Skip to content

Instantly share code, notes, and snippets.

View itsananderson's full-sized avatar

Will Anderson itsananderson

View GitHub Profile
@itsananderson
itsananderson / chain-promises.js
Created June 23, 2015 20:51
Storing state at the top-level scope to be shared between promise handlers.
var user;
var balance;
getCurrentUser()
.then(function (currentUser) {
user = currentUser;
return getBalance(user);
})
.then(function (userBalance) {
balance = userBalance;
@itsananderson
itsananderson / .gitconfig
Created February 13, 2015 00:32
git diff/merge config for kdiff3
[diff]
tool = kdiff3
[difftool "kdiff3"]
cmd = 'c:\\Program Files\\kdiff3\\kdiff3' $LOCAL $REMOTE
keepBackup = false
trustExitCode = true
keepTemporaries = false
[merge]
tool = kdiff3
[mergetool "kdiff3"]
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div style="height: 1584018px;">
Inspect my layout
</div>
</body>
</html>
@itsananderson
itsananderson / a.js
Created October 12, 2014 16:18
An illustration of module export behavior in Node
module.exports = Math.random();
@itsananderson
itsananderson / backbone-wat.js
Created October 7, 2014 05:49
Backbone API designers. WTF is wrong with you?
var posts = new wp.api.collections.Posts();
posts.fetch().done(function() {
var post = posts.first().attributes;
// ...
});
@itsananderson
itsananderson / .gitconfig
Created August 27, 2014 22:22
My setup for automatically configuring user.email when cloning a repo
[alias]
email-guess = !. ~/.git-scripts/email-guess.sh
var paths = require('./paths');
gulp.task('lint', function() {
gulp.src(paths.app.concat(paths.test))
.pipe(lint());
});
gulp.task('minify', function() {
gulp.src(paths.app)
.pipe(minify());
@itsananderson
itsananderson / build-status.cpp
Created July 25, 2014 02:18
Build Status Monitor
/*
Repeating Web client
This sketch connects to a a web server and makes a request
using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or
the Adafruit Ethernet shield, either one will work, as long as it's got
a Wiznet Ethernet module on board.
This example uses DNS, by assigning the Ethernet client with a MAC address,
IP address, and DNS address.
@itsananderson
itsananderson / repeating-client.cpp
Created July 24, 2014 10:38
Arduino client to send requests in a loop
/*
Repeating Web client
This sketch connects to a a web server and makes a request
using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or
the Adafruit Ethernet shield, either one will work, as long as it's got
a Wiznet Ethernet module on board.
This example uses DNS, by assigning the Ethernet client with a MAC address,
IP address, and DNS address.
@itsananderson
itsananderson / fib-gen.js
Created July 22, 2014 06:28
Fibonacci generator in ES6
function* fib() {
var a = 0;
var b = 1;
while(true) {
yield a;
b = a+b;
a = b-a;
}
}