When testing REST-based web services that return JSON you may decide to use a shell script with cURL commands. Some services require a call to authorize a client and a second call to perform some action. In these cases, you would need to store the returned information in variables to use in subsequent calls. This is only a simple example of why you would want a shell script to parse JSON and return a value, but the usefulness of a JSON parser goes beyond a simple example like this.
Continue readingAuthor Archives: Allan Bogh
A simple c++ string replace function
I’ve been privileged by higher-level language string functions, such as PHP’s easy to use str_replace function, that I’ve forgotten how performing such simple tasks in lower-level languages like C++ can be such a hassle. Aside from using some library (of which I’m not aware yet), here’s a simple string replace function which is similar to the PHP version. In this case the function will directly modify the original string, not return an instance of a new string.
Continue readingDynamically Modifying Input Elements on Click
Sometimes it’s necessary to modify an input form element when a user clicks on that element. In some cases, the form element can contain information regarding what information is appropriate, or what format is expected. The most common example is showing “mm/dd/yyyy” in a text-based date field and automatically removing that information when a user clicks on the field.
Continue readingJavascript Benchmarking with JSBenchtest
Javascript benchmarking couldn’t be easier. With this webpage you can input any Javascript code and test how fast it is. The webpage will automatically call your code for 1,000,000 iterations and report the total amount of time that it took to execute. It will even output a variable that you can use for debugging. You can now test an algorithm, make a modification, and test again to see if the modification helped the execution time.
Click here to benchmark some code.
Continue readingSwitch vs If – Which is faster?
In programming there are two different methods that people use to test variables that have a number of different values. One method is to use the If statement and define blocks of code to perform. The other common method is to use a switch statement and list all possible values, perhaps including a default value, and perform some process inside the appropriate section of code.
Continue readingJavascript: Flattening a Multidimensional Array
A friend had asked me about converting a 2-dimensional array into a flat 1-dimensional array. In array form this would be (written as was provided to me):
in = [1,"2",[3,"4"]];
out = [1,"2",3,"4"]; //this is what he wanted out.
Continue reading Raspberry Pi now available!
The Raspberry Pi is a computer, it’s a platform for development, it’s an educational tool that’s cheap enough for students and schools, it’s a media center PC, it’s a server, and it can be a robot brain.
Continue readingGlasir – an open source PHP/HTML5 media player
Glasir is an open source PHP/HTML5 media player for a personal music collection of unlimited size. For use with Chrome, Firefox, and Android phones. It’s a project that I developed and open sourced for people to install it on their personal web servers and point it at a music folder.
Continue readingSaving a Failing Hard Drive with GNU/Linux
I came to find out that my mother’s computer’s hard drive was failing. Programs took a long time to open and the computer would suddenly reboot for no reason. I discovered that the hard drive had bad sectors, which means potentially lost data if it decided to quit before I could save the data onto a different drive. Various GNU/Linux-based systems saved the day.
Continue readingHow to Set Up an Ubuntu Active Directory Client
Here I will explain a solution that worked for me to configure an Ubuntu workstation to authenticate with an Active Directory domain. The workstation was able to browse domain resources (ie, filesystem) without having to log in and it pulled the AD group information from the domain controller. A process was used to map certain groups to Linux (Ubuntu) groups, however extensive verification of the results could not be performed.
Continue reading