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
| def digit(num, curr_dig): | |
| diff = pow(10, curr_dig - 1) | |
| num = num / diff | |
| return num % 10 | |
| def radix_sort(arr, n): | |
| buckets = [[] for x in range(0, 10)] | |
| curr_dig = 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
| def with_time_zone(tz_name) | |
| prev_tz = ENV['TZ'] | |
| ENV['TZ'] = tz_name | |
| yield | |
| ensure | |
| ENV['TZ'] = prev_tz | |
| end | |
| with_time_zone('Asia/Singapore') { Chronic.parse("this week Monday 21:00") } |
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
| { | |
| // See http://www.jshint.com/options/ for in-depth explanations | |
| // Predefined globals that JSHint ignores | |
| "browser" : true, // standard globals like 'window' | |
| "devel" : true, // development globals, e.g. 'console' | |
| "dojo" : true, // dojo toolkit globals | |
| "nonstandard" : true, // widely-adopted globals, e.g. 'escape' | |
| "predef" : [ // extra globals |
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
| -(id)initWithTerms:(NSArray*)ts{ // 5 points | |
| // REQUIRES: "ts" satisfies clauses given in the representation invariant | |
| // EFFECTS: constructs a new polynomial using "ts" as part of the representation. | |
| // the method does not make a copy of "ts". remember to call checkRep to check for representation invariant | |
| if (self = [super init]) { | |
| terms = [ts sortedArrayUsingComparator:^NSComparisonResult(id a, id b) { | |
| // RatTerm has a property expt that is an int | |
| int first = [(RatTerm*)a expt]; | |
| int second = [(RatTerm*)b expt]; | |
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
| [[37956, "Episode"], [852, "Episode"], [852, "Episode"], [832, "Episode"], [841, "Episode"], [37958, "Episode"], [845, "Episode"], [840, "Episode"], [37957, "Episode"], [839, "Episode"], [844, "Episode"], [37959, "Episode"], [3230, "Episode"], [64135, "Movie"], [849, "Episode"], [71141, "Clip"], [71141, "Clip"], [68063, "Clip"], [71137, "Clip"], [71142, "Clip"], [71142, "Clip"], [70988, "Clip"], [70988, "Clip"], [70885, "Episode"], [71242, "Episode"], [71242, "Episode"], [71242, "Episode"], [70779, "Episode"], [70779, "Episode"], [37955, "Episode"], [37956, "Episode"], [847, "Episode"], [846, "Episode"], [832, "Episode"], [843, "Episode"], [37958, "Episode"], [840, "Episode"], [37957, "Episode"], [839, "Episode"], [37959, "Episode"], [3230, "Episode"], [64135, "Movie"], [64001, "Movie"], [71178, "Clip"], [71178, "Clip"], [71141, "Clip"], [71137, "Clip"], [71137, "Clip"], [71142, "Clip"], [71142, "Clip"], [70988, "Clip"], [70885, "Episode"], [70885, "Episode"], [70885, "Episode"], [71242, "Episode"], [71242, " |
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
| //*[contains(@id, 'tools')]/*[contains(@class, 'blurb')][contains(., 'Splash')]/ul/li |
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
| require 'rubygems' | |
| require 'mysql2' | |
| require 'unsupervised-language-detection' | |
| db1 = Mysql2::Client.new(:host => 'localhost', :username =>'xxx', :password => 'xxx', :database => 'sgbeat') | |
| db2 = Mysql2::Client.new(:host => 'localhost', :username =>'xxx', :password => 'xxx', :database => 'sgb_pure') | |
| tweets = db1.query("SELECT * FROM tweets").each do |row| | |
| str = row["tweet"] | |
| puts row["id"] |
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
| /* Crude implementation of a readLine function -> used to get HTTP headers from a socket InputStream | |
| * Then you may get the rest of the binary data by just calling sock.getInputStream().read() | |
| */ | |
| public static String readLine(Socket sock) { | |
| String line = new String(); | |
| int c; | |
| try { | |
| while ((c = sock.getInputStream().read()) != '\n') { | |
| line += (char) c; |
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
| package com.stackoverflow.q2307291; | |
| import java.io.BufferedReader; | |
| import java.io.IOException; | |
| import java.io.InputStreamReader; | |
| import java.io.OutputStreamWriter; | |
| import java.io.PrintWriter; | |
| import java.net.Socket; | |
| public class Test { |
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
| public StoreAndValue eval(Store s, Environment e) { | |
| StoreAndValue s_and_v = rightHandSide.eval(s, e); | |
| int loc = s.newLocation(); | |
| // Be careful of this. It might be wrong, though it works now | |
| e.extendDestructive(leftHandSide, loc); | |
| if (s_and_v.value instanceof BoolValue) { | |
| BoolValue res = (BoolValue) s_and_v.value; | |
| s = s.extend(loc, res); |