Skip to content

Instantly share code, notes, and snippets.

View softprops's full-sized avatar
®️
Rustling

Doug Tangren softprops

®️
Rustling
View GitHub Profile
function createWebSocket () {
var connection = new WebSocket();
var attempts = 1;
connection.onopen = function () {
// reset the tries back to 1 since we have a new connection opened.
attempts = 1;
// ...Your app's logic...
}
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially
@softprops
softprops / LICENSE.txt
Created June 26, 2011 02:27 — forked from 140bytes/LICENSE.txt
foldl
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
# Creative Commons Attribution-Share Alike 3.0 United States License
# http://creativecommons.org/licenses/by-sa/3.0/us/
# By Susan Potter <http://geek.susanpotter.net>
(($) ->
editSubmitHandler: (evt) ->
form: $(this)
data: form.serialize()
url: form.attr('action')
$.getJSON(url, data, (data, resp) ->
$('#notice').html(data['html'])
jQuery.fn.noisy = function(opacity) {
if (typeof(opacity) === 'undefined') {
opacity = 0.1;
}
var wrapper = jQuery(this).wrapInner('<div />').children();
var canvas = document.createElement("canvas");
canvas.width = 100;
canvas.height = 100;
var ctx = canvas.getContext("2d");
@softprops
softprops / gist:818081
Created February 9, 2011 07:06 — forked from r/gist:267244
function xmlcurl {
curl -s $1 | tidy -xml -i -w 0 -q
}
YAHOO_API_ENDPOINT="http://where.yahooapis.com/v1"
# get this APP_ID from http://developer.yahoo.com/geo/geoplanet/
YAHOO_APP_ID=FILL YOUR APP ID HERE
# lookup a string and find a matching WOEID
function woeid_search {
LOC=$(echo -n "$1" | perl -pe's/([^-_.~A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg');
#!/usr/bin/env ruby
# The script that give you focus!
# Create a text file that contains sites want to give yourself
# access to only during certain times of day.
#
# The file will look like this:
# 12 news.ycombinator.com
# 11-13,19-21 twitter.com
#
# using rvm with ruby-1.8.7-p249
# latest version 2.7.7 2010-06-17
brew install libxml2
# installing libxslt from source code
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
tar xvfz libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.7
import scalaz._
/**
* A simple example of how applicative functors can shorten code
* adapted from chapter 8? of Real World Haskell
*/
object OptionGolf {
@softprops
softprops / browser
Created November 9, 2010 04:14 — forked from defunkt/browser
#!/bin/sh -e
#
# Usage: browser
# pipe html to a browser
# e.g.
# $ echo "<h1>hi mom!</h1>" | browser
# $ ron -5 man/rip.5.ron | browser
if [ -t 0 ]; then
if [ -n "$1" ]; then