Skip to content

Instantly share code, notes, and snippets.

View unfo's full-sized avatar

Jan Wikholm unfo

View GitHub Profile
pub struct Vertice {
pub source: int,
pub target: int,
pub weight: int,
}
pub struct Node {
pub id: int,
pub vertices: Vec<Vertice>,
}

Dijkstra

File reading: 18 ms
JSON parse:   2243 ms
Vertex parse: 1818 ms
Find routes:  9468 ms
----
Total time: 13548 ms
<?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/"/>
@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 } }' | \
سَيّارة
سيارة
@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();
Host *.labs.overthewire.org
SendEnv WECHALLTOKEN
SendEnv WECHALLUSER
#!/usr/bin/python
import sys
def min_needed(percentage, decimals):
top = 1.0
bottom = 1.0
percentage = round(percentage, decimals)
current = round(100 * (top / bottom), decimals)
@unfo
unfo / shl 8
Created November 23, 2015 09:53
|----------------- eax -----------------|
|-- ah -| |-- al -|
0001 0001 1000 1000 0000 0000 1111 1111
<< 8
1000 1000 0000 0000 1111 1111 0000 0000
import SimpleHTTPServer
import SocketServer
import logging
import cgi
import sys
if len(sys.argv) > 2:
PORT = int(sys.argv[2])