Skip to content

Instantly share code, notes, and snippets.

View daxhuiberts's full-sized avatar

Dax Huiberts daxhuiberts

View GitHub Profile
@daxhuiberts
daxhuiberts / basic.component.wat
Last active April 16, 2024 17:56
Most basic WASI v0.2 CLI component
(component
(core module $app
(func (export "run") (result i32)
i32.const 0
)
)
(core instance $app (instantiate $app))
(func $run (result (result)) (canon lift (core func $app "run")))
http://blog.burntsushi.net/rust-error-handling/
http://hoverbear.org/2014/08/12/option-monads-in-rust/
http://hoverbear.org/2015/05/02/a-journey-into-iterators/
http://hoverbear.org/2015/07/10/reading-rust-function-signatures/
https://manishearth.github.io/blog/2015/05/03/where-rust-really-shines/
https://manishearth.github.io/blog/2015/05/17/the-problem-with-shared-mutability/
https://manishearth.github.io/blog/2015/05/27/wrapper-types-in-rust-choosing-your-guarantees/
https://manishearth.github.io/blog/2015/05/30/how-rust-achieves-thread-safety/
https://huonw.github.io/blog/2015/05/finding-closure-in-rust/
https://huonw.github.io/blog/2015/05/defaulting-to-thread-safety/
@daxhuiberts
daxhuiberts / gist:6527eea491da5a9d70b3
Last active August 29, 2015 14:12
what to do with the 'impl <T> Payload<T>'?
extern crate "rustc-serialize" as rustc_serialize;
use rustc_serialize::json;
use rustc_serialize::Encodable;
use rustc_serialize::json::Encoder;
use std::io::IoError;
#[deriving(RustcEncodable)]
struct Data {
str: &'static str,
@daxhuiberts
daxhuiberts / gist:9da05585979667f7743a
Created December 8, 2014 14:56
Bettering my Rust
// old one
fn process_stat(str: &str) -> Option<Vec<u32>> {
match STAT_REGEX.captures(str) {
Some(captures) => {
let iter = captures.at(1).split(' ');
let vec = iter.map(|x: &str| {
from_str(x).unwrap()
}).collect();
Some(vec)
}
@daxhuiberts
daxhuiberts / gist:8fe8c4f7f367e32260a5
Created August 1, 2014 10:22
proof of concept memcache server in rust
use std::collections::hashmap::HashMap;
use std::io::Acceptor;
use std::io::BufferedReader;
use std::io::Listener;
use std::io::TcpListener;
use std::sync::Arc;
use std::sync::RWLock;
fn main() {
let map = Arc::new(RWLock::new(HashMap::<String, String>::new()));
module ProcessAsset
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def process_asset(asset_name)
define_method :process do
send "#{asset_name}_file_name"
end
@daxhuiberts
daxhuiberts / gist:822385
Created February 11, 2011 14:04 — forked from roy/gist:822341
class Object
def tap(method =nil, *params, &block)
block.call(self) if block
self.send(method, *params) if method
self
end
end
@daxhuiberts
daxhuiberts / gist:822358
Created February 11, 2011 13:49 — forked from roy/gist:822341
class Object
def tap(method=nil, *params, &block)
raise ArgumentError, "supply either a block or a method name to send" if (method || block) && !(method && block)
block ||= proc { self.send method, *params }
super(&block)
end
end