Skip to content

Instantly share code, notes, and snippets.

View tilpner's full-sized avatar

Till Höppner tilpner

  • Germany
View GitHub Profile
[package]
authors = ["Till Höppner <till@hoeppner.ws>"]
name = "quux"
version = "0.1.0"
[dependencies]
mioco = "0.4.1"
time = "0.1.35"
extern crate mioco;
extern crate time;
use std::str::FromStr;
use std::net::SocketAddr;
use std::io::prelude::*;
// use std::sync::{Arc, Mutex};
use std::sync::Arc;
use mioco::sync::Mutex;
use std::io::BufReader;
#![feature(io)]
use std::io::{self, Read, Write};
use std::net::TcpStream;
use std::process::exit;
use std::env;
fn main() {
let addr: u16 = 12345;
let args = env::args().skip(1).collect::<Vec<_>>().join(" ");
use std::io;
use std::net::TcpListener;
use std::thread;
fn main() {
let listener = TcpListener::bind("127.0.0.1:12345").unwrap();
for stream in listener.incoming() {
if let Ok(mut out) = stream {
thread::spawn(move || {
if let Ok(mut inp) = out.try_clone() {
(use socket tcp6)
; Execute `nc -l -p 12345` in a terminal
; then run `csi -s timeout.scm`
(define s (tcp-connect "localhost" 12345))
(parameterize ((socket-receive-timeout 1000)
(tcp-read-timeout 1000))
(print (read-line s)))
use std::{env, io};
use std::fs::File;
fn main() {
let output = io::stdout();
env::args_os()
.skip(1)
.map(|f| {
let mut f = File::open(f).expect("Couldn't open file");
use std::{env, io, process};
use std::fs::File;
use std::path::Path;
use std::collections::HashSet;
use std::io::{BufReader, BufRead, Write};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
enum Errors {
Success = 0,
Open = 1,
@tilpner
tilpner / expand.rs
Created February 19, 2016 17:28
Limited tilde expansion, doesn't support ~user
use std::path::{Path, PathBuf};
use std::env;
fn expand<P: AsRef<Path>>(path: P) -> Option<PathBuf> {
let path = path.as_ref();
if path.starts_with("~") {
let mut path = path.iter();
path.next();
env::home_dir().map(|home| home.join(path))
} else {
@tilpner
tilpner / collaborate_with
Last active February 18, 2016 23:22
Naive detection if a keybase user collaborates with you. POC, inefficient, perhaps broken, do not use.
#!/usr/bin/env bash
USER=`keybase status | grep Username | awk '{print $NF}'`;
COLLAB_DIR="/keybase/public/$USER/collab"
FILE=`mktemp -t "XXXXXXXXXX" -p $COLLAB_DIR`
echo $1 | keybase encrypt -b --hide-recipients $1 > $FILE
@tilpner
tilpner / collaborates.fish
Created February 18, 2016 22:13
Inefficient sketch to detect collaboration with you
# e.g. "collaborates tilpner"
function collaborates
for f in /keybase/public/$argv[1]/collab**
keybase decrypt -i $f > /dev/null 2> /dev/null
if [ $status -eq 0 ]
echo "$argv[1] collaborates with you"
return
end
end