View gitlab_hook.rs
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 gitlab::webhooks::WebHook; | |
use hyper::service::{make_service_fn, service_fn}; | |
use hyper::{Body, Request, Response, Server}; | |
use log::{log_enabled, Level}; | |
async fn gitlab_webhook(req: Request<Body>) -> Result<Response<Body>, hyper::Error> { | |
log::debug!("< {:?}", req); | |
let body = hyper::body::to_bytes(req.into_body()).await?; | |
let event: Result<WebHook, _> = serde_json::from_slice(&body); | |
match event { |
View num-stable-crates.rs
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::cmp::Reverse; | |
use std::collections::HashMap; | |
use std::fs::File; | |
use std::io::BufRead; | |
use std::io::BufReader; | |
use walkdir::WalkDir; | |
fn get_version(entry: walkdir::Result<walkdir::DirEntry>) -> Option<String> { | |
let entry = entry.ok()?; | |
let path = entry.path(); |
View leaked_thread.rs
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 actix::prelude::*; | |
use actix_web::{middleware, web, App, HttpResponse, HttpServer}; | |
use log::info; | |
use std::io; | |
use std::thread; | |
use std::time::Duration; | |
fn my_handler() -> HttpResponse { | |
"Hello".into() |
View test.rs
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
fn some_test -> Result<(), Error> { | |
let mut rt = tokio::runtime::Runtime::new().unwrap(); | |
rt.spawn(microservice_1.map_err(|e| panic!(e))); | |
rt.spawn(microservice_2.map_err(|e| panic!(e))); | |
rt.spawn(microservice_3.map_err(|e| panic!(e))); | |
rt.spawn(microservice_4.map_err(|e| panic!(e))); | |
// do testing and do not touch rt anymore | |
} |
View nom_error.rs
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
#[macro_use] | |
extern crate nom; | |
use nom::alpha; | |
use nom::types::CompleteStr; | |
use nom::ErrorKind; | |
named!(block<CompleteStr, Vec<(CompleteStr, CompleteStr)>>, | |
do_parse!( | |
tag!("BEGIN") >> |
View Cargo.toml
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] | |
name = "ratelimiting-server" | |
version = "0.1.0" | |
[dependencies] | |
futures = "0.1" | |
tokio = "0.1" | |
hyper = "0.12" |
View elm-time.rs
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
#![allow(dead_code)] | |
extern crate futures; | |
extern crate time; | |
use futures::prelude::*; | |
use futures::sync::mpsc::{channel, Receiver}; | |
use time::{Tm, now_utc}; | |
use std::{thread}; |
View client.rs
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
impl Client { | |
pub fn connect( | |
handle: &Handle, | |
uri: hyper::Uri, | |
framework_info: mesos::FrameworkInfo, | |
) -> Box<Future<Item = Self, Error = failure::Error>> { | |
// Mesos subscribe essage | |
let mut call = scheduler::Call::new(); | |
let mut subscribe = scheduler::Call_Subscribe::new(); | |
subscribe.set_framework_info(framework_info); |
View csv.rs
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::fs::File; | |
use std::io::BufRead; | |
use std::io::Write; | |
use std::path::PathBuf; | |
#[derive(Debug)] | |
struct Args { | |
input: PathBuf, | |
column: String, | |
replacement: String, |
View before_after.rs
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
// before | |
fn parse_args<Iter>(mut args: Iter) -> Result<Args, &'static str> | |
where Iter: Iterator<Item = String> | |
{ | |
let hostname = match args.next() { | |
Some(s) => s, | |
None => return Err("argument 'hostname' missing"), | |
}; | |
let port: u16 = match args.next() { |
NewerOlder