I just posted a new app to GitHub called TestFairy. It’s at https://github.com/krypted/TestFairy. It automatically generates unit tests for either a file or a highlighted piece of swift code. It does this using the OpenAI API, so leverages a LLM to write test code. It’s pretty straight forward. Simply highlight the code and in the Editor Menu, click TestFairy, then Generate Tests. I had hoped to post it for free to the App Store, but I didn’t want to distribute my OpenAI API key, or write an intermediary microservice that housed my key that an app uses. The use of an API key is considered an end-around to the In-App…
-
-
Python script to identify CIDR notation
It’s not uncommon to expect CIDR notation vs an IP address in a script (e.g. one that’s being passed to another API. So the following script is an example of using the re module to identify if an entry is in CIDR or not (since it’s not always obvious how to go about doing so): The array can easily be changed or filled with a network mask or array of them rather than fixed as they are here – and the output could easily be to call another function rather than to just print output.
-
Detect Deepfakes and Hacked Audio Programmatically
Deepfakes are a type of synthetic media where a person replaces parts of an image or video with something else, like someone’s likeness. The act of creating deepfakes is known as deepfakery. Deepfakes can be used to create fake news, spread misinformation, or damage someone’s reputation. They can also be used by a service like JibJab just to be funny, although those are obviously cartoonish and not meant to actually fool anyone. There are a number of different approaches to detecting deepfakes. Some of these approaches are based on image forensics, which is the study of digital images to identify and extract hidden information. Other approaches are based on machine…
-
HTTP Success and Error Codes
When you make a request to a web server, the server will respond with a status code. The status code indicates whether the request was successful or not, and if not, what the error was. There are lots of different HTTP response codes, which are three digit codes that generally align with the following classes: Of these, some of the most common ones we run into include the following: HTTP response codes are typically more used by web developers (and web browser developers) to bettter understand the status of a request and to take appropriate action. For example, if a request returns a 404 Not Found status code, the web…
-
Google Cloud Function to convert JSON to YAML
This function takes JSON data as an input, uses the json and yaml modules to convert JSON data to YAML and then returns with the YAML. Deploy the function, as a Python 3.7 runtime, pasting the following code into the code field:
-
Detecting LLM-Generated Code
Large language models (LLMs) are a type of artificial intelligence that generates text, translates languages, writes different kinds of creative content, creates net-new artistic works, and answers questions in an informative way. They are trained on massive datasets of text and code, and can learn to produce human-quality output. Because of how they import massive troves of data and create similar content, they can then be fairly formulaic in their output. A few things to look for to help determine if code was written by an LLM: If you are suspicious that a piece of code was written by an LLM, you can use a number of tools to help…
-
Detecting AI-Generated (LLM) Content In Articles
We hear more and more about the pros and cons of AI. There is a movement to regulate the use, movies about dangers of sentient robots, and those who think AI will free humanity from any boring work, or work that involves a lot of repetitive tasks. Going back to the 1950s and 1960s, what they called AI (or what we might call small shell scripts these days) were supposed to “Augment Human Intellect” as the great Doug Englebart wrote about in his 1962 article https://www.dougengelbart.org/content/view/138 or Vannevar Bush’s “As We May Think” from 1945, available at https://www.theatlantic.com/magazine/archive/1945/07/as-we-may-think/303881/. What is an LLM? A large language model (LLM) is a type…
-
Google Cloud Function to convert JSON to a plist
The following is a Google Cloud Function that converts JSON to a property list. It uses the json and plistlib modules to return the property list data. Deploy the function as a Python 3.7 runtime with the following in the function code field:
-
Scripts To Show Browser Extensions In Windows
Posted scripts to return browser extensions installed in Firefox, Google Chrome, and Windows Edge at https://github.com/krypted/extensionsmanager/tree/main/Windows%20Extensions. There’s a python and a VBscript version of each. The VBScript uses a Set objShell = CreateObject(“WScript.Shell”) statement to create a new instance of the WScript.Shell object and the strExtensionsPath = objShell.ExpandEnvironmentStrings(“%APPDATA%\Mozilla\Firefox\Profiles\%USERNAME%\extensions”) statement gets the path to the extensions directory, so if it’s different for a given environment, make sure to change that per-script. The Set colExtensions = objShell.EnumFiles(strExtensionsPath, “*.xpi”) statement gets a collection of all the extensions in the extensions directory. The Chrome version looks for crx, etc. Might be a way to do these with custom extension types that I’m not aware…
-
Simple sqlite3 Fuzzer
One of my favorite ways to find escape defects in code is to employ a generic fuzzer. I typically have 5-10 laptops running fuzzers for various projects at a time. I was recently doing some research on sqlite3 and so started to fuzz the implementation built into macOS. The fuzzer generates random SQL statements and executes them against a SQLite database file. If any errors are encountered, they will be printed to the console: There’s not much logic here. Add more complex tests to improve it. Like SQL grammar to generate valid SQL statements, or a genetic algorithm to evolve SQL statements that are more likely to find bugs. Use…