Skip to content

Instantly share code, notes, and snippets.

fhtagn unfo

Block or report user

Report or block unfo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View percentage.py
#!/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)
View .ssh config
Host *.labs.overthewire.org
SendEnv WECHALLTOKEN
SendEnv WECHALLUSER
@unfo
unfo / ip.rs
Created May 15, 2015
hyper client response does not implement read_to_string
View ip.rs
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();
View car
سَيّارة
سيارة
@unfo
unfo / draw_graph.sh
Created Mar 16, 2015
simple awk script for drawing ascii graphs
View draw_graph.sh
# 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 } }' | \
View unfo-feedly.opml
<?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/"/>
View dijkstra-vs-astar-no-heuristic.md

Dijkstra

File reading: 18 ms
JSON parse:   2243 ms
Vertex parse: 1818 ms
Find routes:  9468 ms
----
Total time:   13548 ms
View graph.rs
pub struct Vertice {
pub source: int,
pub target: int,
pub weight: int,
}
pub struct Node {
pub id: int,
pub vertices: Vec<Vertice>,
}
View lib.rs
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
View markov.lua
-- 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.
You can’t perform that action at this time.