Skip to content

Instantly share code, notes, and snippets.

View eddyb's full-sized avatar

Eduard-Mihai Burtescu eddyb

View GitHub Profile
fn pop<T, ..Stack>((_, ..stack): (T, ..Stack)) -> Stack {
stack
}
fn dup<T: Clone, ..Stack>((x, ..stack): (T, ..Stack)) -> (T, T, ..Stack) {
(x.clone(), x, ..stack)
}
fn swap<T, U, ..Stack>((x, y, ..stack): (T, U, ..Stack)) -> (U, T, ..Stack) {
(y, x, ..stack)
use git2::Delta;
use git2::DiffOptions;
use git2::Repository;
use std::collections::BTreeMap;
use std::env::set_current_dir;
use std::process::Command;
fn main() {
let repo = Repository::open_from_env().unwrap();
set_current_dir(repo.workdir().unwrap()).unwrap();
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package amedia;
import java.io.File;
import java.net.URL;
@eddyb
eddyb / foo.rs
Created January 26, 2014 12:25 — forked from bvssvni/gist:8631956
/*
Tests the Any trait.
*/
pub struct Player {
name: ~str
}
@eddyb
eddyb / gist:7886876
Last active December 30, 2015 21:19 — forked from ezyang/gist:7886849
pub unsafe fn allocMegaGroup(mblocks: nat) -> ~Block {
let n = MBLOCK_GROUP_BLOCKS(mblocks);
enum SearchResult<'a> {
PerfectMatch(~Block),
BestMatch(&'a mut BlockData, &'a mut BlockMeta),
NoMatch
}
fn go<'a>(n: uint,
prev_link: &'a mut Option<~Block>,
best: Option<(&'a mut BlockData, &'a mut BlockMeta)>)
@eddyb
eddyb / gist:7789849
Last active December 30, 2015 06:29 — forked from anonymous/gist:7789813
// array per definizione nomi da 0 a 19
static a19: [&'static str, ..20] = [
"", "uno", "due", "tre",
"quattro","cinque", "sei", "sette", "otto",
"nove", "dieci", "undici", "dodici",
"tredici", "quattordici", "quindici",
"sedici", "diciassette", "diciotto",
"diciannove"
];
@eddyb
eddyb / gist:7673295
Last active December 29, 2015 12:49 — forked from cnd/gist:7673288
(
|a: |b: |||| a(|| {})
)(
|b: ||| b()
)
@eddyb
eddyb / gist:7640657
Last active December 29, 2015 07:59 — forked from cnd/gist:7640445
let (ref cfg, ref appCfg) = {
let prefix = Path::new(getenv("HOME").unwrap_or(~""));
(prefix.join(".Sync.conf"), prefix.join(".Mirana.conf"))
};
@eddyb
eddyb / gist:7640491
Created November 25, 2013 12:22 — forked from cnd/gist:7640445
let (ref cfg, ref appCfg) = if nix {
( Path::new ( "~/.Sync.conf" ) ,
Path::new ( "~/.Mirana.conf" )
)
} else {
let prefix = getenv("HOME").unwrap_or(~"");
( Path::new ( prefix + "~/.Sync.conf" ),
Path::new ( prefix + "~/.Mirana.conf" )
)
};
@eddyb
eddyb / parse.rs
Last active December 28, 2015 23:49 — forked from tiffany352/parse.rs
use std::str::*;
use std::hashmap::*;
trait CloneParser<T> {
fn clone_as_parser(&self) -> ~Parser<T>;
}
impl<T, U: Clone> CloneParser<T> for U {
fn clone_as(&self) -> ~Parser<T> {
~self.clone() as ~Parser<T>