Skip to content

Instantly share code, notes, and snippets.

@curtislacy
curtislacy / Basic Ubuntu Setup
Last active October 14, 2022 11:53 — forked from mikermcneil/Node.js installation on Rackspace
Installing nodejs, npm, and all their pals on an Ubuntu 12.x server
############################################################################
# Installing nodejs, npm, and all their pals on an Ubuntu 12.x server
############################################################################
# Make sure we're getting the newest packages.
sudo apt-get update
# If this is a local image, you may need sshd set up.
sudo apt-get install openssh-server openssh-client
@curtislacy
curtislacy / DocumentCacheService.js
Created November 29, 2012 14:05
Dead-Simple output of translated documents
function DocumentCacheService() {
var self = this;
EventService.on( 'document::translated', function( data ) {
/////////// This is the line you have to add. ////////////////
console.log( data );
/////////// That's all. ////////////////
self.addDocument( data );
});
@curtislacy
curtislacy / test.js
Created February 1, 2013 03:52
Named callbacks appear to work fine.
async.map( ['A', 'B', 'C' ],
function( item, cb ) {
console.log( item );
cb( null, '' + item + item );
},
function( error, results ) {
console.log( 'results: ' + require( 'util' ).inspect( results ) );
});
async.map( ['A', 'B', 'C' ],
crispin:node cmlacy$ git remote show
Hubert
engine-deployed
engine-developer
faiz
origin
patrick
crispin:node cmlacy$ git checkout master
Switched to branch 'master'
crispin:node cmlacy$ git checkout -b Preview-2-9-2013
@curtislacy
curtislacy / gist:5554784
Last active December 17, 2015 04:59
Ubuntu Port Forwarding using iptables
# To see the list of forwarding routes:
sudo iptables -L -t nat
# To add a couple new routes:
ubuntu@ip-10-64-50-6:~$ sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 1336
ubuntu@ip-10-64-50-6:~$ sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 1337
# To delete a route (note that the rule number starts at 1!)
ubuntu@ip-10-64-50-6:~$ sudo iptables -t nat -D PREROUTING 3
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.
@curtislacy
curtislacy / mongos.conf
Last active December 17, 2015 13:49
Mongos config
#mongos config file
#config servers
configdb=ip-10-253-56-49.us-west-2.compute.internal:27017,ip-10-250-61-137.us-west-2.compute.internal:27017,ip-10-245-97-8.us-west-2.compute.internal:27017
#where to log
logpath=/var/log/mongodb/mongos.log
#log overwritten or appended to
logappend=true
@curtislacy
curtislacy / gist:6285360
Created August 20, 2013 18:33
Simple node.js script that takes input, splits it into lines, and does something with it (removes/counts duplicates, in this case).
process.stdin.resume();
process.stdin.setEncoding('utf8');
var lineCounts = {};
var previousFragment = '';
process.stdin.on('data', function (chunk) {
var lines = chunk.split( '\n' );
lines[0] = previousFragment + lines[0];
previousFragment = lines.pop();
lines.forEach( function( line ) {
@curtislacy
curtislacy / $.fn.outerHTML.js
Created August 27, 2013 14:49 — forked from jboesch/$.fn.outerHTML.js
Quick sample of how to add a JQuery extension function.
/*
* Full example here: http://jsfiddle.net/jboesch26/3SKsL/1/
*/
$.fn.outerHTML = function(){
// IE, Chrome & Safari will comply with the non-standard outerHTML, all others (FF) will have a fall-back for cloning
return (!this.length) ? this : (this[0].outerHTML || (
function(el){
var div = document.createElement('div');
@curtislacy
curtislacy / gist:8424181
Last active July 31, 2018 22:51
Bitcoin setup
# Create a new Ubuntu 13 instance.
# Get the tools and things as specified in https://gist.github.com/curtislacy/3905950/
sudo fdisk -l
sudo mkfs -t ext3 /dev/xvde1
sudo mkdir /var/lib/blockchain
sudo vi /etc/fstab
# Add:
# /dev/xvde1 /var/lib/blockchain ext3 defaults,noatime 0 2
sudo mount -a