Skip to content

Instantly share code, notes, and snippets.

def include_script(browser, path):
with open(path, 'r') as f:
script = f.read()
browser.execute_script(script)
def sizzle_path():
import djungle.sizzle
return os.path.join(os.path.dirname(djungle.sizzle.__file__),
'static', 'djungle', 'sizzle.js')
from collections import namedtuple
import decorator
@decorator.decorator
def continuate(gen, *args, **kwargs):
it = gen(*args, **kwargs)
def continuation():
try:
@chris-martin
chris-martin / _.md
Last active August 29, 2015 14:02
Scala for Java Programmers: A profane tutorial

There are other such tutorials, but I find that they don't hurl enough angry insults at Java. So I'm writing one that contains a sufficient amount of fury. We're going to introduce Scala concepts alongside their fucking stupid Java counterparts.

A trivial file

Scala

Java

$ tree
.
├── project
│   ├── project
│   │   ├── project
│   │   │   ├── project
│   │   │   │   ├── project
│   │   │   │   │   ├── project
│   │   │   │   │   │   ├── project
│   │   │   │   │   │   │   ├── project
import math
import pygame
from pygame import draw
import sys
import time
pygame.init()
size = width, height = 500, 200
screen = pygame.display.set_mode(size)
>>> a = ['1', '2', '3', '4', '5', '6', '7']
>>> [' '.join(a[i:i+2]) for i in xrange(0, len(a), 2)]
['1 2', '3 4', '5 6', '7']
1 1
22 22
333 333
4444 4444
55555 55555
666666 666666
7777777 7777777
88888888 88888888
999999999999999999
999999999999999999