Skip to content

Instantly share code, notes, and snippets.

@mbrubeck
mbrubeck / ssh2-sample.rs
Created February 21, 2018 22:27 — forked from opensourcegeek/ssh2-sample.rs
Failing code
extern crate ssh2;
use std::net::TcpStream;
use ssh2::Session;
fn create_session() -> (TcpStream, Session) {
let tcp = TcpStream::connect("test:22").expect("Cannot connect");
let mut sess = Session::new().expect("cannot start session");
sess.handshake(&tcp).expect("handshake failed");
@mbrubeck
mbrubeck / main.rs
Last active May 22, 2018 16:36 — forked from Yatekii/main.rs
pub fn render(library: &Library, state: &mut State, mut stack: Vec<String>, expression: &mut Expression) -> Expression {
match expression {
// We have a symbolic expression that we have to evaluate
Expression::Symbolic(ref mut args) | Expression::NotDone(ref mut args) => {
// If we have a valid expression (unnamed ones are not allowed)
if args.len() > 0 {
// Get the first nested expression
return match args.remove(0) {
// If the first expression is a plain literal
Expression::Literal(Literal::S(name)) => {
@mbrubeck
mbrubeck / lib.rs
Last active July 19, 2018 16:05 — forked from pftbest/lib.rs
#![feature(test)]
extern crate test;
trait Max2 {
type Item;
fn max_by_key2<B: Ord, F>(self, f: F) -> Option<Self::Item> where
Self: Sized,
F: FnMut(&Self::Item) -> B;
}