Skip to content

Instantly share code, notes, and snippets.

View swenson's full-sized avatar
🍰
cupcake

Christopher Swenson swenson

🍰
cupcake
View GitHub Profile
@swenson
swenson / runTests.sh
Last active July 30, 2021 22:30
Run Android tests (returning with exit code 1 if they fail)
# Use whatever your test app directory is for ExampleTest, and whatever the
# package you are testing for com.example.test
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$PATH"
pushd ExampleTest
# adb shell throws away the return value, so we have to hack do some magic
# see https://code.google.com/p/android/issues/detail?id=3254
@swenson
swenson / listing-7-1.py
Created March 31, 2015 22:14
Code samples from Modern Cryptanalysis by Christopher Swenson
# The number of bits in the S-box
sbits = 6
# Calculate the maximum value / differential
ssize = 2**6
# Generate the matrix of differences, starting
# at all zeros
count = []
for i in range(ssize):
@swenson
swenson / Swenson & Poppies.tmTheme
Created April 12, 2015 22:42
Swenson & Poppies Sublime Text theme, based on Slush & Poppies.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Generated by: TmTheme-Editor -->
<!-- ============================================ -->
<!-- app: http://tmtheme-editor.herokuapp.com -->
<!-- code: https://github.com/aziz/tmTheme-Editor -->
<plist version="1.0">
<dict>
<key>author</key>
<string>William D. Neumann</string>
@swenson
swenson / debug.asm
Created April 25, 2015 19:37
A 6502 disassembler and debugger (written as part of a NES emulator)
do_a_trap
mov esi, [trap]
test esi, 0x10000
jnz normal_trap
test esi, 0x20000
jnz register_trap
jmp near return_no_cigar
normal_trap
cmp si, [_PC]
jnz near return_no_cigar
@swenson
swenson / backup.sh
Created August 12, 2015 05:17
Install tarsnap. Then, here's some stuff.
#!/bin/bash
NAME="something"
d=$(date "+%F--%H-%M-%S")
/usr/local/bin/tarsnap -c --keyfile /root/tarsnap.key --cachedir /usr/local/tarsnap-cache -f $NAME-backup-$d /etc /home /root /var
proc f() : (int, int) {
return f();
}
proc main() {
f();
}
@swenson
swenson / repro.chpl
Created March 28, 2016 21:44
Tuple destructor: formal count does not match argument count
proc f() : (int, int) {
return f();
}
proc main() {
f();
}
@swenson
swenson / segfault.py
Created July 13, 2016 04:23
Segfault Python 2.7.11 (mac) by adding numbers
This file has been truncated, but you can view the full file.
def f():
a0 = 0
a1 = 1
a2 = 2
a3 = 3
a4 = 4
a5 = 5
a6 = 6
a7 = 7
a8 = 8
@swenson
swenson / explore.py
Created August 10, 2016 22:09
Ctags + Pygments static source generator
from collections import defaultdict
import json
import os
import os.path
import shutil
from pygments.formatters import HtmlFormatter
from pygments.lexers import get_lexer_for_filename
from pygments import highlight
@swenson
swenson / rlwe-integers.ipynb
Created December 24, 2016 07:57
This notebook performs computations from "Fully Homomorphic Encryption over the Integers" by van Dijk, Gentry, Halevi, and Vaikuntanathanm, which can be found at https://eprint.iacr.org/2009/616.pdf
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.