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
PREFIX='http://mediastream2.brown.edu/media/_definst_/vreserves/harrison_ampa2610/mp4:' | |
for i in `seq 1 36` | |
do | |
file=`curl http://brown.edu/cis/sta/dev/harrison_ampa2610/lecture_$i.html | grep mp4 | awk '{print substr($2, 2, length($2)-3)}'`; | |
ffmpeg -i $PREFIX$file/playlist.m3u8 -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $file | |
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
import gevent | |
from gevent import monkey | |
monkey.patch_all() | |
from bs4 import BeautifulSoup | |
from urllib2 import urlopen | |
from os import mkdir, path | |
BASE = 'http://math.nyu.edu/faculty/varadhan' | |
def mkpath(url): |
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
from collections import defaultdict | |
tweets = open('tweets.txt.aa').read().lower().split() | |
target = open('tweets.txt.ab').read().lower().split() | |
#Mapping from term to number of tweets | |
doc_ctr = defaultdict(int) | |
for tweet in tweets: | |
for word in set(tweet.split()): |
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
package autocorrect | |
import scala.collection.mutable.Map | |
import scala.collection.mutable.ArrayBuffer | |
class BKTree(val str: String) { | |
var children: Map[Int, BKTree] = Map[Int, BKTree]() | |
def add(word: String): Unit = { | |
val dist = Utils.levenshtein(str, word) | |
if (children contains dist) children(dist) add word |
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
package com.vivekn.bktree | |
import scala.collection.mutable.ArrayBuffer | |
import scala.collection.mutable.Map | |
class BKTreeNode(str: String) { | |
var children: Map[Int, BKTreeNode] = Map[Int, BKTreeNode]() | |
def add(word: String) : Unit = { | |
val dist = WordUtils.levenshtein(str, word) |
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
import java.util.HashMap | |
import scala.collection.mutable.Set | |
object Solution { | |
class Node (var isTerm: Boolean = false) { | |
var children: HashMap[String, Array[Node]] = new HashMap[String, Array[Node]]() | |
} | |
def splitTokens(regex: String) : (String, String, Char) = { |
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
svn sw $1 | |
lines=`svn merge --accept postpone $2|grep -y "conflict"|wc -l` | |
if [ lines -eq 0 ] | |
then | |
svn ci -m "Merged Trunk" | |
svn sw $1 | |
svn up | |
lines2=`svn merge --reintegrate $2|grep -y "conflict"|wc -l` | |
if [ lines2 -eq 0 ] | |
then |
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
sudo touch /usr/local/bin/$1 | |
sudo vim /usr/local/bin/$1 | |
sudo chmod +x /usr/local/bin/$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
from math import sqrt, log, pi | |
from random import random | |
import numpy as np | |
def build_st_ism(frames, r, s): | |
nframes = len(frames) | |
M, N = frames[0].shape | |
patches = map(ism, get_patches(frames, r, s)) | |
spatial_ism = stitch_space(patches, nframes, M, N, r, s) | |
slices = map(ism, get_slices(frames)) |
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 permg(seq): | |
""" | |
Returns a generator of permutations for a sequence. | |
""" | |
if len(seq) <= 1: | |
yield seq | |
else: | |
for perm in permg(seq[1:]): | |
for i in range(len(seq)): | |
yield perm[:i] + seq[0:1] + perm[i:] |
NewerOlder