This file contains hidden or 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
| ;; -*- mode: emacs-lisp -*- ;; | |
| (require 'cl) | |
| ;; set up marmelade for package management | |
| (require 'package) | |
| (add-to-list 'package-archives | |
| '("melpa" . "http://melpa.milkbox.net/packages/") t) |
This file contains hidden or 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
| ### Keybase proof | |
| I hereby claim: | |
| * I am dbp on github. | |
| * I am dbp (https://keybase.io/dbp) on keybase. | |
| * I have a public key whose fingerprint is 36EE AD9E A53D 20B7 9C38 3EED 2747 EC48 A98D 4AF0 | |
| To claim this, I am signing this object: |
This file contains hidden or 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
| ;; -*- mode: emacs-lisp -*- ;; | |
| (require 'cl) | |
| ;; set up marmelade for package management | |
| (require 'package) | |
| (add-to-list 'package-archives | |
| '("melpa" . "http://melpa.milkbox.net/packages/") t) |
This file contains hidden or 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
| {-# LANGUAGE OverloadedStrings #-} | |
| module Main where | |
| import Control.Monad | |
| import Data.Monoid | |
| import Data.Text (Text) | |
| import qualified Data.Text as T | |
| import qualified Data.Text.IO as T | |
| import Database.Rivet | |
| import Database.Rivet.Adaptor.PostgreSQL |
This file contains hidden or 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
| // how pretty printer formats closures (I think; I'm unable to build from incoming right now to check) | |
| fn main() { | |
| do something |foo| | |
| { | |
| something_long_enough_to_not; | |
| fit_on_a_single_line; | |
| } | |
| let my_fn = || | |
| { | |
| something_long_enough_to_not; |
This file contains hidden or 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
| fn main() { | |
| let bytes : ~[u8] = ~[1,1,1]; // for example | |
| let len = vec::len(bytes)-1; | |
| let mut out: u32 = 0; | |
| do vec::iteri(bytes) |i, b| { | |
| out += (b as u32) << (8*(len-i)) | |
| } | |
| io::println(u32::str(out)); | |
| } |
This file contains hidden or 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
| macro_rules! num_visitor( | |
| ($typ:ident) => ( | |
| fn visit_$typ() -> bool { | |
| self.align_to::<$typ>(); | |
| do self.get::<$typ>() |i| { | |
| self.out += $typ::to_str(i, 10u); | |
| }; | |
| self.bump_past::<$typ>(); | |
| true | |
| } |
This file contains hidden or 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
| ... | |
| fn visit_enter_enum_variant(_variant: uint, | |
| _disr_val: int, | |
| _n_fields: uint, | |
| _name: &str) -> bool { | |
| do self.get::<int>() |e| { | |
| if e == _disr_val { | |
| self.out += _name; | |
| } | |
| }; |
This file contains hidden or 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
| fn visit_evec_uniq(_mtbl: uint, _inner: *tydesc) -> bool { | |
| self.out += ~"~["; | |
| self.align_to::<~[u8]>(); | |
| self.visit_unboxed_vec(_mtbl, _inner); | |
| self.bump_past::<~[u8]>(); | |
| self.out += ~"]"; | |
| true | |
| } | |
| fn visit_unboxed_vec(_mtbl: uint, _inner: *tydesc) -> bool { |
This file contains hidden or 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
| fn visit_estr_fixed(_n: uint, _sz: uint, | |
| _align: uint) -> bool { | |
| self.align(_align); | |
| self.out += ~"\""; | |
| unsafe { | |
| self.out += str::unsafe::from_buf_len(self.ptr as *u8, _n); | |
| } | |
| self.bump(_sz); | |
| self.out += ~"\""; | |
| true |
OlderNewer