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
| {-# LANGUAGE ScopedTypeVariables #-} | |
| module BST where | |
| import Test.QuickCheck | |
| import Control.Monad | |
| import Control.Applicative | |
| data BST a = Empty | |
| | Node {value :: a, left :: BST a, right :: BST a} |
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 Control.Monad.ST | |
| import Control.Monad | |
| import Data.Array | |
| import Data.Array.ST | |
| import Data.List (elemIndex) | |
| import Data.Maybe (fromMaybe) | |
| newSTArray :: (Ix i) => (i,i) -> e -> ST s (STArray s i e) | |
| newSTArray = newArray |
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 factors(n): | |
| app = [n] if n != 1 else [] | |
| ans = set(chain(app, *((i, n//i) for i in range(2, int(sqrt(n) + 1)) | |
| if not n % i))) | |
| return ans |
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
| vows = require 'vows' | |
| assert = require 'assert' | |
| phantom = require '../phantom' | |
| describe = (name, bat) -> vows.describe(name).addBatch(bat).export(module) | |
| # Make coffeescript not return anything | |
| # This is needed because vows topics do different things if you have a return value | |
| t = (fn) -> | |
| -> |
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 Vertex: | |
| def __init__(self, idx, parent, children): | |
| self.idx = idx | |
| self.parent = parent | |
| self.children = children | |
| def rb_dist(source, graph): | |
| def init_list(): | |
| return [float('inf') for _ in graph] |
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
| BASE_URL="https://chalk.uchicago.edu/webapps" | |
| AUTH_URL="$BASE_URL/login/?action=relogin" | |
| SCRAPE_URL="$BASE_URL/blackboard/content/launchLink.jsp?course_id=_137801_1&tool_id=_139_1&tool_type=TOOL&mode=view&mode=reset" | |
| # Log in to the server. This can be done only once. | |
| wget --keep-session-cookies --save-cookies cookies.txt --post-data 'user_id=$1&password=$2' $AUTH_URL | |
| # Now grab the page or pages we care about. | |
| wget --load-cookies cookies.txt -m $SCRAPE_URL |
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 logging | |
| LOG = logging.getLogger(__name__) | |
| LOG.setLevel("DEBUG") | |
| LOG.warning("foo") | |
| LOG.debug("bar") |
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
| datatype type_node | |
| = Param of TyParam.t | |
| | LongId of LongTyId.t * tyargs_t option | |
| | Record of field_t list | |
| | Tuple of type_t list | |
| | Fun of type_t list * type_t list option * type_t list | |
| | Any | |
| | VProc | |
| | Cont of tyargs_t option | |
| | Addr of type_t |
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 static Calendar startCalendarFromFilename(String bookPath) { | |
| // format is YYYYMMDD | |
| String datePattern = "\\D+(\\d{4})(\\d{2})(\\d{2})\\.csv\\.gz"; | |
| Pattern dateRe = Pattern.compile(datePattern); | |
| Matcher matcher = dateRe.matcher(bookPath); | |
| Calendar startDate; | |
| if (matcher.groupCount() == 3) { | |
| System.out.println("Got match on:" + matcher.toString()); | |
| System.out.println("Group 0:" + matcher.group(0)); |
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
| (23): { | |
| [ 81400000, 400, | |
| 80620000, 25, | |
| 80500000, 50, | |
| 79800000, 200, | |
| 76510000, 100, | |
| 75000000, 100, | |
| 72600000, 100, | |
| 72520000, 5, | |
| 72000000, 25, |