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
function getPalindromes(s) { | |
/* get all palindromes of the string s */ | |
var results = []; | |
for (var i = 0; i < s.length; i++) { | |
var start, end; | |
start = end = i; | |
//check 'odd' palindromes | |
while ( 0 <= start && end < s.length && s[start] == s[end] ) { | |
results.push(s.substring(start, end + 1)); | |
start--; |
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
function powerset(input) { | |
var result = []; | |
var selections; // bitmap of current subset | |
for(selections = 0; selections < Math.pow(2, input.length); selections++) { | |
var subset = []; | |
var index; // index into bitmap we're looking for | |
for(index = 0; index < input.length; index++) { | |
if(selections & (1 << index)) { | |
subset.push(input[index]); | |
} |
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 all_subsets_rec(left, so_far, accum): | |
if len(left) == 0: | |
accum.append(so_far) | |
else: | |
# find subsets that include first item of left | |
all_subsets_rec(left[1:], [left[0]] + so_far, accum) | |
# find subsets that do NOT include first item of left | |
all_subsets_rec(left[1:], so_far, accum) | |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
my_g_plot <- function(g, id, transform=FALSE) { | |
# get coords in mercator proj | |
png(paste("plots/plot", id, ".png", sep=""), | |
type="cairo-png", | |
width=1000, height=1000) | |
if(transform) { | |
vec_df <- get.data.frame(g, what="vertices") | |
xy <- vec_df[,c("X", "Y")] | |
coordinates(xy) <- ~X+Y | |
proj4string(xy) <- CRS("+proj=longlat +ellps=WGS84") |
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 lxml import etree | |
import urllib2 | |
import urlparse | |
import sys | |
# Prevents this script from failing when output is piped | |
# to another process | |
from signal import signal, SIGPIPE, SIG_DFL | |
signal(SIGPIPE,SIG_DFL) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 XMonad | |
import XMonad.Hooks.DynamicLog | |
import XMonad.Hooks.ManageDocks | |
import XMonad.Util.Run(spawnPipe) | |
import XMonad.Util.EZConfig(additionalKeys) | |
import System.IO | |
myManageHook = composeAll | |
[ ] |