Skip to content

Instantly share code, notes, and snippets.

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 {
boxdot /
Created November 7, 2019 20:09
Calculate number of stable crates on
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();
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 {
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
extern crate nom;
use nom::alpha;
use nom::types::CompleteStr;
use nom::ErrorKind;
named!(block<CompleteStr, Vec<(CompleteStr, CompleteStr)>>,
tag!("BEGIN") >>
boxdot / Cargo.toml
Last active October 9, 2018 09:20
Example of a hyper service/server with rate limiting of requests
name = "ratelimiting-server"
version = "0.1.0"
futures = "0.1"
tokio = "0.1"
hyper = "0.12"
extern crate futures;
extern crate time;
use futures::prelude::*;
use futures::sync::mpsc::{channel, Receiver};
use time::{Tm, now_utc};
use std::{thread};
boxdot /
Last active February 2, 2018 16:46
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();
use std::fs::File;
use std::io::BufRead;
use std::io::Write;
use std::path::PathBuf;
struct Args {
input: PathBuf,
column: String,
replacement: String,
// before
fn parse_args<Iter>(mut args: Iter) -> Result<Args, &'static str>
where Iter: Iterator<Item = String>
let hostname = match {
Some(s) => s,
None => return Err("argument 'hostname' missing"),
let port: u16 = match {