Skip to content

Instantly share code, notes, and snippets.

View wddwycc's full-sized avatar
🎯
Focusing

duan wddwycc

🎯
Focusing
View GitHub Profile
@wddwycc
wddwycc / .vimrc
Last active September 3, 2022 02:45
.vimrc
call plug#begin('~/.vim/plugged')
" Color Scheme
Plug 'morhetz/gruvbox'
" Syntax highlight
Plug 'sheerun/vim-polyglot'
Plug 'vim-airline/vim-airline'
Plug 'preservim/nerdtree'
@wddwycc
wddwycc / Lens.swift
Created June 8, 2019 06:52
Lens with @dynamicMemberLookup in Swift5.1
import Foundation
struct Lens<Whole, Part> {
let view: (Whole) -> Part
let set: (Part, Whole) -> Whole
}
protocol LensCompatible {}
@wddwycc
wddwycc / http-client.swift
Created May 16, 2019 14:12
simple but full featured http client based on Rx
import Foundation
import RxSwift
import RxCocoa
class HTTPClient {
private let session = URLSession.shared
func request(_ method: String = "GET", url: String,
@wddwycc
wddwycc / request.rs
Created December 2, 2017 03:54
Send request use hyper.rs
extern crate hyper;
extern crate futures;
extern crate tokio_core;
use std::io::{self, Write};
use futures::{Future, Stream};
use hyper::Client;
use tokio_core::reactor::Core;
fn main() {
@wddwycc
wddwycc / iron.md
Last active November 2, 2017 07:48
Iron Cheatsheet

Crate a router

extern crate iron;
extern crate router;

use iron::prelude::*;
use iron::status;
use router::Router;
@wddwycc
wddwycc / docker.md
Last active September 23, 2017 08:46
docker cheatsheet

Run

Run a container:

$ docker run -p <local-port>:<container-port> <image-name>

Add -d for detached mode.

@wddwycc
wddwycc / write_to_path.py
Created June 25, 2017 08:00
Python write to a path
def write(filepath, content):
folder = os.path.dirname(filepath)
if not os.path.isdir(folder):
os.makedirs(folder)
with open(filepath, 'wb') as f:
f.write(content.encode('utf-8'))
def create_flask_app(config=None):
app = Flask(__name__)
#: load default configuration
app.config.from_object('diadem.settings')
#: load environment configuration
if 'DIADEM_CONF' in os.environ:
app.config.from_envvar('DIADEM_CONF')
@wddwycc
wddwycc / tmux-cheatsheet.markdown
Created April 15, 2017 05:08 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@wddwycc
wddwycc / bobp-python.md
Created November 13, 2016 11:15 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens