Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 operator | |
import requests | |
from bs4 import BeautifulSoup | |
def get_data_for_category(soup, data_category_id): | |
output_data = {} | |
data_rows = soup.find_all("div", attrs={"data-category-id": data_category_id})[0] | |
for row in data_rows.find_all("div", "ProgressBar-textWrapper"): |
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/python | |
# | |
# This script is an improved version of the 'qstat' command | |
# that prints out only USEFUL information (like the job's | |
# FULL name) in a readable way. | |
# | |
# All of the output of the command 'qstat -f' is captured | |
# and organized, so it would be very easy to print out | |
# additional info by modifying the last loop of the script. | |
# |
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 random | |
#number of games to play | |
n = 5 | |
#number of correct guesses on first guess | |
correct = 0 | |
# run simulations | |
for i in range(n): | |
print 'cycle %i' % i |
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
"""Genetic Algorithmn Implementation | |
see: | |
http://www.obitko.com/tutorials/genetic-algorithms/ga-basic-description.php | |
""" | |
import random | |
class GeneticAlgorithm(object): | |
def __init__(self, genetics): | |
self.genetics = genetics | |
pass |
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
"""Scrapes interviews from the blog 'the chrome ball incident' for text analysis.""" | |
import urllib | |
import string | |
from bs4 import BeautifulSoup | |
# url of first page of interviews | |
url = 'http://chromeballincident.blogspot.com/search/label/chrome%20ball%20interview' | |
interviews = 0 |
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 urllib | |
from datetime import timedelta | |
from operator import itemgetter | |
import csv | |
from bs4 import BeautifulSoup | |
# function that does stuff | |
def match_stats(last_page=2, out_file='out.csv', info=False): | |
""" gets match statistics from oc.tc/matches pages | |
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
(* This function removes an {x,y} point if the point does not | |
have a unique x value from a list {{x1,y1},{x2,y2},...} *) | |
removeDupX[l_] := ( | |
nl = l; | |
length = Length[l]; | |
xs = l[[All, 1]]; | |
For[i = 1, i <= length, i++, | |
If[Count[nl[[All, 1]], xs[[i]]] > 1, | |
nl = Delete[nl, i]; | |
xs = Delete[xs, i]; |
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
En[n_, a_, V_] := | |
Assuming[a \[Element] Reals && | |
a > 0, (1/8)*Integrate[D[n, x]^2/n, {x, -Infinity, Infinity}] + | |
Integrate[V*n, {x, -Infinity, Infinity}]] | |
V[x_, k_] := (1/2)*k*x^2 | |
\[Psi][x_, a_] := (1/Sqrt[2*Pi*a])*Exp[-x^2/(2*a)] | |
Enf = En[\[Psi][x, a]^2, a, V[x, k]] | |
Solve[D[Enf, a] == 0, a] |
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
(* Numerical Schemes *) | |
(* Regular Euler Method *) | |
euler[y0_, npoints_, a_, b_, f_] := ( | |
h = (b - a)/(npoints - 1); | |
y = Table[0, {npoints}]; | |
t = Table[0, {npoints}]; | |
y[[1]] = y0; | |
t[[1]] = a; | |
Do[ | |
yn = y[[n]]; |
NewerOlder