This file contains hidden or 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
#!/bin/bash | |
mkdir -p /tmp/cerb_1 | |
sshfs $host_dir /tmp/cerb_1 | |
mkdir -p /tmp/cerb_2 | |
encfs /tmp/cerb_{1,2} | |
for d in $@ | |
do |
This file contains hidden or 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
#!/bin/bash | |
function setup_db() { | |
docker run -d --name gcpg postgres | |
echo "waiting for db to spin up..." | |
sleep 2 | |
docker exec gcpg psql -U postgres -c 'CREATE DATABASE gcdb;' | |
docker exec gcpg psql -U postgres -c "CREATE ROLE gcu WITH PASSWORD 'foo';" | |
docker exec gcpg psql -U postgres -c "ALTER ROLE gcu WITH LOGIN;" | |
docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --postgres | \ |
This file contains hidden or 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
CMDSTAN ?= ~/Downloads/cmdstan-2.17.0 | |
nsim ?= 1 | |
./%: %.stan prelude.stan | |
$(CMDSTAN)/bin/stanc --o=$*.hpp $*.stan | |
here=$(shell pwd); cd $(CMDSTAN); make $$here/$@; cd $$here | |
sim.csv: sim.data.R ./sim | |
./sim sample algorithm=fixed_param num_samples=$(nsim) data file=sim.data.R output file=sim.csv |
This file contains hidden or 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 re | |
def lines(fname='awssg.py'): | |
with open(fname,'r') as fd: | |
for line in fd.readlines(): | |
if "f'" in line: | |
yield line | |
def fmt_str(line): | |
ex = r'f\'(.*)\'' |
This file contains hidden or 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 .models import Thing | |
import time | |
all_ids = [] | |
size = 10000 | |
num_items = Thing.objects.count() | |
qs = Thing.objects.order_by('id') | |
last_id = qs.first().id | |
count = 0 |
This file contains hidden or 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 boto | |
import requests | |
import json | |
import os.path | |
# keep the list of cidr/ip addrs we used in the past | |
known_fname = os.path.expanduser('~/.awssg') | |
# aws credentials | |
creds = { |
This file contains hidden or 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 numpy import * | |
import numpy as np | |
from numpy.random import randn, rand | |
def spmat(A): | |
n = A.shape[0] | |
m = A != 0 # non-zero mask | |
a = A[m] # non-zero elements | |
r, c = argwhere(m).T # non-zero row & col indices |
This file contains hidden or 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 os | |
import sys | |
import subprocess | |
# gcc $(python3-config --cflags) -fPIC -c $file | |
# gcc -shared $(python3-config --ldflags) utils.o -o utils.so | |
def flags(): | |
proc = subprocess.Popen(['python3-config', '--cflags'], stdout=subprocess.PIPE) | |
cflags = proc.stdout.read().decode('ascii') |
This file contains hidden or 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
#!/bin/bash | |
apt-get update | |
apt-get install -y apt-transport-https ca-certificates curl python-software-properties | |
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - | |
echo "deb [arch=amd64] https://download.docker.com/linux/debian wheezy stable" >> /etc/apt/sources.list | |
echo "deb http://ftp.debian.org/debian/ wheezy-backports main" >> /etc/apt/sources.list | |
apt-get update |
This file contains hidden or 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
print('importing') | |
import numpy as np | |
import sympy as sp | |
import scipy.optimize | |
import random | |
print('functions') | |
def gen_trace(n_time, sig, dt, a): | |
x = random.gauss(0, 3) |