Skip to content

Instantly share code, notes, and snippets.

View radelmann's full-sized avatar

Rob Adelmann radelmann

View GitHub Profile
@radelmann
radelmann / sublime.keymaps.home.end
Last active August 29, 2015 14:21
Sublime Text - Key Maps - home, end, shift+home, shift+end
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} },
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} },
{ "keys": ["shift+end"], "command": "move_to", "args": {"to": "eol", "extend": true} },
{ "keys": ["shift+home"], "command": "move_to", "args": {"to": "bol", "extend": true } }
@radelmann
radelmann / sublime.sym.link
Last active October 25, 2015 21:44
Sublime Text 2 - Create Symbolic Link - Terminal Cmd
@radelmann
radelmann / node.sublime-build
Last active December 5, 2015 23:44
Node.js Build System for Sublime Text
{
"cmd": ["/usr/local/bin/node", "$file"],
"selector": "source.js"
}
@radelmann
radelmann / alias.chrome
Last active October 22, 2015 04:59
create an alias for opening html file in chrome from cmd line
openChrome() {
open -a "/Applications/Google Chrome.app" $1
}
alias chrome=openChrome
@radelmann
radelmann / js.func.expr.sublime-snippet
Created October 24, 2015 21:30
sublime - js function expression
<snippet>
<content><![CDATA[
var ${1:var} = function (${2:params}) {
${3:body}
};
]]></content>
<description>js function expression</description>
<tabTrigger>varf</tabTrigger>
<scope>source.js</scope>
</snippet>
@radelmann
radelmann / js.if.else.sublime-snippet
Created October 24, 2015 21:51
sublime snippet - js if else
<snippet>
<content><![CDATA[
if (${1:condition}) {
${2:body}
} else {
${3:body}
}
]]></content>
<description>js if else</description>
<tabTrigger>ifelse</tabTrigger>
@radelmann
radelmann / gist:43f135a15eac8c88ccdc
Last active October 27, 2015 20:42 — forked from lucasfais/gist:1207002
Sublime Text 2 - OSX shortcut cheat sheet

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@radelmann
radelmann / formatLongDate.js
Last active October 26, 2015 22:19
Format javascript date object into a user friendly long date string
var formatLongDate = function(date) {
//input: js date object
//output: user friendly long date string, eg: Monday, Oct 26, 2015, 3:11 PM
var options = {
weekday: "long",
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit"
@radelmann
radelmann / getTimeDiff.js
Created October 26, 2015 22:25
return how long ago a date occured in days, hours, or mins.
var getTimeDiff = function(date) {
//input: js date object
//output: returns how long ago the input date occured in a user friendly format
var now = new Date().getTime();
var ms = (now - date.getTime());
var days = Math.round(ms / 86400000); // days
var hrs = Math.round((ms % 86400000) / 3600000); // hours
var mins = Math.round(((ms % 86400000) % 3600000) / 60000); // minutes
if (days > 0) {
@radelmann
radelmann / randomIntMinMax.js
Created October 27, 2015 03:22
javascript - generate a random integer between the min and mix inputs
function getRandomInt (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}