Skip to content

Instantly share code, notes, and snippets.

View missinglink's full-sized avatar

Peter Johnson missinglink

View GitHub Profile
@missinglink
missinglink / http_build_url.php
Created March 20, 2012 00:33
A complete HACK to emulate most of functionality of http_build_url() from http_pecl
/**
* A complete HACK to emulate most of functionality of http_build_url() from http_pecl
*/
ob_start();
empty( $this->scheme ) || printf( '%s://', $this->scheme );
empty( $this->user ) || printf( '%s%s@', $this->user,
empty( $this->pass ) ?'': sprintf( ':%s', $this->pass ));
empty( $this->host ) || print( $this->host );
empty( $this->port ) || printf( ':%d', $this->port );
empty( $this->path ) ? print( '/' ) : print( $this->path );
@missinglink
missinglink / doctrine2_reverse_engineer.php
Created August 2, 2012 23:27
Doctrine2 Reverse Engineer Sqlite Database
use \Doctrine\ORM\Tools\EntityGenerator,
\Doctrine\Common\ClassLoader,
\Doctrine\ORM\Configuration,
\Doctrine\Common\Cache\ArrayCache,
\Doctrine\ORM\EntityManager,
\Doctrine\ORM\Mapping\Driver\DatabaseDriver,
\Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
// autoload
$classLoader = new ClassLoader( 'Entities', __DIR__ );
@missinglink
missinglink / app.js
Created September 17, 2012 20:39 — forked from bobbydavid/app.js
socket.io in Express 3
var express = require('express')
, http = require('http')
, connect = require('connect')
, io = require('socket.io');
var app = express();
/* NOTE: We'll need to refer to the sessionStore container later. To
* accomplish this, we'll create our own and pass it to Express
* rather than letting it create its own. */
var sessionStore = new connect.session.MemoryStore();
@missinglink
missinglink / nodecopter dns
Created October 22, 2012 14:11
nodecopter dns
$ dig A nodecopter.com
; <<>> DiG 9.8.1-P1 <<>> A nodecopter.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46757
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 4
;; QUESTION SECTION:
;nodecopter.com. IN A
@missinglink
missinglink / github-api.coffee
Created January 31, 2013 00:07
Ciao Script for the Github README API
#! Requried Headers
headers: 'User-Agent': 'Ciao/Client 1.0'
#> Github API call for node.js README
port: 443
protocol: 'https:'
host: 'api.github.com'
path: '/repos/joyent/node/readme'
headers: 'Accept': 'application/json'
@missinglink
missinglink / embed.v1.js
Created February 19, 2013 14:35
Ingredo v1 embed code
(function () {
var tag = document.createElement('script');
tag.type = 'text/javascript';
tag.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'embed.ingredo.com/v1/embed?referer=' + window.location.href;
var body = document.getElementsByTagName('head')[0];
body.appendChild(tag);
}).call(this);
var zmq = require("zmq");
var socket = zmq.socket("xrep");
socket.bindSync("ipc:///tmp/zmq-issue");
socket.on("message", function(envelope, _, name) {
socket.send([envelope, new Buffer(0), "Hello, " + name.toString()]);
});
@missinglink
missinglink / zmq-install.sh
Created March 5, 2013 13:12
Install ZeroMq 3.x on Ubuntu / OSX
#!/bin/bash
if [[ `uname -s` == 'Darwin' ]]; then
brew update
brew install libtool autoconf automake
else
sudo apt-get update
sudo apt-get install -y libtool autoconf automake uuid-dev git-core
fi
#!/bin/bash
DIVIDER="--------------------------------------------------------------"
EOL=""
if [ -z "$1" ]; then
echo $DIVIDER
echo " Hack 0.01 (Jan 18th 2008)."
echo " Usage: " $0 "[-action]"
echo " Choose which action to perform:"
#!/bin/bash
DIVIDER="--------------------------------------------------------------"
EOL=""
if [ -z "$1" ]; then
echo $DIVIDER
echo " Wifi 0.01 (Jan 17th 2008)."
echo " Usage: " $0 "[-action]"
echo " Choose which action to perform:"