Skip to content

Instantly share code, notes, and snippets.

View adammw's full-sized avatar
👨‍💻
Hacking on Kubernetes Platform @ Zendesk

Adam Malcontenti-Wilson adammw

👨‍💻
Hacking on Kubernetes Platform @ Zendesk
View GitHub Profile
@fuba
fuba / download_ustream_live.pl
Created October 19, 2010 16:07
download live video from ustream using rtmpdump.
#!/usr/bin/perl
# this script is an implementation of http://textt.net/mapi/20101018201937
use strict;
use warnings;
use LWP::Simple;
my ($ustream_url, $file, $stop) = @ARGV;
@peterhost
peterhost / node_debian_init.sh
Created November 25, 2010 11:41
Daemon init script for node.js based app/server (DEBIAN/UBUNTU)
#!/bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
@jameshartig
jameshartig / gist:761520
Created January 1, 2011 02:58
How to get php-cgi to detect if you have reset the connection
/*
The following example shows how to correct detect connection status under php-cgi
Works under apache and nginx. Cannot get it to work under lighttpd.
*/
ignore_user_abort(true);
ob_implicit_flush(true); //put these at the beginning
//loop and keep doing something until the user aborts
while (true) {
@hanshuebner
hanshuebner / plist-parser.js
Created June 1, 2011 05:44
plist parser written in node.js
var plistParser = require("../lib/sax").parser(false, {lowercasetags:true, trim:true}),
sys = require("sys"),
fs = require("fs");
function entity (str) {
return str.replace('"', '"');
}
plistParser.getInteger = function (string) {
this.value = parseInt(string, 10);
@mathiasbynens
mathiasbynens / unsafeWindow.user.js
Created August 13, 2011 13:21
`unsafeWindow` polyfill (for use in user scripts)
// ==UserScript==
// @name Emulate `unsafeWindow` in browsers that don’t support it.
// ==/UserScript==
// http://mths.be/unsafewindow
window.unsafeWindow || (
unsafeWindow = (function() {
var el = document.createElement('p');
el.setAttribute('onclick', 'return window;');
return el.onclick();
@adammw
adammw / gist:1584453
Created January 9, 2012 19:18
YouTube Video URL extractor function snippet
(function(){a=[];yt.playerConfig.args.url_encoded_fmt_stream_map.split(",").forEach(function(d){e={};d.split("&").forEach(function(b){var b=b.split("="),c=decodeURIComponent;e[c(b[0])]=c(b.slice(1).join("="))});a.push(e)});return a})()
@joergschiller
joergschiller / a2dp_sink_ubuntu_linux.md
Created January 24, 2012 23:05
A2DP Sink on Ubuntu Linux with bluez (streaming bluetooth stereo audio from smartphone to pc)

Howto Enable and Use A2DP Sink on Ubuntu Linux with Bluez

  1. Add Enable=Source to /etc/bluetooth/audio.conf right after [General].

  2. Find address in form XX:XX:XX:XX:XX:XX of phone with hcitool scan.

  3. Pair and trust smartphone with sudo bluez-simple-agent hci0 XX:XX:XX:XX:XX:XX and sudo bluez-test-device trusted XX:XX:XX:XX:XX:XX yes.

  4. Create loopback in pulseaudio connection bluetooth a2dp source with alsa sink:

High level style in javascript.

Opinions are like assholes, every one has got one.

This one is mine.

Punctuation: who cares?

Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.

@ebidel
ebidel / handle_file_upload.php
Created April 18, 2012 03:23
Uploading files using xhr.send(FormData) to PHP server
<?php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,
@domenic
domenic / portable-node.md
Created May 25, 2012 21:03
Tips for Writing Portable Node.js Code

Node.js core does its best to treat every platform equally. Even if most Node developers use OS X day to day, some use Windows, and most everyone deploys to Linux or Solaris. So it's important to keep your code portable between platforms, whether you're writing a library or an application.

Predictably, most cross-platform issues come from Windows. Things just work differently there! But if you're careful, and follow some simple best practices, your code can run just as well on Windows systems.

Paths and URLs

On Windows, paths are constructed with backslashes instead of forward slashes. So if you do your directory manipulation