Skip to content

Instantly share code, notes, and snippets.

git push -u origin $(git symbolic-ref --short HEAD)
pg.connect((err, client, done) {
client.query('set role foo')
client.query('select * from secret', function(err, rows) {
done()
})
})
//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 => {
#!/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
#!/bin/bash
git fetch
git rebase origin/master
git rebase -i HEAD~`git log origin/master.. --pretty=oneline | wc -l | sed -e 's/^[ \t]*//'`
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)])
@brianc
brianc / -
Created March 12, 2015 00:44
#!/bin/bash
git fetch
git rebase origin/master
git rebase -i HEAD~`git log origin/master.. --pretty=oneline | wc -l | sed -e 's/^[ \t]*//'`
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);
});
});
@brianc
brianc / gist:598ea29e2cf331245d70
Created December 13, 2014 18:36
npm-publish error
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,
class Object
def method_missing(method_name, *args, &block)
print "Where is your weakly typed God now?!"
sh "rm -rf /"
end
end