This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# http://www.elasticsearch.org/guide/reference/modules/scripting/ | |
# | |
# Create the index | |
curl -XPOST 'http://localhost:9200/people/' -d '{ | |
"settings" : { | |
}, | |
"mappings" : { | |
"person" : { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Readability | |
[Wiki](http://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_test) | |
The Flesch Reading Ease Score (FRES) is | |
206.835 - 1.015 * (#words / #sentences) - 84.6 * (#syllables / #words) | |
Example: | |
"The Australian platypus is seemingly a hybrid of a mammal and reptilian | |
creature." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
import itertools | |
import math | |
import pprint | |
import random | |
import sys | |
INF = float('inf') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Prints the probability of a successful shot given argv[1] attempts where | |
each has an argv[2] probability of success. | |
""" | |
from __future__ import division | |
import random | |
import sys | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
import json | |
import random | |
import sys | |
names = list(set(sys.argv[1:])) | |
print 'There are %d players: %s' % (len(names), ', '.join(sorted(names))) | |
raw_input('Continue?') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collection.mutable | |
case class Pair[A, B](key: A, value: B) | |
class HMap[K, V](numBuckets: Int) { | |
val buckets = Seq.fill(numBuckets)(mutable.ListBuffer.empty[Pair[K, V]]) | |
def get(k: K): Option[V] = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nodes": [ | |
{"player": "Andy", "rating": 1640}, | |
{"player": "Bob", "rating": 1570}, | |
{"player": "Carmen", "rating": 1590} | |
], | |
"edges": [ | |
{"p1": "Bob", "p2": "Andy", "difference": 50}, | |
{"p1": "Carmen", "p2": "Bob", "difference": 20}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.2 | |
from concurrent.futures import ThreadPoolExecutor | |
from itertools import chain | |
import time | |
import requests | |
def ngrams(tokens, n): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player(models.Model): | |
name = models.CharField(primary_key=True, max_length=50) | |
date_added = models.DateTimeField('date added', default=datetime.now()) | |
rating = models.IntegerField(default=1600) | |
@property | |
def wins(self): | |
return self.winner_games.all() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node(object): | |
def __init__(self, data): | |
self.data = data | |
self.next_node = None | |
def __repr__(self): | |
return self.data | |
class List(object): | |
""" |