Skip to content

Instantly share code, notes, and snippets.

View unfo's full-sized avatar

Jan Wikholm unfo

View GitHub Profile
Host *.labs.overthewire.org
SendEnv WECHALLTOKEN
SendEnv WECHALLUSER
@unfo
unfo / ip.rs
Created May 15, 2015 16:12
hyper client response does not implement read_to_string
extern crate hyper;
use hyper::*;
fn main() {
let mut client = client::Client::new();
let res = client.get("http://ip.nebula.fi/").send().unwrap();
println!("Got response: {:?}", res.status_raw);
let mut contents = String::new();
سَيّارة
سيارة
@unfo
unfo / draw_graph.sh
Created March 16, 2015 09:33
simple awk script for drawing ascii graphs
# Should be used with | sort | uniq -c
# Example input:
# 2 0
# 3 1
# 46 2
# 6 3
# 20 4
# 115 5
function draw_graph() {
awk 'BEGIN { highest= -1 } { sum += $1; items += 1 ; if ($1 > highest) { highest = $1 } ; values[$2] = $1; } END { print highest; for (val in values) { print values[val] " " val } }' | \
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>feedly from @unfo</title>
</head>
<body>
<outline text="Must Read" title="Must Read">
<outline type="rss" text="Ho/Ax (@snare)" title="Ho/Ax (@snare)" xmlUrl="http://ho.ax/feed.xml" htmlUrl="http://ho.ax//"/>
<outline type="rss" text="lcamtuf's blog" title="lcamtuf's blog" xmlUrl="http://lcamtuf.blogspot.com/feeds/posts/default" htmlUrl="http://lcamtuf.blogspot.com/"/>

Dijkstra

File reading: 18 ms
JSON parse:   2243 ms
Vertex parse: 1818 ms
Find routes:  9468 ms
----
Total time: 13548 ms
pub struct Vertice {
pub source: int,
pub target: int,
pub weight: int,
}
pub struct Node {
pub id: int,
pub vertices: Vec<Vertice>,
}
@unfo
unfo / lib.rs
Created December 21, 2014 18:37
Compiling fastgraph v0.0.1 (file:///Users/jw/fun/rust/fastgraph)
/Users/jw/fun/rust/fastgraph/src/lib.rs:18:4: 24:5 error: match arms have incompatible types: expected `()`, found `core::option::Option<<generic #127>>` (expected (), found enum core::option::Option)
/Users/jw/fun/rust/fastgraph/src/lib.rs:18 match re.find(line) {
/Users/jw/fun/rust/fastgraph/src/lib.rs:19 Some((from,end)) => {
/Users/jw/fun/rust/fastgraph/src/lib.rs:20 let i: int = from_str(line.slice(from,end)).unwrap();
/Users/jw/fun/rust/fastgraph/src/lib.rs:21 Some(i);
/Users/jw/fun/rust/fastgraph/src/lib.rs:22 },
/Users/jw/fun/rust/fastgraph/src/lib.rs:23 _ => None
...
/Users/jw/fun/rust/fastgraph/src/lib.rs:23:10: 23:14 note: match arm with an incompatible type
-- USE: lua markov.lua pre-populated-history.log new-input-without-nicknames.log > ~/irc/NETWORK/#channel/in
local brain = {}
local NOWORD = "\0"
local history = arg[1]
local present = arg[2]
--[[
x: (where x is not one of the magic characters ^$()%.[]*+-?) represents the character x itself.
.: (a dot) represents all characters.
%a: represents all letters.
@unfo
unfo / output
Created September 29, 2014 11:23
TIL about Bash exec
rlyeh:work jw$ bash testredir.sh
rlyeh:work jw$ cat logfile
foo
bar