Skip to content

Instantly share code, notes, and snippets.

@dannyid
dannyid / uri.js
Created July 17, 2014 03:50 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@dannyid
dannyid / formatTime.js
Last active August 29, 2015 14:04
Format Time
function formatTime(time) {
//time needs to be a Date object like 'new Date()'
var h = time.getHours(),
m = time.getMinutes(),
s = time.getSeconds(),
m = (m < 10 ? '0' : '' ) + m,
s = (s < 10 ? '0' : '' ) + s,
formattedTime = (h > 12 ? h - 12 : (h === 0 ? h + 12 : h)) + ':' + m + ':' + s + (h >= 12 ? ' PM': ' AM');
return formattedTime;
};
@dannyid
dannyid / remap-capslock
Last active August 29, 2015 14:05
Map Caps Lock to Escape and Control
1. Remap Caps Lock to Control in the Keyboard preference pane (Modifier Keys button).
2. In Karabiner, check "Control_L to Control_L (+ When you type Control_L only, send Escape)".
3. Now, hitting Caps Lock alone will escape while holding it down and hitting another key will act as Control.
via https://coderwall.com/p/63nzva
@dannyid
dannyid / accents-off
Created August 14, 2014 02:57
Turn off key accents when trying to repeat a key on OSX
In terminal run:
defaults write -g ApplePressAndHoldEnabled -bool false
To turn back on:
defaults write -g ApplePressAndHoldEnabled -bool true
@dannyid
dannyid / ocr.js
Last active August 29, 2015 14:07 — forked from joemccann/ocr.js
var ncr = require('nodecr')
, request = require('request')
, fs = require('fs')
, test_img = 'https://www.google.com/images/srpr/logo3w.png' // Change this to your image
// Create image name from end of URL.
// Note this will fail in loads of cases.
var imgName = test_img.split('/').pop()
// Process the image and read the text from it using Tesseract
@dannyid
dannyid / Colloquy Custom.css
Created February 3, 2015 00:40
My custom Colloquy style
/*
http://colloquy.info/project/wiki/Development/Styles/CSS
*/
/* Style based on Bland theme */
body {
}
.envelope {
@dannyid
dannyid / colorblind-helper-bookmarklet.js
Last active August 29, 2015 14:22
Colorblindness Helper Bookmarklet
/**
1. Right click on bookmark bar
2. Click 'Add Page'
3. Give it a title
4. Paste the below into the 'URL' field
5. Save
**/
javascript: (function() {
var e = document.getElementById("colorblind-styling");
@dannyid
dannyid / gh-pages-bookmarklet.js
Last active August 29, 2015 14:24
Instantly go to the gh-pages page of the current repo you're on
/**
1. Right click on bookmark bar
2. Click 'Add Page'
3. Give it a title
4. Paste the below into the 'URL' field
5. Save
**/
javascript:window.location = (function() {
var urlParts = window.location.pathname.split('/').slice(1);
@dannyid
dannyid / gitfiti-helper-bookmarklet.js
Last active August 29, 2015 14:24
Draw drawings on your github contribution timeline and export them to a template. Works alongside https://github.com/gelstudios/gitfiti
/**
* To install:
* 1. Right click on bookmark bar
* 2. Click 'Add Page'
* 3. Give it a title
* 4. Paste the below into the 'URL' field
* 5. Save
*
* To use:
* 1. Navigate to your user page on GitHub, like https://github.com/dannyid
@dannyid
dannyid / uuid.js
Created July 23, 2015 20:42
Generate a UUID
function uuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
};