Skip to content

Instantly share code, notes, and snippets.

View emres's full-sized avatar
💭
"The purpose of computing is insight, not numbers." -- Richard W. Hamming

Emre Sevinç emres

💭
"The purpose of computing is insight, not numbers." -- Richard W. Hamming
View GitHub Profile
# Author: Jacob Kristhammar, 2010
#
# Updated version of websocket.py[1] that implements latest[2] stable version
# of the websocket protocol.
#
# NB. It's no longer possible to manually select which callback that should
# be invoked upon message reception. Instead you must override the
# on_message(message) method to handle incoming messsages.
# This also means that you don't have to explicitly invoke
# receive_message, in fact you shouldn't.
@j4mie
j4mie / normalise.py
Created August 30, 2010 12:44
Normalise (normalize) unicode data in Python to remove umlauts, accents etc.
# -*- coding: utf-8 -*-
import unicodedata
""" Normalise (normalize) unicode data in Python to remove umlauts, accents etc. """
data = u'naïve café'
normal = unicodedata.normalize('NFKD', data).encode('ASCII', 'ignore')
print normal
@razie
razie / scala-profiles.markdown
Created September 24, 2010 15:35
Scala abuses

Scala is a wonderful language, with a specification of a size comparable with that of Java. Overall, the specification is simpler than C++. Why then do some feel intimidated by its expressiveness?

Scala can generate complex constructs. There are some features of the language that, if not used properly, can negatively influence one's perception of its simplicity and generate a waste of many an hour of a frustrated developer.

Newcomers from simply typed, object-oriented, structured languages do not have a full grasp of all the features of scala and their effects or benefits, and they may be very surprised if others on their team use them.

One thing to have when starting or using scala is a readily available bible. I recommend "Programming in Scala", the .pdf version, an easily searcheable language reference.

The scala style guide is very good. Here we will describe the advanced features of the language, which are aimed at library-developers and should not b

@tlrobinson
tlrobinson / google-translate-drums.js
Created November 30, 2010 06:19
A drum machine for the German Google Translate. See instructions in comments below.
(function() {
// Notes from http://news.ycombinator.com/item?id=1952531
var notes = {
"suspended cymbal":"zk",
"snare":"bschk",
"brush":"pv",
"bass":"bk",
"flam1":"tk",
"roll tap":"vk",
"flam2":"kt",
@wrwills
wrwills / LensTest.scala
Created November 30, 2010 13:47
playing with some of the ideas from the Haskell fclabels library using the new Lens functionality in scalaz
import scalaz._
/**
* playing with some of the ideas from the Haskell fclabels library
* using the new Lens functionality in scalaz
*
* http://hackage.haskell.org/package/fclabels
*/
object LensTest {
@qnighy
qnighy / PriorityQueue.scala
Created December 28, 2010 11:15
Immutable PriorityQueue in Scala
// Immutable PriorityQueue in Scala
// Most functions run in O(log n)
// Developed in Scala version 2.7.7
// Implementation: Leftist Heap (See "Purely Functional Data Structures")
// Author: Masaki Hara (ackie.h.gmai _at_ gmail.com)
package scala.collection.immutable
import priorityqueue._
@oxbowlakes
oxbowlakes / 3nightclubs.scala
Created May 13, 2011 15:14
A Tale of 3 Nightclubs
/**
* Part Zero : 10:15 Saturday Night
*
* (In which we will see how to let the type system help you handle failure)...
*
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0)
*/
import scalaz._
import Scalaz._
@etorreborre
etorreborre / gist:1387113
Created November 22, 2011 21:50
An example of a non-terminating compilation with javac
/** from http://www.reddit.com/r/programming/comments/mlbna/scala_feels_like_ejb_2/c31z0co */
interface Pong<T> {}
class Ping<T> implements Pong<Pong<? super Ping<Ping<T>>>> {
static void Ping() {
Pong<? super Ping<Long>> Ping = new Ping<Long>();
}
}
> javac Ping.java
@voidfiles
voidfiles / textrank.py
Created January 20, 2012 08:22
An implmentation of TextRank in python
"""
From this paper: http://acl.ldc.upenn.edu/acl2004/emnlp/pdf/Mihalcea.pdf
I used python with nltk, and pygraph to do an implmentation of of textrank.
for questions: http://twitter.com/voidfiles
"""
import nltk
import itertools
@osa1
osa1 / gist:1861099
Created February 18, 2012 21:46
Utils for PRINTing and READing CL standard hash-tables, inspired by Haskell's fromList
(in-package :cl-user)
(defpackage :m-utils
(:use :cl)
(:export :from-list :print-ht))
(in-package m-utils)
(defmacro from-list (list &rest params)
"A hash-table generator inspired by Haskell's fromList."