Skip to content

Instantly share code, notes, and snippets.

@DarinM223
DarinM223 / main.rs
Last active February 23, 2017 13:32
How to get server service to send http requests in Hyper?
extern crate tokio_core;
extern crate hyper;
extern crate futures;
use futures::Future;
use futures::future::ok;
use hyper::{Body, Client, Get, StatusCode};
use hyper::client::HttpConnector;
use hyper::header::ContentLength;
// 2018.5.11更新: 减少了swap
function qSort(compare) {
var swap = (p1, p2) => {
var tmp = this[p1];
this[p1] = this[p2];
this[p2] = tmp;
}
var sortRange = (start, end) => {
var midValue = this[start];
var p1 = start + 1, p2 = end - 1;
// from c++ version: https://gist.github.com/timshen91/f6a3f040e5b5b0685b2a
// author: wangxiaochi
function ConcatExpr (Left,Right) {this.Left = Left;this.Right=Right} // ab
function AltExpr(Left,Right) {this.Left = Left;this.Right=Right} // a|b
function RepeatExpr(SubExpr) {this.SubExpr= SubExpr;} // a*
function OptionalExpr(SubExpr) {this.SubExpr= SubExpr;} // a?
function MatchExpr(ch) {
this.ch= ch
}
@infinityb
infinityb / gist:600c22ae549cecf43244
Last active January 23, 2022 16:44 — forked from webstrand/gist:46fb441e52a8663bced0
Simple Rust Reverse Proxy
extern crate hyper;
extern crate url;
static HOST: &'static str = "www.google.com";
macro_rules! ret_err(
($e:expr) => {{
match $e {
Ok(v) => v,
Err(e) => { println!("Line {}: {}", line!(), e); return; }
@joyrexus
joyrexus / README.md
Created February 23, 2015 22:11
boltdb demo
from: http://play.golang.org/p/P5DDZrcXZB
package main
import "fmt"
type Monad interface {
Bind(func(interface{}, Monad) Monad) Monad
Return(interface{}) Monad
}
@shaunlee
shaunlee / restful.go
Last active September 29, 2017 08:11
Simple RESTful web dispatcher
package main
import (
"fmt"
"log"
"net/http"
"regexp"
"strings"
)
@dpwright
dpwright / README.md
Last active June 21, 2018 03:09
Monadic operations in C++

Monadic operations in C++

This began as a further attempt to implement the Maybe monad in C++, but quickly spiralled out of control and now includes an implementation of the List monad as well (using std::list!). This is really for my own amusement rather than to try and do anything useful with them. It also gave me an excuse to try out C++ 11 lambda functions for the first time.

My original implementation defined a macro called MBind which caused a number of problems -- thankfully [PJayB][pjayb] managed to find a way around that so

Moved

Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.

Why it was moved

Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!

@shanzi
shanzi / init.vim
Last active September 30, 2023 08:20
This configuration use vundle to arrange vim plugins
" install vundle first:
" git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
set hidden
set nocompatible " do not compatible with vi
set backspace=indent,eol,start " allow backspace to delete char
set modeline
set shiftwidth=4 " set tab width to 4 space
set tabstop=4
set expandtab