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 readingCategory Archives: Programming
Dynamically 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 Glasir – 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 readingGetting password complexity requirements with VBScript and Powershell
I was helping with a method to check a user’s password against the domain via a program called UMRA. The idea was to use basic JavaScript validation for some of the password checks, but then to send the validation to the server for true verification. There currently is no process for checking a password without first creating the account and checking the error code from Active Directory. I did some searching and found various different methods from Microsoft, but nothing that hit the nail on the head. Then doing one final Google search for “vbscript domain policy” lead me to this website.
Continue readingMaking DVDs from JVC Everio MOD files using Ubuntu, WinFF, Avidemux, and DeVeDe
I purchased the JVC Everio hard disk camcorder with the intention of quickly copying the movie files from it and burning them to a DVD. Since I use Ubuntu and since the camera automatically detected as a USB hard drive, I did not install the supplied software, opting for open source applications instead.
Continue readingIntegrating Real-Time SQL Triggers to manage Active Directory Accounts with UMRA
Triggers allow a set of SQL code to run on several types of SQL actions, such as INSERT, UPDATE, or DELETE. For instance, upon an INSERT, the SQL engine will call the trigger configured for the INSERT action. The trigger specified will have programming logic to perform actions on other systems. With OLE Automation enabled in SQL, the trigger will have the ability to perform actions using COM objects.
Continue readingWhere did CSS and JavaScript go wrong?
Ahhhhhhhh!!! That’s me pulling out my hair every time I start working with divs, CSS, and the DOM’s innerHTML property using JavaScript. I can never figure out if I’m doing something wrong or if someone somewhere made a huge mistake when they made innerHTML.
Continue reading