Skip to content

Instantly share code, notes, and snippets.

@sandfox
sandfox / node-s3.js
Created November 16, 2011 16:41
Amazon S3 nodejs example - (not my own work)
/*
*
* A simple S3 library written because the other implementation doesn't meet needs and is outdated.
*
* What this library is good for:
*
* ** Can send files any size (although S3 is currently limited at 5 gigs)
* ** Streams files from disk to socket -- minimal memory footprint and very efficient
* ** Uses sockets to support 100 Continue (especially usefull for large files)
* - the body is only sent after amazon approves the signed header
@sandfox
sandfox / router.js
Created January 27, 2012 15:51
Simple Nodejs http request router
var url = require('url');
exports.getRouter = function getRouter()
{
var routes = [];
function addRoute(method, path, callback)
{
var route = {
@sandfox
sandfox / CertificateGeneration.sh
Created February 15, 2012 00:11
TLS certificate inspection example (using nodejs)
###
#Step 1 - Generate server certificates etc... (most of this code is horribly ripped off from nodejs docs currently -> http://nodejs.org/docs/latest/api/tls.html)
###
#Assuming your starting from a clean directory
mkdir server
cd server
#generate private key
@sandfox
sandfox / auth.js
Created February 19, 2012 20:21
Nodejs Auth example
var app = connect.createServer(
   //connect.logger(),
   connect.cookieParser(),
   connect.session({secret : 'wibble', key : 'phoenix.sid', store: sessionStore}),
   connect.bodyParser(),
   
   //Move this out of here later for cleanliness
   connect.router(function(app){
app.post('/auth', function(req, res) {
           
@sandfox
sandfox / jerome.txt
Created March 8, 2012 11:25
Shit I get from recruiters...
Hi James Edward,
It was a cold day, Gustav arrived for his first day at work clutching his laptop and some books on the Zend framework. His past nights had been disturbed by the 'Tetris effect', lines of pure code produced by his unconscious mind in his sleep, dropping down, one atop the other, leaving him in somewhat of a half awake, half asleep state throughout the nights. His world view was formed through code, indeed giving him great insight, yet leaving him somewhat distant from those around him.
He was starting to question his sanity. A formidable PHP Zend coder, instead of taking rest in its conventional sense, his mind would be occupied with thoughts on RESTful services, instead of using soap in the bath, he would be comparing SOAP with RESTful services. He took a single bite on a pear, the only food he had eaten in two weeks, and instantly started thinkng of PEAR and PECL extensions. Instead of eating, he would usually be coding, his natural hunger instinct shut off from the deep levels of focus
@sandfox
sandfox / index-luke.js
Created May 6, 2012 20:44
lukes http server
var config = {
servers: [
{ host: '192.168.33.10', port: 80 },
{ host: '192.168.33.11', port: 80 }
]
};
var http = require('http'),
httpProxy = require('http-proxy'),
Word.
Go to http://translate.google.com
Select German.
Put in:
pv zk bschk pv zk pv bschk zk pv zk bschk pv zk pv bschk zk bschk pv bschk bschk pv kkkkkkkkkk bschk bschk bschk pv zk bschk pv zk pv bschk zk pv zk bschk pv zk pv bschk zk bschk pv bschk bschk pv kkkkkkkkkk bschk bschk bschk pv zk bschk pv zk pv bschk zk pv zk bschk pv zk pv bschk zk bschk pv bschk bschk pv kkkkkkkkkk bschk bschk bschk pv zk bschk pv zk pv bschk zk pv zk bschk pv zk pv bschk zk bschk pv bschk bschk pv kkkkkkkkkk bschk bschk bschk pv zk bschk pv zk pv bschk zk pv zk bschk pv zk pv bschk zk bschk pv bschk bschk pv kkkkkkkkkk bschk bschk bschk
@sandfox
sandfox / Cat.php
Created May 16, 2012 15:31
Simple Model - Mapper abstract pair for PHP
<?php
namespace Sandfox\Model;
use \Sandfox\Model\ModelAbstract;
class Cat extends ModelAbstract
{
/**
* Define data names and defaults here
-module(hello).
-export([start/0]).
start() ->
spawn(fun() -> loop() end).
loop() ->
receive
hello ->
io:format("Hello, World!~n"),
@sandfox
sandfox / puppet.md
Created July 23, 2012 23:06
Quick and dirty instructions on how to bring some types of server to life

Starting the PuppetMaster v1

  • Create security group (SG) for puppet-master
  • Create new small instance 64bit, EBS backed, ubuntu 12.04 in correct Region using puppet-master SG
  • SSH into instance (username ubuntu)
  • Grab Puppet Labs deb packages for 12.04 `wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb && sudo dpkg -i puppetlabs-release-precise.deb'
  • Update the instance sudo apt-get update && sudo sudo apt-get dist-upgrade
  • install puppet and git 'sudo apt-get install puppetmaster git'
  • set puppetmaster running. sudo puppet resource service puppetmaster ensure=running enable=true