This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I can make a case that queues only do what people want if you don’t consider failure cases. | |
Qs are empty (normal) or full (fail). Normally things are processed quickly. Failure case processing time is unbounded (or “too long”). | |
Solution is always “dump the Q”. Which means you do care about how long it takes to process items. So you want the queue to always be empty | |
Which means you only want a non-failing Q. | |
So why not admit it, use in-proc buffers, run enough servers to handle load? Reject work up front instead of dropping oldest items w/… |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env ruby | |
# A brute-force letterpress board searcher. It takes about 90 seconds to search a board. | |
# | |
# Good uses: train on your vocabulary with boards you lost on. | |
# | |
# LAZY AND STUPID CHEATERS: DO NOT USE THIS FOR CHEATING. CHEATERS NEVER WIN. | |
class BoardSearcher | |
attr_reader :board |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use core::option; | |
/** | |
* Implementation of thunks in Rust. | |
*/ | |
pub struct Lazy<T> { | |
code : @fn() -> T, | |
mut value : Option<T> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(void) { | |
// unsigned is not much better | |
int i = 3; | |
int j = 7; | |
double k = i / j; | |
return k; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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<_>>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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()); | |
} |