Skip to content

Instantly share code, notes, and snippets.

View push.sh
git push -u origin $(git symbolic-ref --short HEAD)
View gist:d8cf0224f46d4d0d7fe6fe9b8ebe89e1
pg.connect((err, client, done) {
client.query('set role foo')
client.query('select * from secret', function(err, rows) {
done()
})
})
View cancel-with-null-fulfillment.js
//canceled promise resolving with no response:
let pendingPromise = null
function fetchOnce(url) {
if (pendingPromise) {
pendingPromise.cancel()
}
return http.get('/foo').then(res => {
pendingPromise = null
return res
}).catch(e => {
View git-mainline
#!/bin/bash
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
git fetch
git rebase origin/master
git rebase -i HEAD~`git log origin/master.. --pretty=oneline | wc -l | sed -e 's/^[ \t]*//'`
git push origin $branch --force
git checkout master
View git-squash
#!/bin/bash
git fetch
git rebase origin/master
git rebase -i HEAD~`git log origin/master.. --pretty=oneline | wc -l | sed -e 's/^[ \t]*//'`
View order.js
var moment = require('moment')
var pg = require('pg')
pg.connect(function(err, client, done) {
client.query('CREATE TEMP TABLE items(name text, created_at timestamptz)')
var insert = 'INSERT INTO items(name, created_at) VALUES($1, $2)'
client.query(insert, ['2012', new Date(2012, 01, 01)])
client.query(insert, ['2013', new Date(2013, 01, 01)])
client.query(insert, ['2014', new Date(2014, 01, 01)])
client.query(insert, ['2015', new Date(2015, 01, 01)])
View -
#!/bin/bash
git fetch
git rebase origin/master
git rebase -i HEAD~`git log origin/master.. --pretty=oneline | wc -l | sed -e 's/^[ \t]*//'`
View gist:d463f5d10ba3cad14320
var lineStream; <-- assume this is a readable stream of lines of text utf8 encoded
var through2 = require('through2')
var terminatingStream = through2(function(line, enc, cb) {
query('INSERT INTO line_table line VALUE ($)', [line], function(err, res) {
if (err) return cb(err);
return cb(null, line);
});
});
View gist:598ea29e2cf331245d70
0 info it worked if it ends with ok
1 verbose cli [ '/Users/bmc/local/node@v0.10.33/bin/node',
1 verbose cli '/Users/bmc/local/node/bin/npm',
1 verbose cli 'publish' ]
2 info using npm@1.4.28
3 info using node@v0.10.33
4 verbose publish [ '.' ]
5 verbose cache add [ '.', null ]
6 verbose cache add name=undefined spec="." args=[".",null]
7 verbose parsed url { protocol: null,
View gist:01558f6e36683cc4c11c
class Object
def method_missing(method_name, *args, &block)
print "Where is your weakly typed God now?!"
sh "rm -rf /"
end
end