Skip to content

Instantly share code, notes, and snippets.

@bramp
bramp / 401k.dot
Created Nov 14, 2017
401k/IRA flow chart
View 401k.dot
digraph "401k" {
label = "Assumptions - 2018 - Age < 50 - Single - Income > $135k - 50% company match of 401(k)\n";
"Pay Cheque (Pre-tax)" -> "Pre-tax 401(k)" [ label = "Max $18.5k*" ];
"Pay Cheque (After-tax)" -> "Roth 401(k)" [ label = "Max $18.5k*" ];
"Pay Cheque (After-tax)" -> "After-tax 401(k)" [ label = "Max $27.25k" ];
"Pay Cheque (After-tax)" -> "Bank Account (After-tax)";
@bramp
bramp / mysql_simple_test.go
Created Oct 1, 2017
Example of a failing ANTLR MySQL Parser
View mysql_simple_test.go
/**
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@bramp
bramp / CaseChangingStream.go
Created Sep 28, 2017
Example antlr.CharStream that changes the case of the input.
View CaseChangingStream.go
/*
Copyright 2017 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@bramp
bramp / turn-on-github-ssl.py
Created Jun 9, 2016
Prints a list of all owned repositories with pages.
View turn-on-github-ssl.py
#!/usr/bin/env python
# Prints a list of all owned repositories with pages.
# by Andrew Brampton 2016 https://bramp.net
#
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
View gist:c43cc4d137e11127963b
Benchmark Mode Cnt Score Error Units
UnrolledCopierBenchmark.ByteLoopState.test thrpt 25 32035617.621 ± 203057.890 ops/s
UnrolledCopierBenchmark.ForLoopState.test thrpt 25 137210309.246 ± 3297133.141 ops/s * For loop
UnrolledCopierBenchmark.LoopState.test thrpt 25 148544358.728 ± 10786777.032 ops/s * While loop
UnrolledCopierBenchmark.HandUnrolledState.test thrpt 25 447763590.583 ± 7256308.885 ops/s
UnrolledCopierBenchmark.UnrolledState.test thrpt 25 455870292.662 ± 4004173.595 ops/s
(Larger scores the better)
https://github.com/bramp/unsafe/blob/master/unsafe-unroller/src/main/java/net/bramp/unsafe/LoopingForUnsafeCopier.java#L36
https://github.com/bramp/unsafe/blob/master/unsafe-unroller/src/main/java/net/bramp/unsafe/LoopingUnsafeCopier.java#L38
View findfakes
#!/bin/sh
# Finds fake files (e.g. those files which are 700mb big, but contain just zeros)
# by bramp.net 2015
#
if [ -z "$1" ]; then
echo "Usage: $0 <directory/files>"
echo "List files that are fakes"
return
fi
for path in "$@"
@bramp
bramp / keybase.md
Created Apr 23, 2014
Keybase proof for Andrew Brampton
View keybase.md

Keybase proof

I hereby claim:

  • I am bramp on github.
  • I am bramp (https://keybase.io/bramp) on keybase.
  • I have a public key whose fingerprint is 77EF 1852 F8E2 E39C 4973 FCDB 67F1 D791 30CA 7809

To claim this, I am signing this object:

@bramp
bramp / gist:5183117
Last active Dec 15, 2015
# Simple script that reads a mongodb datafile (by Andrew Brampton) Finds all documents starting with _id reads the record, and prints out compressed and uncompressed results.
View gist:5183117
# Simple script that reads a mongodb datafile
# Finds all documents starting with _id
# reads the record, and prints out compressed and uncompressed
# results.
#
import mmap
import os
import struct
import zlib
@bramp
bramp / clip.class.php
Created Nov 26, 2011
PHP Polygon Clipping using the Sutherland-Hodgman algorithm
View clip.class.php
<?php
/**
* Polygon Clipping
* @author Andrew Brampton me <at> bramp <dot> net
* @url http://bramp.net/blog/2011/11/php-polygon-clipper-using-the-sutherland-hodgman-algorithm/
*
* Based on the Sutherland-Hodgman algorithm (1974).
* http://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm
*
* This approache assumes four clip edges (the bounding box).
@bramp
bramp / ucode.py
Created Oct 13, 2011
Prints some simple information about ucode firmwares such as those used by Intel Wifi cards
View ucode.py
#!/usr/bin/python
# Prints some simple information about ucode firmwares
# such as those used by Intel Wifi cards
#
# Version 1.0 Jan 2011
# by Andrew Brampton
#
# Example
# ./ucode.py /lib/firmware/*.ucode
#