Skip to content

Instantly share code, notes, and snippets.

Demeter / gist:0e4afbebd84d3fe7062b6a6de5aa05fc
Created May 7, 2021 — forked from spudbean/gist:1558257
Look of disapproval and other emoticons
View gist:0e4afbebd84d3fe7062b6a6de5aa05fc
( ͡° ͜ʖ ͡°)
(╯°□°)╯︵ ┻━┻
Unicode Emoticons

Keybase proof

I hereby claim:

  • I am demeter on github.
  • I am ellie ( on keybase.
  • I have a public key whose fingerprint is F845 257D 4679 6465 3815 FFF6 9117 83FB 4845 E4DD

To claim this, I am signing this object:

Demeter / textWidth.js
Created Feb 3, 2014 — forked from gka/textWidth.js
Approximating the width of a string in JavaScript
View textWidth.js
var textWidth = (function() {
function charW(w, c) {
if (c == 'W' || c == 'M') w += 15;
else if (c == 'w' || c == 'm') w += 12;
else if (c == 'I' || c == 'i' || c == 'l' || c == 't' || c == 'f') w += 4;
else if (c == 'r') w += 8;
else if (c == c.toUpperCase()) w += 12;
else w += 10;
return w;
Demeter /
Last active Jan 3, 2016 — forked from thePastor/
Mark wrote this
#Given a list of items, each with a floating-point number representing popularity, bounded
#at the bottom at zero (no negative values), pick an item based on the weight of that popularity.
#NOTE: A variant of this is used in the Network flow class in pangaia. <github/Social-Garden>\
#This was originally developed for genetic algorithms and the program called GA-SOLVE written in Pascal in 1992
# Zero-weighted values are given a value equal to *half* the lowest value.
from random import *
cityrank = {"Denver": 0.5, "Chicago": 1.0, "Houston": 0.0, "NYC": 2.9}
Demeter / Sidewiki syntax
Created Jan 19, 2014
Maybe this will be allowed by Google+ eventually
View Sidewiki syntax
<p>Sidewiki supported the following HTML tags within entries:</p><br>
<p>Font formatting</p>
<li>b <code> <b>Bold text</b></code> </li>
<li>em <code<em>Emphasize your text</em></code></li>
<li>i <code><i>Italicize your text</i></code></li>
<li>strike <code><strike>Strike out text</strike></code></li>
<li>strong <code><strong>strong font</strong></code></li>
<li>sup <code>Go <sup>superscript</sup></code></li>
# Comments, I've made a few. But then again, too few to mention.
import glob, os, re, sys
assert len(sys.argv) > 1, 'Usage: python %s <file pattern>' % sys.argv[0]
files = [fn for fn in glob.glob(sys.argv[1]) if not os.path.isdir(fn)]
matches = {fn:'repeats(\d+)', fn) for fn in files}
corpus = [(, file(fn, 'rb').read()) for fn, m in matches.items() if m]
assert corpus, r'No files matching "repeats(\d+)"'
View gist:6558823
From 273f56bd6c23bea5ca910af689aa44d4ca56cb7b Mon Sep 17 00:00:00 2001
From: Jeremy Kemper <>
Date: Fri, 27 Feb 2009 14:13:32 -0800
Subject: [PATCH 1/4] Rather than check socket.closed? on every read/write, connect once and reconnect on exceptions
lib/redis.rb | 45 ++++++++++++++++++++++++---------------------
1 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/lib/redis.rb b/lib/redis.rb
View shorturls.txt
# Got hit by this crazy bug in python
result = urlfetch.fetch('http://domain/image.jpg')
multipart_upload_body = "multi part %s upload string" % result.content
# This caused an invalid ascii error since result.content is binary and python wanted to convert it to ascii.
# The solution was not obvious, the only way we found to do it was to create a byte array then write to it like a buffer
buffer = array.array("B") # B = unsigned bytes
buffer.fromstring("multi part ")
View Herfindahl–Hirschman_Index.R
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("plyr", "ggplot2")
if(doInstall){install.packages(toInstall, repos = "")}
lapply(toInstall, library, character.only = TRUE)
ANES <- read.csv("")
ANES$PID3 <- factor(ANES$pid7) # Convert to three-level Party ID:
levels(ANES$PID3) <- c("Dem", "Dem", "Dem", "Ind", "Rep", "Rep", "Rep")