Skip to content

Instantly share code, notes, and snippets.

@shadowmint
shadowmint / gist:9593771
Created March 17, 2014 03:59
Debug'd random reader
extern crate rand;
use std::io;
use std::num;
use std::io::BufferedReader;
use rand::{task_rng, Rng};
fn main() -> () {
@shadowmint
shadowmint / gist:9948184
Last active August 29, 2015 13:58
Trait things
use _macros;
mod foo {
pub trait Foo {
fn hello(&self);
}
}
mod bar {
pub trait Foo {
doug:rust-libs doug$ cat junk.rs
#![crate_id = "junk#0.1"]
use std::libc::c_int;
#[no_mangle]
pub extern fn dothing(a: c_int, b:c_int) -> c_int {
return a + b;
}
define(["require", "exports", 'jquery'], function(require, exports, $) {
requirejs.config({ baseUrl: "Scripts", paths: { jquery: "jquery-1.10.2" } }); // <--- Never gets used
$('#hello').click(); // <--- Won't work, because jquery won't be resolve to the right path
});
enum PyrsErr {
InternalErr
}
...
pub fn init() -> Result<*mut Struct_ppyData, PyrsErr> {
unsafe {
return Ok(ppy_init());
}
macro_rules! trace(
($($arg:tt)*) => (
{ let x = ::std::io::stdout().write_line(format_args!(::std::fmt::format, $($arg)*)); println!("{}", x); }
);
)
pub fn do_something() -> uint {
return 99;
}
@shadowmint
shadowmint / gist:11361488
Created April 28, 2014 04:02
Memory tests
extern crate libc;
use libc::c_void;
use std::ops::Drop;
use std::intrinsics::forget;
use std::ptr::swap;
struct Foo { x: int }
impl Drop for Foo {
use std::iter::Iterator;
struct Foo {
offset:uint,
x:[int, ..8]
}
impl Iterator<(* mut Foo, int)> for Foo {
fn next(& mut self) -> Option<(* mut Foo, int)> {
if self.offset > 0 {
@shadowmint
shadowmint / SassMeister-input.scss
Created April 29, 2014 03:54
Generated by SassMeister.com.
// ----
// Sass (v3.3.5)
// Compass (v1.0.0.alpha.18)
// ----
$mqsupport: true;
$static-bp: tablet;
$breakpoints: (
mobile: (false, 100),
tablet: (100, 200),
use std::str::from_utf8;
pub enum StrTs<'a> {
StrT(&'a str),
VecT(Vec<u8>),
SliceT(&'a [u8]),
}
pub enum StrErr {
InvalidLength