Skip to content

Instantly share code, notes, and snippets.

@oconnor663
oconnor663 / gist:de963983eb2d932d12a9ec87e6535cca
Created November 18, 2016 22:11
Rust subprocess current_dir example
dummy
@oconnor663
oconnor663 / gist:7aea663fb161c5c35f83df1a21d0b7bb
Created December 16, 2016 15:28
flash-all.sh FAILED transcript ("remote: partition [bootb] doesn't exist")
$ sudo fastboot devices
FA6A20303377 fastboot
$ sudo ./flash-all.sh
target reported max download size of 536870912 bytes
sending 'bootloaderb' (32728 KB)...
OKAY [ 0.836s]
writing 'bootloaderb'...
(bootloader) Valid bootloader version.
OKAY [ 1.600s]
@oconnor663
oconnor663 / main.rs
Created December 27, 2016 18:52
mio pipes example
extern crate os_pipe;
extern crate mio;
extern crate nix;
use os_pipe::*;
use mio::*;
use mio::unix::EventedFd;
use nix::fcntl::*;
use std::io::prelude::*;
use std::os::unix::io::*;
@oconnor663
oconnor663 / sign.py
Last active May 4, 2017 19:01
mixing context into ed25519? (python 3)
import hashlib
b = 256
q = 2**255 - 19
l = 2**252 + 27742317777372353535851937790883648493
def H(m):
return hashlib.sha512(m).digest()
def expmod(b,e,m):
@oconnor663
oconnor663 / sleep.rs
Last active August 25, 2017 17:25
thread sleep future
extern crate futures;
use futures::{Future, Poll, Async};
use std::time::Duration;
use std::thread;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
struct Sleep {
@oconnor663
oconnor663 / bad_git.sh
Created October 4, 2017 17:02
edit a git commit without changing the hash
#! /bin/bash
d="$(mktemp -d)"
# Make a git repo with one file in it.
mkdir "$d/good"
cd "$d/good"
git init
echo good > file.txt
git add -A
@oconnor663
oconnor663 / banana.py
Created October 8, 2017 21:28
primality test with Anna
x = 5
# ==============================
# 1 and x will always divide the number, so no need to check those. so check 2 through x-1.
#
# i variable is trad. the "iteration count(er)"
# try to print all the numbers you will need to check in the primality test
i=0
while i<(x-2):
@oconnor663
oconnor663 / blake2b.rs
Last active June 21, 2018 21:25
toy blake2b implementation
extern crate byteorder;
use byteorder::{ByteOrder, LittleEndian};
type Digest = [u8; OUTBYTES];
pub const BLOCKBYTES: usize = 128;
pub const OUTBYTES: usize = 64;
pub const KEYBYTES: usize = 64;
pub const SALTBYTES: usize = 16;
@oconnor663
oconnor663 / cycle.py
Last active May 21, 2018 03:03
the 100 prisoners problem
import itertools
import random
def cycle_len(boxes, num):
steps = 1
position = num
while boxes[position] != num:
steps += 1
position = boxes[position]
return steps
@oconnor663
oconnor663 / b2sum.c
Last active August 10, 2018 20:02
libsodium example
#include <sodium.h>
#include <stdio.h>
#include <unistd.h>
#define BUFSIZE 65536
#define HASHSIZE 32
int main() {
if (sodium_init() == -1) {
return 1;