Skip to content

Instantly share code, notes, and snippets.

@bugventure
bugventure / ScanCode Map.reg
Last active June 25, 2019 12:14
Reorder Win and L Alt keys Windows
; Reference: https://superuser.com/questions/1190329/can-i-switch-the-alt-and-ctrl-keys-on-my-keyboard
; Reference: https://www.experts-exchange.com/articles/2155/Keyboard-Remapping-CAPSLOCK-to-Ctrl-and-Beyond.html
; Location: Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout
; Description: Remaps Left Windows (5b,e0) and Left Alt (38,00) keys
; Note: When using as a .reg file, remove top comment lines
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,5b,e0,38,00,38,00,5b,e0,00,00,00,00
@bugventure
bugventure / README
Created April 10, 2019 12:20
Remap Windows an Alt buttons for Windows on Mac
Reference: https://superuser.com/questions/1190329/can-i-switch-the-alt-and-ctrl-keys-on-my-keyboard
Other useful key codes
```
1d 00 Left Ctrl
1d e0 Right Ctrl
38 00 Left Alt
38 e0 Right Alt
5b e0 Left Windows Key
5c e0 Right Windows Key
$ mocha
update README.md
update changelog.md
update package.json (bump version manually)
$ npm run build
$ static .
navigate to http://127.0.0.1:8080/test and verify all tests pass in the browser
$ git add -A && git commit -m "Prepare vx.x.x"
$ git tag vx.x.x
$ git push origin master --tags
if
ps aux | grep "[g]nome-terminal" > /dev/null
then
xdotool windowactivate `xdotool search --onlyvisible --class gnome-terminal`
else
gnome-terminal &
fi
if
ps aux | grep "[s]ublime_text" > /dev/null
then
xdotool windowactivate `xdotool search --onlyvisible --class sublime_text`
else
subl &
fi
if
ps aux | grep "[c]hrome" > /dev/null
then
xdotool windowactivate `xdotool search --onlyvisible --class google-chrome`
else
google-chrome &
fi
// Source: http://stackoverflow.com/questions/2593637/how-to-escape-regular-expression-in-javascript
RegExp.quote = function(str) {
return (str+'').replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
};
@bugventure
bugventure / base58.js
Created September 13, 2016 15:06
Base58 encode/decode a decimal number
var alphabet = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
var base = alphabet.length; // base is the length of the alphabet (58 in this case)
// utility function to convert base 10 integer to base 58 string
function encode(num) {
var encoded = '';
while (num){
var remainder = num % base;
num = Math.floor(num / base);
encoded = alphabet[remainder].toString() + encoded;
function type(obj) {
var str = Object.prototype.toString.call(obj);
return str.substr(8, str.length - 9).toLowerCase();
}
function isInteger(obj) {
return (obj | 0) === obj; // jshint ignore: line
}
@bugventure
bugventure / requiredir.js
Created October 20, 2014 21:28
node.js requiredir()
function requiredir(dir) {
var fullpath = path.resolve(__dirname, dir),
ret = {},
filepath,
stat,
key;
fs.readdirSync(fullpath).forEach(function forEachFile(file) {
filepath = path.join(fullpath, file);
stat = fs.statSync(filepath);