Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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"):
@bcbwilla
bcbwilla / bstat.py
Last active December 19, 2015 16:49
This script is an improved version of the PBS 'qstat' command that prints out only USEFUL job information (like the 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.
#! /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.
#
@bcbwilla
bcbwilla / monty.py
Last active December 19, 2015 08:59
Simple simulation of Monty Hall problem.
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
"""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
@bcbwilla
bcbwilla / skatescraper.py
Last active December 18, 2015 05:38
Scrapes interviews from the blog 'the chrome ball incident' (http://chromeballincident.blogspot.com) and then analyzes the word occurrence frequency. Output is then fed into wordle to make a word cloud (http://www.wordle.net/)
"""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
@bcbwilla
bcbwilla / mapreport.py
Last active December 17, 2015 07:29
Gather minecraft pvp match data from at oc.tc/matches
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
@bcbwilla
bcbwilla / filterx.nb
Last active December 15, 2015 10:59
This Mathematica function removes an {x,y} point if the point does not have a unique x value from a list {{x1,y1},{x2,y2},...}
(* 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];
@bcbwilla
bcbwilla / qmhw6.nb
Last active December 15, 2015 10:39
Graduate Quantum Mechanics II, HW 6, #4
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]
@bcbwilla
bcbwilla / euler.nb
Last active December 15, 2015 09:39
Mathematica functions for solving first order differential equations numerically
(* 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]];