Skip to content

Instantly share code, notes, and snippets.

use std::io;
fn echo<T>(x:T) { io::println(format!("{}", x)); }
pub trait OpInt<'a> { fn call(&'a self, int, int) -> int; }
impl<'a> OpInt<'a> for &'a |int, int| -> int {
fn call(&self, a:int, b:int) -> int {
echo("I dont wanna die!");
(*self)(a, b)
use std::kinds::marker;
struct Foo {
foo: int,
nopod: marker::NoPod
}
static BAR: Foo = Foo{foo: 5, nopod: marker::NoPod};
### Keybase proof
I hereby claim:
* I am flaper87 on github.
* I am flaper87 (https://keybase.io/flaper87) on keybase.
* I have a public key whose fingerprint is 59F0 8A31 D7DB BD8D 3BC7 4B20 CE03 2311 5EBE 5FA8
To claim this, I am signing this object:
import sys
import json
from qpid.messaging import *
broker = "10.10.10.4:5672" if len(sys.argv)<2 else sys.argv[1]
address = "testexchange / testtopic" if len(sys.argv)<3 else sys.argv[2]
connection = Connection(broker)
try:
phantom /tmp $ cat test
; ModuleID = 'test.rc'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%tydesc = type { i64, i64, void ({}*, i8*)*, void ({}*, i8*)*, void ({}*, i8*)*, void ({}*, i8*)*, i64, { i8*, i64 } }
%struct.Test = type { %"enum.std::option::Option<~str>[#1]" }
%"enum.std::option::Option<~str>[#1]" = type { { i64, i64, [0 x i8] }* }
%str_slice = type { i8*, i64 }
%struct.Test2 = type { i64 }
@flaper87
flaper87 / gist:6530648
Created September 11, 2013 22:28
try_for
/**
* Executes a function in another task and waits
* N msecs for it to complete.
*
* # Return Value
*
* if the function succeeds, the returned value will
* be sent back wrapped in result::Ok, otherwise,
* result::Err will be returned.
*
@flaper87
flaper87 / query.rs
Created September 14, 2013 22:18
Build URLs with custom query params
extern mod extra;
use extra::url::Url;
fn main() {
let params = ~[(~"test", ~"value")];
let mut url: Url = FromStr::from_str("http://www.example.com").unwrap();
// url.query is extra::url::Query
// which is a type = ~[(~str, ~str)]
@flaper87
flaper87 / uvio.rs
Last active December 23, 2015 22:29
UvTimer selected.
impl RtioTimer for UvTimer {
fn sleep(&mut self, msecs: u64) {
self.sleep_uv(msecs);
if !self.optimistic_check() {
rtdebug!("sleep: Optimistic check failed, blocking on");
let scheduler: ~Scheduler = Local::take();
do scheduler.deschedule_running_task_and_then |sched, task| {
self.block_on(sched, task);
}
}
@flaper87
flaper87 / jq.spec
Last active December 26, 2015 03:08
JQ Package
Name: jq
Version: 1.3
Release: 2%{?dist}
Summary: Command-line JSON processor
License: MIT and ASL 2.0 and CC-BY and GPLv3
URL: http://stedolan.github.io/jq/
Source0: http://stedolan.github.io/%{name}/download/source/%{name}-%{version}.tar.gz
BuildRequires: flex
@flaper87
flaper87 / macros.rc
Last active January 1, 2016 04:49
Useful mutt macros
# Mark all as read
# Use _ to collapse-all threads
macro index .r "<limit>~N<enter><tag-pattern>~N<enter><tag-prefix><clear-flag>N<clear-flag>*<untag-pattern>~T<enter><limit>all<enter>" "party time, excellent"
# Toggle pager full-screen
# Tweak `pager_index_lines`
macro pager indexOn "<enter-command>set pager_index_lines="30"; macro pager V indexOff 'Toggle emails index'<enter><redraw-screen>"
macro pager indexOff "<enter-command>set pager_index_lines="0"; macro pager V indexOn 'Toggle emails index'<enter><redraw-screen>"
macro pager V indexOff 'Toogle emails index'