Skip to content

Instantly share code, notes, and snippets.

View flowerhack's full-sized avatar

Julia Hansbrough flowerhack

View GitHub Profile
$ make presubmit
export HOSTOS=linux
export HOSTARCH=amd64
export TARGETOS=linux
export TARGETARCH=amd64
export TARGETVMARCH=amd64
export CC=gcc
export ADDCFLAGS=-m64 -static
export NCORES=56
export EXE=
@flowerhack
flowerhack / fuchsia.cfg
Created July 9, 2018 22:36
fuchsia.cfg
{
"name": "fuchsia",
"target": "fuchsia/amd64",
"http": ":12345",
"workdir": "/usr/local/google/home/flowerhack/workdir.fuchsia",
"kernel_obj": "/usr/local/google/home/flowerhack/dancethetokage/fuchsia/out/build-zircon/build-x64",
"syzkaller": "/usr/local/google/home/flowerhack/whateverpath/src/github.com/google/syzkaller",
"image": "/usr/local/google/home/flowerhack/dancethetokage/fuchsia/out/x64/images/fvm.blk",
"sshkey": "/usr/local/google/home/flowerhack/dancethetokage/fuchsia/out/x64/ssh-keys/id_ed25519",
"reproduce": false,
// We expect this program to terminate with a panic.
// Instead, it will loop forever.
package main
import(
"syscall"
)
func main() {
@flowerhack
flowerhack / refcounting.py
Last active August 29, 2015 14:10
reference counting wat
>>> import sys
>>> sys.getrefcount("myrandomstring")
3
>>> my_rand_str = "myrandomstring"
>>> sys.getrefcount(my_rand_str)
2
>>> sys.getrefcount("hi")
7
>>> class TestObj(object):
... def __init__(self):
@flowerhack
flowerhack / gist:e9747a7b371986e27b26
Last active August 29, 2015 14:10
test_nose_is_weird.py
class TestNoseIsWeird:
def test_hello(self):
import pdb; pdb.set_trace()
print("Hello world!")
# This will succeed:
# nosetests -s test_nose_is_weird.py
# But this will *hang* in Python 2, and *crash* in Python 3
# nosetests test_nose_is_weird.py
# In Python 2, it's not actually hanging—if you hit "c", it'll continue.
@flowerhack
flowerhack / rustgrep.rs
Last active August 29, 2015 14:08
Grep in Rust
/* A very simple grep. Currently only supports searching an exact
* string match within a single directory.
* Stuff that could be done in the future: actual regexp pattern
* matching, other features of grep that I don't actually use
*/
use std::os;
use std::io::{File, Open, ReadWrite};
fn main() {
@flowerhack
flowerhack / spellcheck.rs
Last active August 29, 2015 14:08
Spellchecker in Rust (WIP)
// compiled with rustc 0.13.0-dev
use std::io::{File, Open, ReadWrite};
use std::collections::HashMap;
// use std::clone::Clone; // the compiler warns about unused imports, how cool
fn words_list(infile: &str) -> Vec<String> {
let p = Path::new(infile);
// Gives us a file handle on success
let mut file = match File::open_mode(&p, Open, ReadWrite) {
@flowerhack
flowerhack / gist:2a1c95b6b87b98e21bd1
Last active August 29, 2015 14:07
Bytes in Python 3
# Initializing bytes is pretty easy
>>> my_bytestring = b'Reflection Eternal'
# Seems odd, though. Bytes are numbers, not strings. What encoding's being used?
>>> b'☃'
File "<stdin>", line 1
SyntaxError: bytes can only contain ASCII literal characters.
# So bytes implicitly convert whatever you feed it via ASCII, and unicode makes it explode, even though...
>>> import sys
@flowerhack
flowerhack / trollynamedtuple.py
Last active August 29, 2015 14:07
trollynamedtuple.py
import sys
def trollynamedtuple_init(self, *args):
for prop, arg in zip([i for i in dir(self) if not i.startswith('__')], args):
setattr(self, prop, arg)
def trollynamedtuple(typename, field_names):
tempclass = type(typename, (object,), {k: None for k in field_names.split()})
tempclass.__init__ = trollynamedtuple_init
parent_frame = sys._getframe(1)
@flowerhack
flowerhack / jankycollections.py
Last active August 29, 2015 14:07
jankycollections.py
def jankynamedtuple_init(self, *args):
for prop, arg in zip([i for i in dir(self) if not i.startswith('__')], args):
setattr(self, prop, arg)
def jankynamedtuple(typename, field_names):
tempclass = type(typename, (object,), {k: None for k in field_names.split()})
tempclass.__init__ = jankynamedtuple_init
return tempclass