Skip to content

Instantly share code, notes, and snippets.

@retronym
retronym / type-bounds.scala
Created December 16, 2009 11:17
Tour of Scala Type Bounds
class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x
@mblondel
mblondel / lda_gibbs.py
Last active October 9, 2023 11:31
Latent Dirichlet Allocation with Gibbs sampler
"""
(C) Mathieu Blondel - 2010
License: BSD 3 clause
Implementation of the collapsed Gibbs sampler for
Latent Dirichlet Allocation, as described in
Finding scientifc topics (Griffiths and Steyvers)
"""
@huyng
huyng / reflect.py
Created February 7, 2011 17:57
A simple echo server to inspect http web requests
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
@founddrama
founddrama / VersionComparator.groovy
Last active April 20, 2023 12:55
a version comparator (e.g., "1.0.2" < "1.0.10")
def versions = []
def f = new File('mock-version-tags.txt')
f.eachLine { versions << it }
def versionComparator = { a, b ->
def VALID_TOKENS = /._/
a = a.tokenize(VALID_TOKENS)
b = b.tokenize(VALID_TOKENS)
for (i in 0..<Math.max(a.size(), b.size())) {
case object transaction {
import java.sql.Connection
def apply[T](query: => T):Option[T] = {
val conn:Connection = play.db.DB.getConnection
val auto:Boolean = conn.getAutoCommit
try {
conn.setAutoCommit(false)
Some(query)
} catch {
@clintongormley
clintongormley / gist:1037563
Created June 21, 2011 10:06
Edge ngram example for elasticsearch
# [Tue Jun 21 12:05:39 2011] Protocol: http, Server: 192.168.5.103:9200
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"mappings" : {
"contact" : {
"properties" : {
"twitter" : {
"type" : "object",
"properties" : {
"profile" : {
@jaytaylor
jaytaylor / PlayParameterReader.scala
Created July 11, 2011 21:52
Nice ParaNameReader for the Play! Framework v.1.2.2
package PlayParameterReader
/**
* @author Jay Taylor <outtatime@gmail.com>
*
* @date 2011-05-23
*/
import scala.collection.JavaConversions._
@jaytaylor
jaytaylor / .tmux.conf
Created August 30, 2011 01:53
TMux Configuration
# Make it use C-a, similar to screen..
unbind C-b
unbind l
set -g prefix C-a
bind-key C-a last-window
# Reload key
bind r source-file ~/.tmux.conf
set -g default-terminal "screen-256color"
@jaytaylor
jaytaylor / .vimrc
Created September 20, 2011 19:14
Better Tab/Shift-Tab for block indentation
" Paste this into your .vimrc to make tab/shift-tab work on blocks of text just like in a fancy GUI IDE
map <Tab> >gb
map <S-Tab> v<gv<ESC>0I<ESC>l
imap <S-Tab> <ESC>v<gv<ESC>0I
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
@chitchcock
chitchcock / 20111011_SteveYeggeGooglePlatformRant.md
Created October 12, 2011 15:53
Stevey's Google Platforms Rant

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real