This file contains 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 f(s: String) = { | |
val xs = s.split("\n").map(_.split(",")) | |
val ys = xs.transpose.map(_.map(_.length).max) | |
val zs = xs.map(_.zip(ys)) | |
val ls = zs.map(_.map { case (x,y) => x.padTo(y, ' ') }.mkString(" ")) | |
ls.mkString("\n") | |
} | |
val s = """aaa,b,cc | |
|a,bbbbb,c""".stripMargin |
This file contains 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
val xs = List(1, 2, 3) | |
xs.??? => List(4, 5, 6) | |
xs.??? => List(1, -1, 2, -2, 3, -3) |
This file contains 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
var counter = 0 | |
var rdd = sc.parallelize(data) | |
rdd.foreach(x => counter += x) |
This file contains 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
scratch=# create table pairs (name varchar(5), value integer); | |
CREATE TABLE | |
scratch=# insert into pairs values ('a', 1); | |
INSERT 0 1 | |
scratch=# insert into pairs values ('a', 1); | |
INSERT 0 1 | |
scratch=# insert into pairs values ('a', 1); | |
INSERT 0 1 | |
scratch=# insert into pairs values ('a', 11); | |
INSERT 0 1 |
This file contains 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
for JAR in $(ls *.jar); do echo $JAR; jar -tf $JAR | ack 'org.joda.time.DateTime' ; done; |
This file contains 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 'restclient' | |
# Create the list from the course page by running the following JavaScript | |
# snippet, and copying and paste the results in here. I _think_ the Content-Type | |
# of the pdfs prevents them from being downloaded directly in JavaScript. | |
# $('.course-lectures-list ul:eq(2) a[href$="pdf"]').map(function () { return $(this).attr('href') }) | |
urls = ["https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Flecture3.pdf", | |
"https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Ffunctions.pdf", |
This file contains 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
javascript:(function%20()%20{%20var%20$%20=%20document.createElement('script');%20$.src%20=%20'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';%20$.type%20=%20'text/javascript';%20document.getElementsByTagName('head')[0].appendChild($);%20var%20_%20=%20document.createElement('script');%20_.src%20=%20'http://documentcloud.github.com/underscore/underscore-min.js';%20_.type%20=%20'text/javascript';%20document.getElementsByTagName('head')[0].appendChild(_);%20})() |
This file contains 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
#!/bin/bash | |
# | |
# This script serves as a useful base for generating a list of ignore-dirs | |
# for ack. | |
# It's slow to run (e.g. 30 sec on a 3000 file project on a 2010 MBA) | |
# and emits no output until complete. | |
# | |
# create the list of dirs tracked by git |
This file contains 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
data Tree a = Empty | Branch a (Tree a) (Tree a) deriving (Show, Eq) | |
breadthFirst :: (a -> b) -> Tree a -> [b] | |
breadthFirst f Empty = [] | |
breadthFirst f t = breadthFirst' f ([], [t]) | |
breadthFirst' :: (a -> b) -> ([b], [Tree a]) -> [b] | |
breadthFirst' f (bs, []) = bs | |
breadthFirst' f (bs, as) = bs ++ breadthFirst' f (bsForAs, nextAs) | |
where (bsForAs, nextAs) = breadthFirst'' f as |
This file contains 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 ruby | |
STD_IMG_REF = '/Users/paulcarey/.std_desktop_image.txt' | |
IMG_SRC = '/Users/paulcarey/dev/images/ir_black_bg.png' | |
def current_img | |
cmd = "defaults read com.apple.Desktop Background | grep ImageFilePath | tail -n 2 | head -n 1" | |
res = `#{cmd}` | |
res = res.split('=')[1].strip | |
res[1, res.size - 3] |
NewerOlder