Skip to content

Instantly share code, notes, and snippets.

@emk
emk / gist:9f27145d7f2e593d1463
Last active August 29, 2015 14:02
Rust dynamic linked on Heroku
$ heroku run ldd ./lang-detect
Running `ldd ./lang-detect` attached to terminal... up, run.9621
linux-vdso.so.1 => (0x00007fff82163000)
librustful-9550c8e3-0.1-pre.so => /app/./lib/rustful/lib/librustful-9550c8e3-0.1-pre.so (0x00007f67ee595000)
libnative-1fb5e2c0-0.11.0-pre.so => not found
libhttp-2cee9fa1-0.1-pre.so => /app/./lib/rustful/lib/libhttp-2cee9fa1-0.1-pre.so (0x00007f67ee283000)
libcollections-d412c0c4-0.11.0-pre.so => not found
librand-2ea8f361-0.11.0-pre.so => not found
libstd-59beb4f7-0.11.0-pre.so => not found
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007f67ee06b000)
@emk
emk / collect_example.rs
Created June 1, 2014 17:33
Rust: Using 'collect' after we map something which might fail
impl FromStr for LanguageTag {
fn from_str(s: &str) -> Option<LanguageTag> {
fn parse(s: &str) -> Option<Tag> { from_str(s) }
let parsed: Option<Vec<Tag>> = collect(s.split('-').map(parse));
match parsed {
Some(components) => Some(LanguageTag { components: components }),
None => None
}
}
}
@emk
emk / try_opt.rs
Created June 2, 2014 10:23
try_opt!
macro_rules! try_opt(
($e:expr) => (match $e { Some(v) => v, None => return None });
)
@emk
emk / french-blogs.opml
Created June 8, 2014 12:58
French-language blogs
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>French blogs</title>
</head>
<body>
<outline text="Actualitiés" title="Actualitiés">
<outline type="rss" text="Le Monde.fr - Actualité à la Une" title="Le Monde.fr - Actualité à la Une" xmlUrl="http://www.lemonde.fr/rss/sequence/0,2-3208,1-0,0.xml" htmlUrl="http://www.lemonde.fr/rss/une.xml"/>
<outline type="rss" text="LE FIGARO - Le Figaro - Actualité en direct et informations en continu" title="LE FIGARO - Le Figaro - Actualité en direct et informations en continu" xmlUrl="http://www.lefigaro.fr/rss/figaro_une.xml" htmlUrl="http://www.lefigaro.fr/"/>
@emk
emk / gist:1edb38d29b5078091e1b
Created July 12, 2014 21:23
Cargo failing on Heroku
Updating git repository `https://github.com/iron/iron.git`
fatal: Not a git repository: '.'
Unable to update https://github.com/iron/iron.git
Caused by:
Unable to update https://github.com/iron/iron.git
Caused by:
Executing `git fetch --force --quiet origin` failed
@emk
emk / gist:fd4847bb732ebbd7d5e7
Created July 13, 2014 12:02
Iron middleware with unhandled request returns 200 OK
Escape character is '^]'.
GET /foo.txt HTTP/1.1
Host: www.example.com
HTTP/1.1 200 OK
Transfer-Encoding: chunked
0
@emk
emk / french-lexique-5000-film-corpus.txt
Created September 5, 2014 20:02
French Lexique top 5000 film corpus
-- Generated from Lexique 3. For raw data & Creative Commons License, see: http://lexique.org/
-- Note that this word list has some peculiarities, because it was intended for use by language
-- processing software.
être
avoir
je
de
ne
pas
le
@emk
emk / error.txt
Created September 17, 2014 18:54
Cargo errors on Heroku
Updating git repository `https://github.com/reem/rust-unsafe-any.git`
Unable to update https://github.com/reem/rust-unsafe-any.git#75cff194
Caused by:
failed to clone into: /tmp/cargo_ASPp/.cargo/git/db/rust-unsafe-any-3633b05955fd77c7
Caused by:
[16] The SSL certificate is invalid
@emk
emk / map_reduce.rs
Created September 27, 2014 12:08
Need something where both Clone and Copy work
pub struct Emitter<R,K: Hash + Eq + Clone,V: Copy,MR: MapReduce<R,K,V>> {
results: HashMap<K,V>
}
impl<R,K: Hash + Eq + Clone,V: Copy,MR: MapReduce<R,K,V>> Emitter<R,K,V,MR> {
fn new() -> Emitter<R,K,V,MR> {
Emitter{results: HashMap::with_capacity(25000)}
}
#[inline]
@emk
emk / melt2connlx
Created September 29, 2014 13:27
melt2connlx: Convert MElt POS-tagger output into a CONLLX file
#!/usr/bin/env ruby
#
# Convert `MElt -tdL` output into *.conllx format. Usage:
#
# melt2conllx < input.melt > output.conllx
#
# Input should be one line per sentence, formatted like:
#
# Durant/P/durant le/DET/le trajet/NC/trajet qui/PROREL/qui
#