Skip to content

Instantly share code, notes, and snippets.

View stevej's full-sized avatar

Steve Jenson stevej

View GitHub Profile
@stevej
stevej / snowstorm.p8
Created June 29, 2017 04:00
Full cart of meditative snowstorm in Pico-8
pico-8 cartridge // http://www.pico-8.com
version 8
__lua__
fps = 30
current_frame = 0
x_max = 128
y_max = 128
updated = 0
players = {}
@stevej
stevej / 1k_qps_load_test.txt
Last active June 9, 2017 18:40
1k_qps_load_test.txt
stevej@netty-test-8:~$ ./slow_cooker_linux_amd64 -host perf-cluster -concurrency 10 -qps 100 http://proxy-test-4d:4140
# sending 1000 GET req/s with concurrency=10 to http://proxy-test-4d:4140 ...
# good/b/f t goal% min [p50 p95 p99 p999] max bhash change
2017-06-09T18:16:35Z 9721/0/0 10000 97% 10s 0 [ 1 2 5 412 ] 412 0 +
2017-06-09T18:16:45Z 9105/0/0 10000 91% 10s 0 [ 1 2 4 626 ] 626 0
2017-06-09T18:16:55Z 9195/0/0 10000 91% 10s 0 [ 1 2 3 413 ] 413 0
2017-06-09T18:17:05Z 9387/0/0 10000 93% 10s 0 [ 1 2 5 1003 ] 1003 0
2017-06-09T18:17:15Z 9511/0/0 10000 95% 10s 0 [ 1 3 4 412 ] 412 0
2017-06-09T18:17:25Z 9544/0/0 10000 95% 10s 0 [ 1 3 4 416 ] 416 0
2017-06-09T18:17:35Z 9548/0/0 10000 95% 10s 0 [ 1 2 4 413 ] 413 0
@stevej
stevej / lesson3.rs
Created January 21, 2017 23:04
Lesson #3: Borrow Checker Challenge Nested Borrows
// Nested borrows are a common source of trouble. This example is a bit contrived
// but illustrates the challenge.
fn main() {
let mut numbers = vec![1,2,3,4];
// Because push() needs a mutable borrow and len() needs an immutable borrow,
// the borrow checker lets you know you've broken the rules.
numbers.push(numbers.len());
println!("numbers has length {}", numbers.len());
}
@stevej
stevej / lesson2.rs
Created January 8, 2017 22:50
Rust for the Experienced Programmer. Lesson 2: references vs values
#[derive(Debug)]
struct Person {
id: u64,
name: String,
}
impl Person {
// Because we're passing a value, we take ownership of it. If we want to give
// ownership back, we have to return it.
fn set_name(mut self, new_name: String) -> Person {
@stevej
stevej / lesson1.rs
Last active January 9, 2017 17:27
Rust for the Experienced Programmer. Lesson 1: The Basics
// In Rust, much like Go, you organize functions around structs.
#[derive(Debug)]
struct Person {
id: u64,
name: String,
twitter_handle: String
}
// Here we hang a function off of a struct.
impl Person {
@stevej
stevej / playground.rs
Created January 8, 2017 21:24 — forked from anonymous/playground.rs
Shared via Rust Playground
// In Rust, much like Go, you organize functions around structs.
#[derive(Debug)]
struct Person {
id: u64,
name: String,
twitter_handle: String
}
// Here we hang a function off of a struct.
impl Person {
BigEasy% pwd
/Users/stevej/local/src/rust-sdl2
BigEasy% cargo clean
BigEasy% cargo build
Compiling pkg-config v0.1.3
/Users/stevej/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.3/src/lib.rs:62:24: 62:43 error: the trait `core::marker::Sized` is not implemented for the type `str`
/Users/stevej/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.3/src/lib.rs:62 .collect::<Vec<_>>();
^~~~~~~~~~~~~~~~~~~
/Users/stevej/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.3/src/lib.rs:62:24: 62:43 error: the trait `core::marker::Sized` is not implemented for the type `str`
/Users/stevej/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.3/src/lib.rs:62 .collect::<Vec<_>>();
/Users/stevej/src/CutieBaby/CutieBaby/GameScene.swift:12:6: error: unimplemented IR generation feature non-fixed multi-payload enum layout
enum Tree<T>:TreeLike {
^
0 swift 0x0000000101e6f028 llvm::sys::PrintStackTrace(__sFILE*) + 40
1 swift 0x0000000101e6f514 SignalHandler(int) + 452
2 libsystem_platform.dylib 0x00007fff89c395aa _sigtramp + 26
3 libsystem_platform.dylib 000000000000000000 _sigtramp + 1983670896
4 swift 0x0000000101ce7290 llvm::ConstantFoldGetElementPtr(llvm::Constant*, bool, llvm::ArrayRef<llvm::Value*>) + 112
5 swift 0x0000000101cef6f3 llvm::ConstantExpr::getGetElementPtr(llvm::Constant*, llvm::ArrayRef<llvm::Value*>, bool) + 51
6 swift 0x0000000101252c0b llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter<true> >::CreateConstInBoundsGEP2_32(llvm::Value*, unsigned int, unsigned int, llvm::Twine const&) + 123
@stevej
stevej / divis.c
Last active August 29, 2015 14:04
Epiphany-III disassembly for division
int main(void) {
// unsigned is not much better
int i = 3;
int j = 7;
double k = i / j;
return k;
}
@stevej
stevej / lazy.rs
Created December 6, 2012 04:57
Thunks in Rust
use core::option;
/**
* Implementation of thunks in Rust.
*/
pub struct Lazy<T> {
code : @fn() -> T,
mut value : Option<T>
}