Skip to content

Instantly share code, notes, and snippets.

@ijprest
ijprest / commodore-vic20.kbd.json
Last active August 29, 2015 14:26
Commodore VIC-20
[
{
"backcolor": "#e8e1ca"
},
[
{
"x": 0.25,
"c": "#413c2c",
"t": "#f1ecda",
"p": "SA R1",
@ijprest
ijprest / colors.js
Last active August 29, 2015 14:26 — forked from mikelikespie/colors.js
Quick code to convert sRGB to CIE L*a*b* and back.
var $color = {};
(function () {
function Lab (l, a, b) { this.l = l; this.a = a; this.b = b; }
$color.Lab = function (l,a,b) { return new Lab(l,a,b); };
function XYZ (x, y, z) { this.x = x; this.y = y; this.z = z; }
$color.XYZ = function (l,a,b) { return new XYZ(x, y, z); };
function sRGBLinear (r, g, b) { this.r = r; this.g = g; this.b = b; }
$color.sRGBLinear = function (r,g,b) { return new sRGBLinear(r,g,b); };
@ijprest
ijprest / convert-to-amd.js
Created July 20, 2015 23:49
Very simple script to convert a normal JS module to a RequireJS-compatible AMD module; intended for command-line usage, and integration into build systems.
#!/usr/bin/env node
///
/// Very simple script to convert a normal JS module to a RequireJS-compatible
/// AMD module; intended for command-line usage, and integration into build
/// systems.
///
/// Reads from stdin & writes to stdout; output can be piped to uglifyjs to
/// minify/compress the code.
///
/// Examples:
function Confirm-Host {
<#
.SYNOPSIS
Prompts the user to OK or Cancel an operation via the host.
.DESCRIPTION
Prompts the user to OK an operation by hitting ENTER or cancel
it by hitting ESC.
.EXAMPLE
if(Confirm-Host) { ... }
.OUTPUTS
@ijprest
ijprest / IniFile.psm1
Created April 13, 2015 00:57
Powershell function to read a standard Windows INI file (using Win32 APIs)
#requires -Version 2
Add-Type -Name _e9b6b3c331bdc58f488487320803ad89 -namespace _e95bcd88febe44bf44ad6600fdd509e7 -MemberDefinition @'
[DllImport("kernel32",CharSet=CharSet.Unicode)] public static extern int GetPrivateProfileStringW(string section, string key, string def, IntPtr retVal, int size, string filePath);
[DllImport("kernel32",CharSet=CharSet.Unicode)] public static extern int GetPrivateProfileStringW(string section, IntPtr key, string def, IntPtr retVal, int size, string filePath);
[DllImport("kernel32",CharSet=CharSet.Unicode)] public static extern int GetPrivateProfileStringW(IntPtr section, IntPtr key, string def, IntPtr retVal, int size, string filePath);
[DllImport("kernel32",CharSet=CharSet.Unicode)] public static extern long WritePrivateProfileStringW(string section, string key, string val, string filePath);
'@
function Read-IniFile {
<#
.SYNOPSIS
param(
[int]$Delay = 0
)
$Win32 = Add-Type -Name WinAPICall -Namespace SystemParametersInfo -PassThru -MemberDefinition @'
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);
'@
if($Win32::SystemParametersInfo(0x17,$delay,$null,0)) {
Write-Host "Keyboard delay changed to: $delay"
} else {
param (
[string]$UserName = "$((Get-ChildItem Env:USERDOMAIN).Value)\$((Get-ChildItem Env:USERNAME).Value)",
[string]$Password = $(Read-Host "Enter a password for user '$UserName'")
)
# Set up auto-logon
$resumed = 0
$auditing = 0
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State").ImageState -ne "IMAGE_STATE_COMPLETE") {
$auditing = 1
@ijprest
ijprest / guidgen.ahk
Created October 6, 2012 20:00
AutoHotkey (AHK) script to generate & paste a new GUID
; Exposes two hotkeys:
; - Win+G generates & pastes a new lowercase guid
; - Win+Shift+G generates & pastes a new UPPERCASE guid
; In both cases, the guid is left on the clipboard so you can easily paste it more than once.
;
GUID()
{
format = %A_FormatInteger% ; save original integer format
SetFormat Integer, Hex ; for converting bytes to hex
VarSetCapacity(A,16)
@ijprest
ijprest / setprompt.bat
Created September 15, 2011 03:14
CMD Batch file to put a separator between each command you run at the prompt
@echo off
for /f "tokens=1,2 delims=: " %%Q IN ('mode con:') DO IF "%%Q"=="Columns" SET _COLS=%%R
SET /A _COLS=%_COLS% - 13
SET _P=
:loop
SET _P=%_P%-
SET /A _COLS=%_COLS% - 1
IF %_COLS% GTR 0 goto :loop
SET PROMPT=%_P%$S$T$_$P$G
@ijprest
ijprest / tohex.bat
Created September 10, 2011 02:07
CMD Batch file conversion of a decimal number to hex
@echo off & setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
set LOOKUP=0123456789abcdef &set HEXSTR=&set PREFIX=
if "%1"=="" echo 0&goto :EOF
set /a A=%* || exit /b 1
if !A! LSS 0 set /a A=0xfffffff + !A! + 1 & set PREFIX=f
:loop
set /a B=!A! %% 16 & set /a A=!A! / 16
set HEXSTR=!LOOKUP:~%B%,1!%HEXSTR%
if %A% GTR 0 goto :loop
echo %PREFIX%%HEXSTR%