Skip to content

Instantly share code, notes, and snippets.

View ucarion's full-sized avatar
🌁
I just love enterprise software, man

Ulysse Carion ucarion

🌁
I just love enterprise software, man
View GitHub Profile
@ucarion
ucarion / initial
Created April 18, 2015 08:02
Benchmarks
test tokenize lipsum-zh.html size 1024 ... bench: 3563 ns/iter (+/- 65)
test tokenize lipsum-zh.html size 1048576 ... bench: 4229471 ns/iter (+/- 344137)
test tokenize lipsum.html size 1024 ... bench: 1580 ns/iter (+/- 26)
test tokenize lipsum.html size 1048576 ... bench: 2463919 ns/iter (+/- 331551)
test tokenize lipsum.html size 1048576 (clone only) ... bench: 257680 ns/iter (+/- 12418)
test tokenize medium-fragment.html ... bench: 80507 ns/iter (+/- 1004)
test tokenize small-fragment.html ... bench: 7614 ns/iter (+/- 2761)
test tokenize strong.html size 1024 ... bench: 52213 ns/iter (+/- 9796)
test tokenize strong.html size 1048576 ... bench: 55531397 ns/iter (+/- 34521875)
test tokenize tiny-fragment.html ... bench: 1347 ns/iter (+/- 265)
$ multirust override nightly-2015-03-20
multirust: installing toolchain 'nightly-2015-03-20'
multirust: downloading rust manifest for 'nightly-2015-03-20'
multirust: downloading 'https://static.rust-lang.org/dist/2015-03-20/channel-rust-nightly.sha256' to '/Users/ulyssecarion/.multirust/tmp/tmp-18723-1'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (22) The requested URL returned error: 404 Not Found
multirust: couldn't download checksum file 'https://static.rust-lang.org/dist/2015-03-20/channel-rust-nightly.sha256'
@ucarion
ucarion / blob.rs
Created January 30, 2015 20:17
Read a blob file in Rust
extern crate flate2;
use std::old_io::{BufferedReader, File};
use flate2::reader::ZlibDecoder;
#[test]
fn test() {
let path = ".git/objects/c3/05bbc0533de6c05e73f37280d31667c5514169";
let file = File::open(&Path::new(path));
let mut reader = BufferedReader::new(file);
@ucarion
ucarion / git.rs
Created January 30, 2015 00:39
Rust issue
pub fn read_file(path: &str) -> IoResult<String> {
let basepath = Path::new(".git");
File::open(&basepath.join(path)).read_to_string()
}
pub enum HeadState {
Detached(String),
Attached(String)
}
@ucarion
ucarion / each_cons.rs
Created December 22, 2014 23:37
Rust each_cons
#![feature(slicing_syntax)]
use std::collections::RingBuf;
fn main() {
let xs = &[1i, 2i, 3i, 4i, 5i];
let mut iter = EachCons { iter: xs.iter(), n: 3, buffer: RingBuf::new() };
for x in iter {
println!("{}", x);
@ucarion
ucarion / lib.rs
Created December 18, 2014 03:08
Rust State Monad
/Users/ulyssecarion/rust/sparsile/src/lib.rs:7:9: 13:10 error: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
/Users/ulyssecarion/rust/sparsile/src/lib.rs:7 State {
/Users/ulyssecarion/rust/sparsile/src/lib.rs:8 runState: |firstState| {
/Users/ulyssecarion/rust/sparsile/src/lib.rs:9 let (result, nextState) = (self.runState)(firstState);
/Users/ulyssecarion/rust/sparsile/src/lib.rs:10
/Users/ulyssecarion/rust/sparsile/src/lib.rs:11 (f(result).runState)(nextState)
/Users/ulyssecarion/rust/sparsile/src/lib.rs:12 }
...
/Users/ulyssecarion/rust/sparsile/src/lib.rs:6:65: 14:6 note: first, the lifetime cannot outlive the block at 6:64...
/Users/ulyssecarion/rust/sparsile/src/lib.rs:6 fn and_then<B>(&self, f: |A| -> State<S, B>) -> State<S, B> {
@ucarion
ucarion / gist:1fbc51dc0ca12feb719a
Created November 15, 2014 03:07
Cowsay TeleBEARS
$ cowsay -f telebears 'Go bears!'
___________
< Go bears! >
-----------
\ _
\ (_) <-- TeleBEARS
\ ^__^ / \
\ (oo)\_____/_\ \
(__)\ you ) /
||----w ((
@ucarion
ucarion / html_cleanup.rb
Last active February 21, 2022 13:19
Composing programs to PDF
require 'nokogiri'
input = $stdin.readlines.join
page = Nokogiri::HTML(input)
page.css('.example').each do |elem|
elem.inner_html = '<i>Environment diagram omitted.</i>'
end
page.css('img').remove
@ucarion
ucarion / cah.txt
Created October 4, 2014 00:46
Cards Against Humanity Haikus
Flying sex snakes.
Michelle Obama's arms.
German dungeon porn.
White people.
Getting so angry that you pop a boner.
Tasteful sideboob.
Praying the gay away.
Two midgets shitting into a bucket.
MechaHitler.
Being a motherfucking sorcerer.
@ucarion
ucarion / hog.hs
Created September 17, 2014 20:40
Pig score distributions
-- Execute this as:
--
-- ghc -O2 hog.hs && ./hog
--
-- Which takes about 1 minute to execute.
import Data.List (any)
import Control.Monad (replicateM)
rolls :: Int -> Int -> [[Int]]