Skip to content

Instantly share code, notes, and snippets.

│ mov %eax,%edx
│ mov -0x10570(%rbp),%rdi
│ → callq memset@plt
│ ↑ jmp 3ff
│430: lea -0x270(%rbp),%rdi
│ → callq core..result..Result$LT$hyper..server..response..Response$LT$hyper..net..Streaming$GT$$C$$u{20}std..old_io..IoError$GT$::glue_drop.7352::hc73d0301cc6ca3b3
0.01 │ lea -0x10328(%rbp),%rdi
│ mov %rdi,-0x10578(%rbp)
│ ↓ jmp 45f
│44c: mov -0x10578(%rbp),%rax
/code fn write_with_body(mut res: HttpResponse<Fresh>, mut body: Box<Reader + Send>) -> IoResult<()> {
let content_type = res.headers().get::<headers::ContentType>()
.map(|cx| cx.clone())
.unwrap_or_else(|| headers::ContentType("text/plain".parse().unwrap()));
res.headers_mut().set(content_type);
let mut res = try!(res.start());
// FIXME: Manually inlined old_io::util::copy
// because Box<Reader + Send> does not impl Reader.
#!/usr/bin/zsh
set -e
case "$1" in
mobile)
(set -x;
nmcli c down uuid fbfcaacb-649b-4490-8293-c68b526250d8)
nmcli c up uuid e3a22e4f-1973-4683-8de8-931578b0c6ec
;;
for line_or_fail in io::stdin().lines() {
let entry = line_counts.entry(line_or_fail.unwrap());
match entry {
Occupied(mut entry) => { *entry.get_mut() = *entry.get_mut() + 1; },
Vacant(entry) => { entry.set(1); },
}
}
for line_or_fail in io::stdin().lines() {
// XXX(scode): There is probably a much better way?
let line = line_or_fail.unwrap();
let existed = {
let existing_count = line_counts.get_mut(&line);
match existing_count {
None => { false },
Some(count) => { *count = *count + 1; true},
}
};
#[test]
fn test_from_file() {
let tmp_dir = io::TempDir::new("jsontest").unwrap();
let tmp_file: io::File = io::File::create(tmp_dir.path()).unwrap();
let tmp_path: Path = *tmp_file.path();
let mut tmp_out = io::BufferedWriter::new(tmp_file);
tmp_out.write_str(valid_cfg_json());
tmp_out.flush();
@scode
scode / gist:ba6f7395ae7c039b4c75
Created August 1, 2014 02:50
Python is insane
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> l1 = [1, 2]
>>> l2 = l1
>>> l1
[1, 2]
>>> l2
[1, 2]
>>> l1 += [3]
for tup in sorted_lines.iter() {
let count = tup.ref0();
let line = tup.ref1();
...
}
@scode
scode / gist:1179436
Created August 29, 2011 21:19
lazy generator
(defn- inner-generate [n]
(if (= n 10)
nil
(cons n (lazy-seq (inner-generate (inc n))))))
(defn generate []
(lazy-seq (inner-generate 0)))