Skip to content

Instantly share code, notes, and snippets.

View emckean's full-sized avatar
💭
have I told you about Wordnik?

Erin McKean emckean

💭
have I told you about Wordnik?
View GitHub Profile
# syllables.py
# ------------
# get cmu_dict_file from http://webdocs.cs.ualberta.ca/~kondrak/cmudict.html
from collections import defaultdict
PHONEMES = set(['AA', 'AH', 'AW', 'B', 'D', 'EH', 'EY', 'G', 'IH', 'JH', 'L', 'N', 'OW' , 'P', 'S', 'T', 'UH', 'V', 'Y', 'ZH', 'AE', 'AO', 'AY', 'CH', 'DH' , 'ER', 'F', 'HH', 'IY', 'K', 'M', 'NG', 'OY', 'R', 'SH', 'TH' , 'UW', 'W', 'Z'])
VOWEL_PHONEMES = set(['AA', 'AH', 'AW', 'EH', 'ER', 'EY', 'IH', 'OW' , 'UH', 'AE', 'AO', 'AY', 'IY', 'OY', 'UW'])
@negatendo
negatendo / everyword-2014.txt
Created June 7, 2014 23:28
everyword 2014 corpus
This file has been truncated, but you can view the full file.
étui
études
étude
étagères
étagère
épées
épée
émigrés
émigré
élan
def fragmention(self, bookmark):
# Normalize whitespace and encode text as UTF8
text = ' '.join(self.text.split()).encode('utf-8')
url_parts = urlparse(bookmark.url)
# If the URL has no path (i.e. http://google.com) add a "/" then append fragmention
formatter = '%s/##%s' if not len(url_parts.path) else '%s##%s'
fragmention_url = formatter % (url_parts.geturl(), urllib.quote_plus(text))
@ftrain
ftrain / rhymes.clj
Last active July 14, 2023 22:20
Annotated rhyming dictionary
;; This is at: https://gist.github.com/8655399
;; So we want a rhyming dictionary in Clojure. Jack Rusher put up
;; this code here:
;;
;; https://gist.github.com/jackrusher/8640437
;;
;; I'm going to study this code and learn as I go.
;;
;; First I put it in a namespace.
@casualjim
casualjim / scala-interview1.scala
Created May 1, 2013 19:55 — forked from oxbowlakes/scala-interview1.scala
simple exercise around map and flatmap
object GOption {
def some[A](a: A): GOption[A] = new GOption[A] {
def cata[B](n: => B, s: A => B): B = sys.error("Implement me")
}
def none[A]: GOption[A] = new GOption[A] {
def cata[B](n: => B, s: A => B): B = sys.error("Implement me")
}
}
trait GOption[+A] {
@mweibel
mweibel / passport-mock.js
Last active May 14, 2024 09:32
Mock passport.js with an own strategy
/**
* Author: Michael Weibel <[email protected]>
* License: MIT
*/
var passport = require('passport')
, StrategyMock = require('./strategy-mock');
module.exports = function(app, options) {
// create your verify function on your own -- should do similar things as
@selenamarie
selenamarie / a_better_opml.py
Last active December 11, 2015 09:59
This grabs URLs associated with the people you follow on Twitter and then tries to scrape RSS feeds from the URLs. You have to get OAUTH creds from dev.twitter.com/apps to do this, and then register the script so that you get the access_token + access_token_secret. Rev 2 actually produces valid OPML. ;)
#!/usr/bin/env python
import tweepy
from BeautifulSoup import BeautifulSoup as parser
import urllib
import sys
import argparse
import ConfigParser
@stew
stew / kleisliexample.scala
Created January 16, 2013 14:07
example of kleisli in kleisli
import scalaz._
import Scalaz._
case class Person(name: String, score: Int)
object Main extends App {
type Environment = Map[String, Person]
type EnvReader[+A] = Kleisli[Option,Environment,A]
type UserReader[+A] = Kleisli[EnvReader,String,A]
@glenjamin
glenjamin / app.js
Created July 8, 2012 13:22
Express 3.0 flash messages with view helper
app.use(require('connect-flash')());
// Expose the flash function to the view layer
app.use(function(req, res, next) {
res.locals.flash = function() { return req.flash() };
next();
})
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",