Skip to content

Instantly share code, notes, and snippets.

Brian Chen betaveros

Block or report user

Report or block betaveros

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
@betaveros
betaveros / mums-leaderboard.js
Last active Aug 10, 2019
Add comparable solve times to the MUMS Puzzlehunt leaderboard
View mums-leaderboard.js
(() => {window.setInterval(() => {
document.querySelectorAll('.betaveros').forEach((node) => {
node.parentNode.removeChild(node);
});
const makeNode = (t) => {
const span = document.createElement('span');
span.className = 'betaveros';
span.textContent = t;
return span;
};
@betaveros
betaveros / makefuzz.py
Created Apr 16, 2019
some really sketchy makefile patching to get openssl fuzzing to work
View makefuzz.py
import sys, os, subprocess
def check(msg):
if not input(msg + ' (y/n): ').lower().startswith('y'):
print('Aborting')
sys.exit()
subprocess.run('./config enable-fuzz-libfuzzer -DPEDANTIC enable-asan enable-ubsan no-shared -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=fuzzer-no-link enable-ec_nistp_64_gcc_128 -fno-sanitize=alignment enable-tls1_3 enable-weak-ssl-ciphers enable-rc5 enable-md2 enable-ssl3 enable-ssl3-method enable-nextprotoneg --debug'.split(), env={'CC': 'clang'})
check('Does config look ok?')
with open('Makefile') as infile:
View fp-optimized.asm
0000000100000f40 <__Z1av>:
100000f40: 55 push rbp
100000f41: 48 89 e5 mov rbp,rsp
100000f44: b8 03 00 00 00 mov eax,0x3
100000f49: 5d pop rbp
100000f4a: c3 ret
100000f4b: 0f 1f 44 00 00 nop DWORD PTR [rax+rax*1+0x0]
0000000100000f50 <_main>:
100000f50: 55 push rbp
@betaveros
betaveros / c.hs
Created Nov 27, 2017
Enumerative Combinatorics with Haskell, Splash 2017
View c.hs
import Control.Monad
import Data.List
-- Haskell comments look like this, lines that start with two hyphens.
{- You can also write range comments like this. -}
-- We did not write the type annotations (lines with ::) during class, and in
-- fact if you delete them Haskell will supply (more general) type signatures.
-- You can see what type Haskell thinks the things we've defined are by running
View x86.s
b8 01 00 00 00 mov eax,0x1
b8 37 13 00 00 mov eax,0x1337
b9 01 00 00 00 mov ecx,0x1
b9 37 13 00 00 mov ecx,0x1337
48 c7 c0 01 00 00 00 mov rax,0x1
48 c7 c0 37 13 00 00 mov rax,0x1337
48 c7 c1 01 00 00 00 mov rcx,0x1
48 c7 c1 37 13 00 00 mov rcx,0x1337
49 c7 c0 01 00 00 00 mov r8,0x1
49 c7 c0 37 13 00 00 mov r8,0x1337
@betaveros
betaveros / fn_minus.xml
Created Jan 9, 2017
Karabiner XML for mapping fn+- (fn-hyphen) to a legitimate minus sign, cobbled together from sone online sources I forget
View fn_minus.xml
<?xml version="1.0"?>
<root>
<item>
<name>Change fn+- to (minus sign)</name>
<appendix>You need to enable Unicode Hex Input and U.S. input sources.</appendix>
<identifier>private.fn_minus</identifier>
<autogen>__KeyToKey__
KeyCode::MINUS, ModifierFlag::FN,
<!-- change input source to Unicode -->
View tempo.py
from __future__ import division, print_function
def partial_differences(xs):
return [x2 - x1 for (x1, x2) in zip(xs, xs[1:])]
def index_of_max(xs):
return max(enumerate(xs), key=lambda pair: pair[1])[0]
# given a list of floats, compute a tempo and a timestamp
def tempo(xs, max_beats):
@betaveros
betaveros / c.hs
Last active Nov 25, 2016
combinatorics!
View c.hs
import Control.Monad
import Data.List
-- Haskell comments look like this, lines that start with two hyphens.
{- You can also write range comments like this. -}
-- We did not write the type annotations (lines with ::) during class, and in
-- fact if you delete them Haskell will supply (more general) type signatures.
-- You can see what type Haskell thinks the things we've defined are by running
@betaveros
betaveros / .vimrc
Created May 21, 2016
the .vimrc MIT used at ICPC WF 2016; half of it was probably unnecessary, but it's probably not worth it to figure out which half
View .vimrc
set nocp ai bs=2 cul hls ic is lbr list ls=2 mouse=a nu ru sc scs smd so=3 sw=4 ts=4
set lcs=tab\ ,trail:
filetype plugin indent on
syntax on
map <Space> i<Space><Esc>
map gA m'ggVG"+y''
View hangman.py
(lambda main: main(0, 'https://opensource.org/licenses/MIT', ''.join(filter(str.isalpha, __import__('random').choice(open('/usr/share/dict/words').readlines()).upper())), set(), '|======\n| |\n| {3} {0} {5}\n| {2}{1}{4}\n| {6} {7}\n| {8} {9}\n|', list('OT-\\-//\\||'), 10, main))(lambda _, license, chosen_word, guesses, scaffold, man, guesses_left, main_: main_(map(guesses.add, filter(str.isalpha, raw_input('%s(%s guesses left)\n%s\n%s:' % (','.join(sorted(guesses)), guesses_left, scaffold.format(*(man[:10-guesses_left] + [' '] * guesses_left)), ' '.join(letter if letter in guesses else '_' for letter in chosen_word))).upper())), license, chosen_word, guesses, scaffold, man, max((10 - len(guesses - set(chosen_word))), 0), main_) if not all(letter in guesses for letter in chosen_word) and guesses_left else __import__('sys').stdout.write('You ' + ['lose!\n' + scaffold.format(*man), 'win!'][bool(guesses_left)] + '\nWord was ' + chosen_word + '\n'))
You can’t perform that action at this time.