Skip to content

Instantly share code, notes, and snippets.

@dfm
dfm / LICENSE
Last active September 9, 2023 23:56
XKCD-style plots in d3
Copyright (c) 2012–2013 Daniel Foreman-Mackey
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@artisonian
artisonian / .gitignore
Last active March 21, 2024 20:13
go-eventsource
eventsource
go-eventsource
client/client
@border
border / long_polling.go
Created September 25, 2012 09:58
long polling for golang
package main
import (
"container/list"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@tistaharahap
tistaharahap / gist:1202974
Created September 8, 2011 08:57
HMAC-SHA1 Utility for Android
public static String sha1(String s, String keyString) throws
UnsupportedEncodingException, NoSuchAlgorithmException,
InvalidKeyException {
SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), "HmacSHA1");
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(key);
byte[] bytes = mac.doFinal(s.getBytes("UTF-8"));
@chrisfarms
chrisfarms / basemodel.py
Created March 22, 2011 19:50
GAE base model class with to_json serialisation
SIMPLE_TYPES = (int, long, float, bool, dict, basestring, list)
class BaseModel(db.Model):
def to_json_friendly_value(self, v):
if v is None or isinstance(v, SIMPLE_TYPES):
value = v
elif isinstance(v, datetime.date):
# Convert date/datetime to ms-since-epoch ("new Date()").
ms = time.mktime(v.utctimetuple()) * 1000
@balupton
balupton / README.md
Last active April 20, 2022 13:21
Ajaxify a Website with the HTML5 History API using History.js, jQuery and ScrollTo
#!/bin/zsh
mkdir -p $HOME/Library/LaunchAgents
dir="$HOME/Library/Watchpics"
beep="/System/Library/PrivateFrameworks/ScreenReader.framework/Versions/A/Resources/Sounds/Ellipsis.aiff"
cat > $HOME/Library/LaunchAgents/watchpics.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>