Skip to content

Instantly share code, notes, and snippets.

@omaskery
omaskery / example_output_windows.txt
Last active February 4, 2021 00:45
Investigating slowness of golang/go executable on Windows?
NOTE: pathext contains 11 extensions
NOTE: path has 50 entries
goos: windows
goarch: amd64
pkg: golang-exec-slow-testbed
BenchmarkBuiltinUnknownCommand
BenchmarkBuiltinUnknownCommand-12 3 398999967 ns/op
BenchmarkBuiltinKnownCommand
BenchmarkBuiltinKnownCommand-12 218 5467874 ns/op
BenchmarkLocalCopyWithUnknownCommand
@omaskery
omaskery / parser_combinator.java
Last active July 7, 2019 21:46
Playing with writing a parser combinator in Python
package uk.co.maskery.parsercombinator;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class ParserException extends RuntimeException {
@omaskery
omaskery / docker-compose-ci.py
Last active November 7, 2020 04:10
Script for waiting for a docker compose to exit, before checking all services exited cleanly, returning 0 if so and 1 if any returned non-zero.
#!/usr/bin/env python3
import subprocess
import json
import sys
class Colours:
Green = '\033[92m'
Amber = '\033[93m'
@omaskery
omaskery / installation-instructions.txt
Created October 25, 2015 14:33
instructions for getting up and running with python 3.5/pygame/pycharm/github
python 3.5 (32-bit): https://www.python.org/ftp/python/3.5.0/python-3.5.0.exe
pygame 1.9.2 (compatible with python 3.5 32-bit): http://www.lfd.uci.edu/~gohlke/pythonlibs/xmshzit7/pygame-1.9.2a0-cp35-none-win32.whl
pycharm community edition 4.5.4: https://d1opms6zj7jotq.cloudfront.net/python/pycharm-community-4.5.4.exe
github for windows installer: https://github-windows.s3.amazonaws.com/GitHubSetup.exe
run python installer:
- when it gives option to "Install Now" or "Customize installation":
- if you DON'T care where it goes, click the checkbox "Add Python 3.5 to PATH" and click "Install Now"
- if you DO care where it lives on your computer, choose "Customize installation"
- when it lists advanced options and stuff:
@omaskery
omaskery / interceptor.py
Created September 15, 2015 21:27
a bit of code to poll my friend's mitmproxy web interface instance
from urllib import request, parse
import binascii
import hashlib
import zipfile
import json
def main():
@omaskery
omaskery / euler_2.rs
Last active May 28, 2017 22:22
Creating terribly over-engineered solution to Euler Problem #2 just to play with Rust (which is lovely).
use std::iter::AdditiveIterator;
use std::num::Int;
// Context for a fibonacci sequence generator
struct FibonacciContext<T> where T: Int {
two_ago: Option<T>, // the fibonacci number two previous in the sequence
one_ago: Option<T>, // the last fibonacci number in the sequence
}
// The iterator object for iterating fibonacci numbers
@omaskery
omaskery / main.rs
Last active August 29, 2015 14:15
Playing with the beale ciphers
use std::old_io::File;
use std::rand;
use std::rand::Rng;
use std::str::{StrExt, FromStr};
use std::ascii::OwnedAsciiExt;
use std::collections::HashMap;
use std::iter::AdditiveIterator;
use std::vec::Vec;
const DATA_PATH: &'static str = "data/1.txt";
@omaskery
omaskery / 1.txt
Created February 10, 2015 17:58
Playing around with the beale ciphers
71, 194, 38, 1701, 89, 76, 11, 83, 1629, 48, 94, 63, 132, 16, 111, 95, 84, 341, 975, 14, 40, 64, 27, 81, 139, 213, 63, 90, 1120, 8, 15, 3, 126, 2018, 40, 74, 758, 485, 604, 230, 436, 664, 582, 150, 251, 284, 308, 231, 124, 211, 486, 225, 401, 370, 11, 101, 305, 139, 189, 17, 33, 88, 208, 193, 145, 1, 94, 73, 416, 918, 263, 28, 500, 538, 356, 117, 136, 219, 27, 176, 130, 10, 460, 25, 485, 18, 436, 65, 84, 200, 283, 118, 320, 138, 36, 416, 280, 15, 71, 224, 961, 44, 16, 401, 39, 88, 61, 304, 12, 21, 24, 283, 134, 92, 63, 246, 486, 682, 7, 219, 184, 360, 780, 18, 64, 463, 474, 131, 160, 79, 73, 440, 95, 18, 64, 581, 34, 69, 128, 367, 460, 17, 81, 12, 103, 820, 62, 116, 97, 103, 862, 70, 60, 1317, 471, 540, 208, 121, 890, 346, 36, 150, 59, 568, 614, 13, 120, 63, 219, 812, 2160, 1780, 99, 35, 18, 21, 136, 872, 15, 28, 170, 88, 4, 30, 44, 112, 18, 147, 436, 195, 320, 37, 122, 113, 6, 140, 8, 120, 305, 42, 58, 461, 44, 106, 301, 13, 408, 680, 93, 86, 116, 530, 82, 568, 9, 102, 38, 416, 89, 71, 216, 728, 965, 818, 2,
@omaskery
omaskery / matrix.rs
Created December 13, 2014 23:17
attempt at a matrix implementation in Rust
use std::default::Default;
use std::num::Zero;
pub struct Matrix<T> {
values: Vec<T>,
rows: uint,
columns: uint,
}
struct BaseMatrixIter {
@omaskery
omaskery / silly_2D_quadcopter_experiment_sim
Created August 31, 2014 19:09
Silly little python/pygame simulation of a 2D "quadcopter" to play with PID controllers and estimating position in the face of noise, etc.
__author__ = 'Oliver Maskery'
import datetime
import pygame
import random
import math
class Controller(object):