Skip to content

Instantly share code, notes, and snippets.

View tgvashworth's full-sized avatar

Tom Ashworth tgvashworth

View GitHub Profile
(function (scope, name, fn, map) {
if (typeof define === 'function' && define.amd) {
define(fn)
} else if (typeof exports === 'object') {
var rtn = fn(require, module.exports, module);
if (module.exports !== rtn &&
typeof rtn !== 'undefined') module.exports = rtn;
} else {
var exp = {}, mod = { exports: exp },
reqr = function (i) { return map[i] ? scope[map[i]] : scope[i]; };
@tgvashworth
tgvashworth / deferCallable.js
Last active December 19, 2015 01:19
deferCallable
/**
* Defer callable. Kinda tricky to explain. Basically:
* "Don't make newFn callable until I tell you via this trigger callback."
*
* Example:
// Only start logging after 3 seconds
var log = function (str) { console.log(str); };
var deferredLog = deferCallable(log, function (done) {
setTimeout(done, 3000);
@tgvashworth
tgvashworth / gist:5704768
Last active December 18, 2015 01:38
Make staging easy.
#!/bin/sh
# install:
# cd /usr/local/bin && wget -O stage-me https://gist.github.com/phuu/5704768/raw/gistfile1.sh && chmod u+x stage-me
branch=`git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3-`
echo "Merging ⭠ $branch into ⭠ staging."
read -p "Is this correct? [y/N] : " -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
#!/bin/sh
# Commit and sync to Github
# To install, run:
# cd /usr/local/bin && wget -O commit-and-sync https://gist.github.com/phuu/5680243/raw/gistfile1.sh && chmod u+x commit-and-sync
# then restart yaw terminals.
BRANCH="$(git symbolic-ref HEAD 2>/dev/null)"
# Reconnaissance
// io.js
define(['jquery'], function ($) {
return $({});
});
...
// main.js
require(['io', 'toast'], function (io, toast) {
io.on('my_event', function () {});
@tgvashworth
tgvashworth / gist:5598252
Last active December 17, 2015 10:58
Github to Bitbucket
#!/bin/sh
# Github -> Bitbucket
# - Save this in /usr/local/bin as github-to-bitbucket
# - Then:
# cd /usr/local/bin
# chmod u+x github-to-bitbucket
# - Then restart your terminal
# - You should now have a github-to-bitbucket command

Why?

Why are am I here? Why am I alive, on this planet, at this time?

A big question? No, a deepity. In one reading, truth. In another, nonsense.

The word ‘why’ can be taken in two ways: why meaning for what purpose did x happen; and why meaning how did x happen. Let's look at ‘why am I here?’ from both perspectives.

In the first sense, the question can be rewritten as ‘for what purpose am I here?’. In the second, ‘how is it that I came to be here?’.

@tgvashworth
tgvashworth / gist:5478385
Last active December 16, 2015 18:29
local tld dreamcode/ideas
// Array
// pros:
// simple, no duplication of ports
// cons:
// a tld can be duplicated
{
6000: [
"api.name.dev",
"admin.name.dev"
@tgvashworth
tgvashworth / examples.js
Created April 21, 2013 20:21
Managing Modularity – Code Example
var myModule = (function () {
// Private
var name = "AsyncJS";
// Public
return {
getName: function () {
return name;
},
setName: function (value) {
return (name = value);
@tgvashworth
tgvashworth / .gitconfig
Last active December 13, 2022 14:15
.gitconfig & .gitignore
# A ~/.gitconfig file
[user]
name = YOUR NAME
email = YOUR EMAIL
[github]
user = YOUR USERNAME
token = YOUR TOKEN
[core]
quotepath = false
editor = nvim