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 csv | |
| import datetime | |
| import time | |
| import pprint | |
| import itertools | |
| def get_data(): | |
| f = open('DATA_1334.csv') |
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
| CHARS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' | |
| MAX_RADIX = len(CHARS) | |
| class Bignum: | |
| def __init__(self, digits, radix=10): | |
| # set self.radix | |
| if radix < MAX_RADIX: | |
| self.radix = radix | |
| else: |
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
| <html> | |
| <head> | |
| <title>Diff</title> | |
| <style type="text/css" media="screen"> | |
| ins { | |
| background-color: lightgreen; | |
| text-decoration: none; | |
| } | |
| del { | |
| background-color: pink; |
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 Board { | |
| def init(values) { | |
| @values = values | |
| } | |
| def poss(r,c) { | |
| (((1 to 9).toSet - self.taken_in_col(c)) - self.taken_in_row(r)) - self.taken_in_box(r,c) | |
| } | |
| def taken_in_col(c) { | |
| taken = new Set | |
| for row in 0 to 8 { |
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
| @SuppressWarnings("unchecked") | |
| public class BST extends BinaryTree { | |
| @Override | |
| public Comparable find(Comparable key) { | |
| return findNode(key).getValue(); | |
| } | |
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
| # loosely based on Rails' excerpt helper | |
| # http://rails.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M001713 | |
| # TODO: don't break in the middle of words | |
| def excerpts(text, word, options={}) | |
| omission = options[:omission] || '...' | |
| radius = options[:radius] || 5 | |
| word.class == String ? re = /(#{Regexp.escape(word)})/ : re = word | |
| return nil unless text =~ re | |
| ans = ""; start = 0; last_range = -2..-1 |
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
| CmdUtils.CreateCommand({ | |
| name: "gcal", | |
| takes: {"expression" noun_arb_text}, | |
| description: "Uses Google Calculator to evaluate an expression", | |
| icon: "http://www.google.com/favicon.ico/", | |
| homepage: "http://davanum.wordpress.com/", | |
| author: { name: "Davanum Srinivas", email: "davanum AT gmail.com"}, | |
| help: "Try it out: issue "calc 22/7 - 1".", | |
| preview: function(pblock, statusText) { |
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
| conversions = [ | |
| # length | |
| ('inches','feet',lambda x: x/12.0), | |
| ('feet','inches',lambda x: x*12), | |
| ('meters','feet',lambda x: x*3.2808399), | |
| ('feet','meters',lambda x: x*0.3048), | |
| ('inches','centimeters',lambda x: x*2.54), | |
| ('meters','centimeters',lambda x: x*100), | |
| ('centimeters','meters',lambda x: x/100), | |
| # stoichiometry |
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
| function cmd_strikethrough() { | |
| var doc = context.focusedWindow.document; | |
| if (doc.designMode == "on") | |
| doc.execCommand("strikethrough", false, null); | |
| else | |
| displayMessage("You're not in a rich text editing field."); | |
| } | |
| cmd_italic.description = "If you're in a rich-text-edit area, strikes through the selected text."; |
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 random | |
| alphabet = 'abcdefghijklmnopqrstuvwxyz ' | |
| def random_letter(): | |
| return alphabet[random.randint(0,len(alphabet)-1)] | |
| def random_string(length): | |
| return ''.join([random_letter() for i in range(length)]) | |