Skip to content

Instantly share code, notes, and snippets.

View thouis's full-sized avatar

Thouis (Ray) Jones thouis

  • Broad Institute
  • Cambridge, MA, USA
View GitHub Profile
import requests
import time
# https://github.com/twitterdev/enterprise-scripts-python/blob/main/Engagement-API/generate_user_access_tokens.py
from generate_user_access_tokens import request_token, get_user_authorization, get_user_access_tokens, CONSUMER_KEY, CONSUMER_SECRET
MY_ID = "PUT_YOUR_TWITTER_ID_NUMBER_HERE"
def create_url():
aahed
aalii
aargh
aarti
abaca
abaci
aback
abacs
abaft
abaka
import os
from urllib import request
import numpy as np
import pandas as pd
# grab a large corpus of words, sorted by usage counts (Peter Norvig)
if not os.path.isfile('count_1w.txt'):
request.urlretrieve("https://norvig.com/ngrams/count_1w.txt",
"count_1w.txt")
@thouis
thouis / Players.ipynb
Last active January 2, 2020 20:17
OGS Player stats
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import sys
import twitter
import time
# see https://python-twitter.readthedocs.io/en/latest/getting_started.html
api = twitter.Api(consumer_key=CONSUMER_KEY,
consumer_secret=CONSUMER_SECRET,
access_token_key=ACCESS_TOKEN,
access_token_secret=ACCESS_SECRET)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am thouis on github.
  • I am thouis (https://keybase.io/thouis) on keybase.
  • I have a public key whose fingerprint is A4F6 3AF2 C0E4 8CAE 7501 2BDE 2904 0D09 3557 95A4

To claim this, I am signing this object:

def depth_to_space(x, blocksize=2):
b, k, d, r, c = x.shape
r1 = x.reshape((b, k // (blocksize ** 2), blocksize, blocksize, d, r, c))
r2 = r1.transpose(0, 1, 4, 5, 2, 6, 3)
return r2.reshape((b, k // (blocksize ** 2), d, r * blocksize, c * blocksize))
@thouis
thouis / rand.py
Last active August 11, 2019 09:59
more straightforward adjusted rand error
# coding=utf-8
import numpy as np
import scipy.sparse as sparse
# Evaluation code courtesy of Juan Nunez-Iglesias, taken from
# https://github.com/janelia-flyem/gala/blob/master/gala/evaluate.py
def adapted_rand(seg, gt, all_stats=False):
"""Compute Adapted Rand error as defined by the SNEMI3D contest [1]
import tensorflow as tf
from tensorflow.python import control_flow_ops
# from http://stackoverflow.com/a/34634291
def batch_norm(x, n_out, phase_train, scope='bn', affine=True):
"""
Batch normalization on convolutional maps.
Args:
x: Tensor, 4D BHWD input maps
n_out: integer, depth of input maps