Samuel N Mensah

Thoughts & Ideas in the Dev World

How to retrieve query string values in javascript

Here is a simple method which will allow you retrieve query string values in javascript. function getParameterByName(name) { name = name.replace(/[\[]/, “\\[").replace(/[\]]/, “\\]”); var regex = new RegExp(“[\\?&]” + name + “=([^&#]*)”), results = regex.exec(; return results == null ? “” : decodeURIComponent(results[1].replace(/\+/g, ” “));} Usage: var prodId = getParameterByName(‘prodId’);

How to generate custom reward codes

So you need a couple hundred random codes to test your application and you’re thinking, do I write a quick and dirty program to do that for me? The answer is no. Honestly, I hate re-inventing the wheel so If I can find a quick (and free) tool then why not? Random code generator is one […]

Manipulating files and Directories in c#

Introduction: The following post summarizes how to manipulate files and directories with a brief summary of the most common classes you’re likely to use.The following post summarizes how to manipulate file and directories.   Namespace: System.IO : The System.IO namespace contains types that allow reading and writing to files and data streams, and types that provide […]


Advanced HTML5 – Geolocation

Geolocation is a feature in HTML5 which enables browsers to determine the geographical position of a user. For privacy reasons, geolocation is disabled by default in all supporting browsers. Users have to explicitly give permission to the browser before their position can be determined. The geolocation API is published through the navigator.geolocation object. Retrieving the […]


PowerShell Function to Disable User Access Control (UAC)

At times it is necessary to disable Windows User Access Control. It can be done programmatically with the following functions. Function Disable-UAC { $EnableUACRegistryPath = “REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System” $EnableUACRegistryKeyName = “EnableLUA” $UACKeyExists = Test-RegistryValue -RegistryPath $EnableUACRegistryPath -KeyName $EnableUACRegistryKeyName if ($UACKeyExists) { Set-ItemProperty -Path $EnableUACRegistryPath -Name $EnableUACRegistryKeyName -Value 0 } else { New-ItemProperty -Path $EnableUACRegistryPath -Name $EnableUACRegistryKeyName -Value […]


PowerShell Function to set desktop background

Have you ever wondered how you could programmatically change the background of your desktop? Well here’s a simple function which will allow you to do that in PowerShell. The registry setting for your wallpaper is found in HKCU:\Control Panel\Desktop\ under a value called wallpaper. Function Set-WallPaper($value) { Set-ItemProperty -path ‘HKCU:\Control Panel\Desktop\’ -name wallpaper -value $value […]


PowerShell function to create local user using ADSI

This simple script demonstrates how to create a local user on your machine. The function accepts 3 parameters: username, password & accountDescription & makes use of the Active Directory Service Interfaces (ADSI) which are a set of interfaces used to access the features of directory services.   function Create-LocalUser($UserName ,$Password) { if(!$UserName -or !$Password) { […]


How to tell PowerShell to wait for each command to end before starting the next

There are numerous ways to run executables via command line. PowerShell provides one such option via a cmdlet called Start-Process. Start-Process  allows you to run one or more processes on the local computer. Parameter Set: Default Start-Process [-FilePath] <String> [[-ArgumentList] <String[]> ] [-Credential <PSCredential> ] [-LoadUserProfile] [-NoNewWindow] [-PassThru] [-RedirectStandardError <String> ] [-RedirectStandardInput <String> ] [-RedirectStandardOutput […]

Previous Posts

Theme created by Powered by

  • Twitter