Skip to content

Instantly share code, notes, and snippets.

Avatar

Brendan Zabarauskas brendanzab

View GitHub Profile
@emberian
emberian / links.md
Last active Aug 29, 2015
PL Theory etc
View links.md
@sobels
sobels / life.d
Created Oct 20, 2014
Conway's Game of Life, using D metaprogramming
View life.d
enum height = 5;
enum width = 5;
enum iterations = 20;
enum initialState = [
0, 1, 0, 1, 1,
0, 0, 0, 0, 1,
1, 1, 0, 0, 0,
1, 1, 1, 1, 1,
@aaron-santos
aaron-santos / gist:3939096
Created Oct 23, 2012
rSimulate GeoJSON Draft
View gist:3939096

Purpose

To define a common data language for applications that simulate entire worlds. When many applications speak the same language, an ecosystem develops that is often more than the sum of its parts.

General

  • All data is UTF-8 encoded.
  • MIME type is application/json
View gist:4288478
// Original version: http://play.golang.org/p/ebO20f-eax
// Requires Rust 0.5.
extern mod std;
use io::WriterUtil;
const WIDTH: uint = 76;
const HEIGHT: uint = 10;
const NUM_BALLS: uint = 10;
anonymous
anonymous / RustSyntaxProposal
Created Mar 18, 2013
Proposal for new syntax for type definition. Motivation: Rust tries to mix concepts from Functional languages with syntax from C/C++. structs (records) are equivalent to the C/C++ version. However enums in rust do not behave like enums from c: Enums in rust are used to define Algebraic Data Types (sum types) that act similar to 'tagged unions' i…
View RustSyntaxProposal
type Name = {
first: ~str,
last: ~str
}
type Shape = Circle(int) | Rect(int, int) // Variants with constructors
type Direction = North | South | East | West // without constructors
View cpplike.rs
pub trait BaseVec: Index<uint,Self::T>
+ Eq {
type T;
static LEN: uint;
fn from_value(value: Self::T) -> Self;
}
pub trait BaseVec3: BaseVec {
fn new(x: Self::T, y: Self::T, z: Self::T) -> Self;
}
View rqsrt.rs
fn libc_rsqrt(f: &f32) -> f32 {
1.0/f32::sqrt(*f)
}
fn llvm_rsqrt(f: &f32) -> f32 {
1.0/core::unstable::intrinsics::sqrtf32(*f)
}
fn asm_rsqrt(f: &f32) -> f32 {
let mut b = &0.0f32;
unsafe {
asm!("rsqrtss ($0), %xmm0\n\t\
View ohnoes.rs
fn r̄ͬ̇ͦ̓u͗͗̅̐s̔̈́ͯ̄̓ͭ͋tͣͯͦ̂̃̆̓_̍͌̉̃l̆a͐̾̿̋̈́n̉ͬͥ́ͪ̊gͭ͛̾_́cͪͬ͑͂̈oͭͨ̊̋̓ͧm̌̿̐̿ͤ̆͐e̔̓̆ͭͨ̾̚s() {
println("ĭ̒̚tͧ̂͆ͫ̄ ̃ͬ͗̍̂c̈͒̊õ͑̓ͩͦ͒m̊͗̐̒esͩ͛!ͨ̀ͩ̀͆̄̚ ĭ̿̈̍̀ͮ͑tͦ͂̉̒̔̇ ̓co͛́̾ͤ̄̉͌m͂͆̀ͫe͛ͨ͌̇͆ͣͥs͂!̇̌̎̆");
}
fn main() {
r̄ͬ̇ͦ̓u͗͗̅̐s̔̈́ͯ̄̓ͭ͋tͣͯͦ̂̃̆̓_̍͌̉̃l̆a͐̾̿̋̈́n̉ͬͥ́ͪ̊gͭ͛̾_́cͪͬ͑͂̈oͭͨ̊̋̓ͧm̌̿̐̿ͤ̆͐e̔̓̆ͭͨ̾̚s();
}
View glfw-refactor.rs
pub struct Context {
chan: SharedChan<Msg>,
}
enum Msg {
CreateWindow(Context, uint, uint, ~str, WindowMode, Chan<Option<Window>>),
DetachCurrentContext,
// window messages
GetShouldClose(*c_void, Chan<bool>),