Skip to content

Instantly share code, notes, and snippets.

View boutell's full-sized avatar

Tom Boutell boutell

View GitHub Profile
@boutell
boutell / network-generator.js
Created November 8, 2014 16:36
Network generators in javascript
/* jshint node:true */
var generators = {};
function range(first, last) {
var c = {
first: first,
last: last,
now: first,
step: function(c) {
@boutell
boutell / gist:e63e2f7cc7d418b2dc19
Created September 8, 2014 16:11
Area with lots of controls needing icons
{{ aposArea(page, 'content2', {
controls: [
'Bold',
'Italic',
'Underline',
'Strike',
'Subscript',
'Superscript',
'RemoveFormat',
'NumberedList',
for(var i = begin; i <= end; i++) {
pushOne(i);
}
function pushOne(i) {
q.push({name: 'Artist: ' + i}, function (err) {
console.log('wla' + i)
whop.lookupArtist(i)
});
}
0 info it worked if it ends with ok
1 verbose cli [ 'node', '/Users/boutell/npm/bin/npm', 'publish' ]
2 info using [email protected]
3 info using [email protected]
4 verbose node symlink /usr/local/bin/node
5 verbose publish [ '.' ]
6 verbose cache add [ '.', null ]
7 verbose cache add spec="." args=[".",null]
8 verbose cache add local package /Users/boutell/src/apostrophe-snippets
9 silly lockFile 3a52ce78- .
@boutell
boutell / gist:bf6bf1ae22dae2d77cc1
Created June 6, 2014 17:36
npm guru meditation with 200 OK result code
npm ERR! <?xml version="1.0" encoding="utf-8"?>
npm ERR! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
npm ERR! "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
npm ERR! <html>
npm ERR! <head>
npm ERR! <title>200 OK</title>
npm ERR! </head>
npm ERR! <body>
npm ERR! <h1>Error 200 OK</h1>
npm ERR! <p>OK</p>
@boutell
boutell / gist:3be15e4b5c72597db273
Created June 6, 2014 15:47
nginx redirect example
server {
listen 80;
server_name oldname;
location / {
rewrite ^(.*)$ http://newname$1;
}
}
@boutell
boutell / gist:11055808
Last active August 29, 2015 14:00
Verify server is at least mongodb 2.6
self.db.command({ 'serverStatus': 1 }, function(err, result) {
if (err) {
return callback(err);
}
var versions = result.version.split(/\./);
if ((versions[0] < 2) || ((versions[0] == 2) && (versions[1] < 6))) {
return callback(new Error('\n\nMONGODB TOO OLD: your server must be at least MongoDB 2.6.0.\nYou currently have: ' + result.version));
}
return callback(null);
});
server {
listen 80;
server_name site1 www.site1;
location / {
rewrite ^/apartments http://site2/communities;
rewrite ^.*$ http://site2/something-else;
}
}
@boutell
boutell / gist:7183307
Created October 27, 2013 15:04
Subshells + Bash's "and" and "or" operators = kinda awesome
(
(cd server-status && git pull) ||
(rm -rf server-status && git clone https://github.com/punkave/server-status)
) &&
cd server-status &&
npm install ... etc
@boutell
boutell / nodeup.sh
Last active December 24, 2015 08:09
nodeup: a tiny script that installs the desired version of node on any Ubuntu Linux server. Builds from source but does it quickly with 4 cores. Also installs forever
#!/bin/sh
# On the specified host, install the specified version of node
if [ -z "$1" ]
then
echo "First argument must be somehost.com, second argument must be desired node version"
exit 1
fi