Skip to content

Instantly share code, notes, and snippets.

View kevin-miles's full-sized avatar
👋
AFK

kevin-miles

👋
AFK
View GitHub Profile
@kevin-miles
kevin-miles / slice arguments
Last active December 28, 2015 14:39
Javascript - Use array prototype slice to collect arguments of a function
//notice that there are no parameters defined, but arguments are still copied
function doSomething () {
var args = Array.prototype.slice.call (arguments);
console.log (args);
}
doSomething ("Water", "Salt", "Glue"); // ["Water", "Salt", "Glue"]
@kevin-miles
kevin-miles / throw or catch javascript errors
Created November 22, 2013 03:52
throw or catch errors?
The best way to think about the difference between throwing errors and catching errors is this: you should catch errors only if you know exactly what to do next. The purpose of catching an error is to prevent the browser from responding in its default manner; the purpose of throwing an error is to provide information about why an error occurred. - Zakas, Nicholas C.
@kevin-miles
kevin-miles / gist:7619549
Created November 23, 2013 20:31
javascript scope
//source: http://stackoverflow.com/questions/500431/javascript-variable-scope
// a globally-scoped variable
var a=1;
// global scope
function one(){
alert(a);
}
@kevin-miles
kevin-miles / gist:11264907
Last active August 29, 2015 14:00
OSX No Sound Fix
sudo kextunload /System/Library/Extensions/AppleHDA.kext
sudo kextload /System/Library/Extensions/AppleHDA.kext
@kevin-miles
kevin-miles / gist:ce1f996e5c59c7b4a9bf
Last active August 29, 2015 14:01
Lexical Analyzer State Table
string const state[21][15] =
{
/* ignore me */ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
/* start */ "", "2", "4", "6", "19", "8", "19", "19", "12", "19", "14", "17", "1", "19", "",
/* in id */ "", "2", "2", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "",
/* end id */ "", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "",
/* in # */ "", "5", "4", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "",
/* end # */ "", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "",
/* in {} */ "", "6", "6", "6", "7", "6", "6", "6", "6", "6", "6", "6", "6", "6", "",
/* end {} */ "", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "",
@kevin-miles
kevin-miles / gist:be5982d96772c9dd30e9
Created June 12, 2014 13:32
Selenium Remote Webdriver Connect To
http://127.0.0.1:4444/wd/hub
@kevin-miles
kevin-miles / gist:4b672dfe715729ee05fd
Created June 15, 2014 21:54
Selenium Webdriver Node Mocha
var BASE_URL = 'http://google.com';
var assert = require('assert'),
webdriver = require('selenium-webdriver'),
colors = require('colors');
//build all the drivers to be used
var chrome_driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
@kevin-miles
kevin-miles / gist:ecc1b8f174b70d860ada
Created July 17, 2014 01:14
import file from another directory
import os
import sys
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/' + '../..'))
@kevin-miles
kevin-miles / gist:e8fb0e1a6b3a7c3c815b
Created July 22, 2014 01:30
Enable and Disable OSX Keyboard
To disable the Macbook keyboard, type (or copy and paste) the following into terminal:
sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/
To re-enable it, type (or copy and paste) the following into terminal (if copying and pasting, don't forget to copy a linebreak to make the command work):
sudo kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/
@kevin-miles
kevin-miles / gist:4beabbb3c9c455f1a3f4
Created August 29, 2014 17:12
Beautify cURL Response
curl -X GET -H 'Authentication: this:that' 'http://localhost:3001/myserver/cmd' | python -mjson.tool