Skip to content

Instantly share code, notes, and snippets.

View charmoniumQ's full-sized avatar
:shipit:
dabbing on the haters

Sam Grayson charmoniumQ

:shipit:
dabbing on the haters
View GitHub Profile
@charmoniumQ
charmoniumQ / dropdown.html
Created October 4, 2013 22:39
Dropdown where you can select a pre-existing option, or "other" and create your own
<select onchange="checkvalue(this.value)">
<option value='Bailey'>Bailey</option>
<option value='Bedichek'>Bedichek</option>
<option value='Burnet'>Burnet</option>
<option selected value="Other">Other</option>
</select>
<input type="text" name="current_school_other" id="other_current_school" class="pad" style='visibility:visible;' disabled/>
<script>
function checkvalue(val) {
@charmoniumQ
charmoniumQ / brain.py
Created November 30, 2016 02:06
My BF interpreter
import sys
def interpret(source, memory=1000, max_iterations=100000):
mem = [0] * memory
mem_ptr = 0
loop_stack = []
src_ptr = 0
iterations = 0
while True:
# safety in brainf?

Keybase proof

I hereby claim:

  • I am charmoniumq on github.
  • I am charmonium (https://keybase.io/charmonium) on keybase.
  • I have a public key whose fingerprint is 1E12 89FB 4C9C 5ED6 0008 765B 5ECF 6F86 24EC 9FD8

To claim this, I am signing this object:

@charmoniumQ
charmoniumQ / frequency.py
Last active January 9, 2017 09:09
This script does a frequency analysis on the word-stems to improve your writing or analyze the English language
#!/usr/bin/env pytohn3
import re
import click
from collections import Counter
from nltk.stem.porter import PorterStemmer
def tokenize(prose):
prose = prose.lower()
prose = re.sub('[^a-z ]', ' ', prose, flags=re.M)
@charmoniumQ
charmoniumQ / four_numbers.hs
Last active March 15, 2017 21:57
Solves the generalized 4 numbers game (AKA 24 game) in Haskell. Answers the question "can you make this number out of those numbers (using basic operations)? If so, how?"
import Data.List
import System.Environment
---------- Main ----------
main :: IO ()
main = main1
main1 :: IO ()
main1 = do
@charmoniumQ
charmoniumQ / csvcut
Created April 28, 2017 05:15
CSV-aware cut -- outputs chosen columns of it's input
#!/usr/bin/env python3
import click
import sys
import csv
version = 0.1
version_info = '''
csvcut v{version}
by Sam Grayson
(backwards-c) 2017 GPLv3
#!/usr/bin/env python3
import os
import sys
from string import Template
for in_line in sys.stdin.readlines():
out_line = Template(in_line).safe_substitute(os.environ)
sys.stdout.write(out_line)
@charmoniumQ
charmoniumQ / cache.py
Last active October 28, 2017 16:05
See bottom for usage
import collections
from pathlib import Path, PurePath
import shutil
import toolz
import pickle
import os
class Cache(object):
def __init__(self, index, store, hit_msg=None, miss_msg=None, suffix=''):
@charmoniumQ
charmoniumQ / prime_in_e.cpp
Last active December 4, 2018 01:35
First ten-digit prime in the consecutive digits of e
/*
clang++ -g prime_in_e.cpp -std=c++11 -lgmp -lgmpxx -Wall -Werror -g -o test && ./test
*/
#include <iostream>
#include <vector>
#include <gmp.h>
#include <gmpxx.h>
#include <string>
#include <sstream>
#include <tuple>
@charmoniumQ
charmoniumQ / Makefile
Last active July 20, 2018 21:32
Malloc performance test
#CC = clang
CFLAGS += -Wall -Wextra -I./include/ -std=gnu99
CFLAGS_DBG = -Og -g
CFLAGS_OPT = -O3 -DNDEBUG
main: main.out
cp main.out main
main.out: main.c
$(CC) $(CFLAGS) $(CFLAGS_OPT) -o $@ $<