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
| library(plyr) | |
| library(ggplot2) | |
| formatter = function(x) formatC(x, format='d', big.mark=',') | |
| # create some fake data | |
| variability = c(A=0.1, B=0.2, C=0.3) | |
| d = as.data.frame(mutate(list(), | |
| source=sample(c('A', 'B', 'C'), 1000, replace=TRUE), |
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 collections import defaultdict | |
| def splitter(l, mapper): | |
| """Partition an iterable by a callable mapper.""" | |
| results = defaultdict(list) | |
| for x in l: | |
| results[mapper(x)].append(x) |
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 itertools | |
| def offsetter(iterable, offsets=(0, 1), longest=False): | |
| """ | |
| Return offset element from an iterable. | |
| Pad offset element with None at boundaries. | |
| >>> l = range(10) | |
| >>> for prev, curr, next in offsetter(l, offsets=(-1, 0, 1), longest=True): | |
| ... print prev, curr, next |
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 insert_sort(l, inc=1): | |
| """Insert sort.""" | |
| for i, x in enumerate(l): | |
| while x < l[i - inc] and i > 0: | |
| l[i] = l[i - inc] | |
| i -= inc | |
| l[i] = x | |
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 bubble_sort(l, inc=1): | |
| """Bubble Sort.""" | |
| swapped = True | |
| while swapped: | |
| swapped = False | |
| for i in xrange(1, len(l)): | |
| if l[i - inc] > l[i] and i - inc >= 0: | |
| swapped = True | |
| l[i], l[i - inc] = l[i - inc], l[i] |
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 heapq import merge | |
| def merge_lr(left, right): | |
| """Merge left and right sequences.""" | |
| result = [] | |
| left_idx, right_idx = 0, 0 | |
| while left_idx < len(left) and right_idx < len(right): | |
| # change the direction of this comparison to change the direction of the sort |
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
| # What did Barbara get up to in Spain? | |
| # TL;DR: 11 Gelato, 68 Drinks and 36 Tapas | |
| library(XML) | |
| library(ggplot2) | |
| library(reshape2) | |
| # parse page into XML DOM document | |
| parse_doc = function (page) { |
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
| -- grant access to multiple people | |
| DECLARE | |
| usernames VARCHAR2(1024) := ' | |
| jimmy, | |
| bobby, | |
| franky, | |
| alice, | |
| mandy | |
| '; |
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
| @echo off | |
| setlocal enableextensions | |
| pushd "%~p1" | |
| set FILENAME="%~n1" | |
| echo @%FILENAME% exit; | sqlplus -l -s /nolog | |
| popd |
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
| \documentclass{article} | |
| \usepackage{datatool} | |
| \usepackage{booktabs} | |
| \usepackage{xtab} | |
| \usepackage{longtable} | |
| \DTLloaddb{scientists}{scientists.csv} | |
| \begin{document} |