Skip to content

Instantly share code, notes, and snippets.

Test Status. Do not upvote

Chewxy chewxy

Test Status. Do not upvote
Block or report user

Report or block chewxy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View main.go
package main
import (
chewxy / test_sparse.go
Created Dec 30, 2017
Sparse tensors in Gorgonia
View test_sparse.go
package main
import (
. ""
func main() {
xs := []int{1, 2, 6, 8}
chewxy /
Created Nov 26, 2015
Munges stuff from FitNotes, StrongLifts and MyFitnessPal
import pandas as pd
import numpy as np
fitnotesFile = "..."
strongLiftsFile = "..."
mfpFile = "..."
fn = pd.read_csv(fitnotesFile)
fn = fn.rename(columns={'Weight (kgs)': 'Weight'}) # cleanup names
grp = fn.groupby(['Date','Exercise']).agg({'Weight':[np.sum, np.mean], 'Reps': [np.sum, np.mean], 'Exercise': [np.size]})
import math
class Monad(object):
def bind(self, f):
if type(self) is List and type(self.value) is list:
return self._bind(f)
elif type(self) is Value and type(self.value) is list:
# transform it into a List(Value)
chewxy /
Created Sep 3, 2014
Gets the EBNF from the ECMAScript 5.1 spec
from bs4 import BeautifulSoup
import requests
r = requests.get('')
soup = BeautifulSoup(r.text)
sections = ('sec-A.1', 'sec-A.2', 'sec-A.3', 'sec-A.4', 'sec-A.5')
appendix = []
for s in sections:
chewxy /
Created Sep 3, 2014
Gets the EBNF of the Golang spec at
from bs4 import BeautifulSoup
import requests
r = requests.get('')
soup = BeautifulSoup(r.text)
bnf = soup.find_all('pre', class_='ebnf')
bnftxt = [x.get_text() for x in bnf]
bnftxt = ''.join(bnftxt)
chewxy / gist:02159093814794eb18d8
Created Aug 17, 2014
variadic functions in ASM
View gist:02159093814794eb18d8
pushq %rbp
movq %rsp, %rbp
subq $64, %rsp
movl %edi, -180(%rbp)
movq %rdx, -160(%rbp)
movq %rcx, -152(%rbp)
movq %r8, -144(%rbp)
movq %r9, -136(%rbp)
testb %al, %al
chewxy / gist:17e6920b608208647a74
Created Aug 7, 2014
Running arbitrary code in Python
View gist:17e6920b608208647a74
# Sorry for using Python 2.7
from ctypes import *
import os, sys
argv = int(sys.argv[1])
argv2 = int(sys.argv[2])
chewxy /
Created Feb 12, 2014
Quick and Dirty Colour Histogram of a masked image in OpenCV
import cv2
import numpy as np
import matplotlib.pyplot as plt
im = cv2.imread('IMG_3545S.JPG')
# convert to greyscale for easy thresholding
imgray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
# get a threshold - basically splits the image into black and white
View pointerTaggingBench_test.go
package pointerTagging
import (
func BenchmarkInitializingInterface(b *testing.B) {
for i := 0; i < b.N; i++ {
You can’t perform that action at this time.