View playground.rs
This file contains 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
use std::sync::{Arc, Mutex, MutexGuard}; | |
use std::thread; | |
use std::thread::JoinHandle; | |
type SafeNode = Arc<Mutex<TreeNode>>; | |
#[derive(Debug)] | |
struct TreeNode { | |
value: u16, | |
children: Vec<TreeNode>, |
View playground.rs
This file contains 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
extern crate rand; | |
use rand::{thread_rng, Rng}; | |
use rand::distributions::{Normal, IndependentSample}; | |
struct SinglePack { | |
open_block: Vec<f64>, | |
open_sum: f64, | |
blocks: Vec<Vec<f64>>, | |
} |
View NaiveRust.rs
This file contains 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
// Implementation contributed by https://github.com/Maplicant | |
// Optimized game implementation in Rust | |
extern crate time; | |
use time::precise_time_ns; | |
use std::ops::{Add, Sub, Mul}; | |
const NUM_BLOCKS: usize = 65535; | |
const NUM_ENTITIES: usize = 1000; | |
const CHUNK_COUNT: usize = 100; |
View fast.rs
This file contains 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
let start = time::now(); | |
let metadata = try!(fs::metadata(&path)); | |
let mut file = try!(File::open(&path)); | |
let mut buf = vec![0u8; metadata.len() as usize]; | |
try!(file.read(&mut buf)); | |
buf.make_ascii_lowercase(); | |
let mut str: &str = try!(str::from_utf8(&buf)); |
View playground.rs
This file contains 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
pub struct Brick { | |
pub peer: Peer, | |
pub path: Path, | |
} | |
use std::fmt; | |
impl fmt::Display for Brick { | |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | |
write!(f, "{}:{}", self.peer.hostname, self.path.display()) |
View gc_count.rs
This file contains 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
//based off https://gist.github.com/samuell/5555803 | |
use std::fs::File; | |
use std::io::BufReader; | |
use std::io::prelude::*; | |
use std::env; | |
fn main() { | |
let mut file = BufReader::new(File::open("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa")); | |
let content = gc_content(&mut file); | |
println!("{:.2}", content * 100.0); |
View cmdline.rs
This file contains 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
extern crate getopts; | |
use std::io::{File, Open, Read}; | |
use std::path::Path; | |
use std::io::{Command}; | |
use std::string::{String}; | |
use std::os; | |
use std::str; | |
View gist:1d683f2ce03a053d9b06
This file contains 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
/* | |
Everything is in a single crate. The directory structure is as follows: | |
. | |
├── b | |
│ └── mod.rs | |
├── c | |
│ └── mod.rs | |
├── d | |
│ └── mod.rs |
View multiple files.xml
This file contains 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
<!-- strings_user.xml --> | |
<resources> | |
<string name="user_name">Name</string> | |
<string name="user_password">Password</string> | |
<string name="user_phone">Phone</string> | |
</resources> | |
<!-- strings_registration.xml --> |
View MacroCollection.hx
This file contains 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
package ; | |
/** | |
* ... | |
* @author Zachary Dremann | |
*/ | |
#if macro | |
import haxe.macro.Expr; | |
import haxe.macro.Context; |
NewerOlder