This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
authors = ["Till Höppner <till@hoeppner.ws>"] | |
name = "quux" | |
version = "0.1.0" | |
[dependencies] | |
mioco = "0.4.1" | |
time = "0.1.35" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![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(" "); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |