Skip to content

Instantly share code, notes, and snippets.

View ascv's full-sized avatar

Joshua Andersen ascv

  • Fullbeaker.com
  • Seattle
View GitHub Profile
import getpass
def compute_freqs(sequence):
freqs = {
'd|d' : 0,
'f|d' : 0,
'd|f' : 0,
'f|f' : 0,
}
n <- 500
a <- rnorm(n, 0, 3)
b <- rnorm(n, 1, 4)
Z <- rep(0, n)
V <- rep(0, n)
P <- rep(0, n)
for (i in seq(5, n)) {
df <- i %% 24
A <- a[1:i]
@ascv
ascv / asdf
Created September 25, 2014 00:53
teams = c('Yahoo_Settings', 'French_Revolution', 'Full_QBker', 'Angel_Edward Team',
'TheGhostofAL', 'Hawkn_Balls', 'Jessica_Eric', "Mikes_Team",
'Game_of_Throws', 'WhoDat_Nation', 'Jim_Michael', "Alexandras_Team")
df = data.frame(teams=teams, avg=avg_scores, sd=sd_scores)
m = matrix(0, 151, 12)
x = seq(0,150)
for (i in 1:12) {
m[,i] = dnorm(x, avgs[i], sds[i])
@ascv
ascv / scratch
Created September 24, 2014 00:46
teams = c('Yahoo_Settings', 'French_Revolution', 'Full_QBker', 'Angel_Edward Team',
'TheGhostofAL', 'Hawkn_Balls', 'Jessica_Eric', "Mikes_Team",
'Game_of_Throws', 'WhoDat_Nation', 'Jim_Michael', "Alexandras_Team")
df = data.frame(teams=teams, avg=avg_scores, sd=sd_scores)
m = matrix(0, 151, 12)
x = seq(0,150)
for (i in 1:12) {
m[,i] = dnorm(x, avgs[i], sds[i])
@ascv
ascv / threebuys
Last active August 29, 2015 13:58
cc_sim = function(seed, tran, debug=FALSE) {
# Does a simulation from a list of transition coefficients
# and initial state.
#
# Args:
# seed: the initial state
# tran: a list of transition coefficients
n = length(tran)
lst = rep(1,n)
@ascv
ascv / getpdfs.sh
Last active August 29, 2015 13:57
Download all pdfs from a remote directory.
# Download all pdfs from a remote directory
grep -o '\"[a-zA-Z]*\.pdf\"' index.html |
sed s/\"//g |
sed -e "s/^/http:\/\/web.ipac.caltech.edu\/staff\/fmasci\/home\/statistics\_refs\//" |
xargs wget
@ascv
ascv / gist:6796978
Last active December 24, 2015 12:19
lego man
legoSim <- function() {
i = 1
legos <- c()
while(TRUE) {
x <- sample(1:16, 1)
if (x %in% legos == FALSE) {
legos <- c(legos, x)
if (length(legos) == 16) { break }
}
else { i <- i + 1 }
@ascv
ascv / gist:5123769
Last active December 14, 2015 17:39
MIT License
MIT LicenseCopyright (C) <2014> <Joshua Andersen>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTW
@ascv
ascv / gist:5122536
Last active December 14, 2015 17:29
How to catch javascript errors in the Firefox WebDriver using the JSErrorCollector extension. Get JSErrorCollector.xpi from https://github.com/mguillem/JSErrorCollector.
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.add_extension('JSErrorCollector.xpi')
ff=webdriver.Firefox(profile)
ff.get('http://www.somepage.com')
ff.execute_script('return window.JSErrorCollector_errors.pump()')
@ascv
ascv / gist:5038415
Created February 26, 2013 13:31
An example of merge sort in Java. This is not an in-place sort.
/**
* A demonstration of Merge Sort in Java.
*/
public class Merge {
public Merge() {}
/**
* Gets a sorted array in O(n log n).
*