Skip to content

Instantly share code, notes, and snippets.

View konsumer's full-sized avatar

David Konsumer konsumer

View GitHub Profile
@chanon
chanon / gist:661597
Created November 3, 2010 19:50
Facebook iframe Canvas App Authentication in node.js
var querystring = require("querystring");
var base64ToString = function(str) {
return (new Buffer(str || "", "base64")).toString("ascii");
};
var base64UrlToString = function(str) {
return base64ToString( base64UrlToBase64(str) );
};
@jedp
jedp / autocomplete.py
Created April 18, 2011 19:20 — forked from j4mie/autocomplete.py
autocomplete.py - redis autocompleter
"""
A redis autocomplete example for multi-word phrases.
Based on:
Ruby original: http://gist.github.com/574044
Python original: https://gist.github.com/577852
See options below for usage
Requires http://github.com/andymccurdy/redis-py/
@140bytes
140bytes / LICENSE.txt
Created May 9, 2011 16:13
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@metal3d
metal3d / nat-traversal.js
Created August 9, 2011 22:16
NAT Traversal with node (0.5.x)
/*
NAT traversal system to let 2 computers behind firewall to communicate.
Example:
Client A (your machine) has public ip 1.1.1.1
Client B (distant machine) has public ip 2.2.2.2
You want to bind port 5556 on your machine
Distant Client want to bind port 5557
@LeaVerou
LeaVerou / vunits.js
Created November 8, 2011 11:05
Static polyfill for vw, vh, vm units
/**
* Polyfill for the vw, vh, vm units
* Requires StyleFix from -prefix-free http://leaverou.github.com/prefixfree/
* @author Lea Verou
*/
(function() {
if(!window.StyleFix) {
return;
var mongoose = require('mongoose')
, Schema = mongoose.Schema
, db = mongoose.connect('localhost', 'testing_streaming').connection
, Stream = require('stream').Stream
, express = require('express')
/**
* Dummy schema.
*/
@jaysonrowe
jaysonrowe / FizzBuzz.js
Created January 11, 2012 01:39
FizzBuzz JavaScript solution
for (var i=1; i <= 20; i++)
{
if (i % 15 == 0)
console.log("FizzBuzz");
else if (i % 3 == 0)
console.log("Fizz");
else if (i % 5 == 0)
console.log("Buzz");
else
console.log(i);
@duncanbeevers
duncanbeevers / sc-dl-min.js
Created March 22, 2012 12:16 — forked from pheuter/sc-dl.js
Bookmarklet that generates download link for a Soundcloud upload
(function(window){var i,$sound,$buttonGroup;var $sounds=$(".sound");var clientId=require("config").get("client_id");var oauthToken=require("lib/connect").getAuthToken();var conversionHelper=require("lib/helpers/conversion-helper");var $downloadButton,size;var params,downloadUrl,onSuccess;for(i=$sounds.length-1;i>=0;i--){$sound=$($sounds[i]);var soundcloudUrl="https://soundcloud.com"+($sound.find(".soundTitle__title").attr("href")||window.location.pathname);params={url:soundcloudUrl,client_id:clientId};onSuccess=function($sound){return function(data){var params={client_id:clientId};downloadUrl=require("lib/url").stringify({query:params},data.stream_url+".mp3");$buttonGroup=$($sound.find(".sound__soundActions .sc-button-group")[0]);size=$buttonGroup.find(".sc-button:first")[0].className.match(/sc-button-((?:small)|(?:medium))/)[1];$downloadButton=$('<a class="sc-button sc-button-download sc-button-icon sc-button-responsive">Download</a>').attr({title:"Download this sound ("+conversionHelper.bytesToMB(data.origi
@RickKimball
RickKimball / diskio.h
Created April 7, 2012 04:29
msp430 Petit FatFile System sample
/*-----------------------------------------------------------------------
/ PFF - Low level disk interface modlue include file (C)ChaN, 2009
/-----------------------------------------------------------------------*/
#ifndef _DISKIO
#include "integer.h"
/* Status of Disk Functions */
typedef BYTE DSTATUS;
@andypiper
andypiper / nuget.sh
Created May 8, 2012 16:18
nuget for OS X
#!/bin/sh
# add a simple 'nuget' command to Mac OS X under Mono
# get NuGet.exe binary from http://nuget.codeplex.com/releases/view/58939
# get Microsoft.Build.dll from a Windows .NET 4.0 installation
# copy to /usr/local/bin and Robert is your father's brother....
#
PATH=/usr/local/bin:$PATH
mono --runtime=v4.0 /usr/local/bin/NuGet.exe $*