Skip to content

Instantly share code, notes, and snippets.

View shaunxw's full-sized avatar
🦀

Shaun Wang shaunxw

🦀
View GitHub Profile
### Keybase proof
I hereby claim:
* I am shaunxw on github.
* I am shaunw (https://keybase.io/shaunw) on keybase.
* I have a public key ASBgaQM519wS4wN0Vls6AlDKSqq0pcPfJMG0i-9eSHq8Vgo
To claim this, I am signing this object:
@shaunxw
shaunxw / move.rs
Last active October 3, 2019 23:31
Rust: `move` == memcpy?
#[derive(Debug)]
struct S(u32);
fn move_struct() -> S {
let s = S(0);
println!("addr before move: {:p}", &s);
s
}
fn move_box() -> Box<S> {
@shaunxw
shaunxw / .tmux.conf
Created May 17, 2019 01:37
my tmux config
# Mouse
set -g mouse on
set -g set-clipboard external
# Pane splitting.
bind h split-window -c "#{pane_current_path}" -h
bind v split-window -c "#{pane_current_path}" -v
# Autorename sanely.
setw -g automatic-rename on
@shaunxw
shaunxw / decorator_patterns.py
Created July 25, 2018 04:28
Decorator patterns
import functools
# `_func` should not be used as kwarg here, as it is for detecting if
# this decorator is used with parentheses or not.
def my_dec(_func=None, *, my_kwarg="my keyword arg"):
"""
Could used with parentheses or not.
"""
def decorator(func):
@shaunxw
shaunxw / UIFont & UIFontDescriptor.swift
Last active September 30, 2016 03:11
UIFont & UIFontDescriptor Quick Reference, by Swift 3. Copy it to playground to review.
import UIKit
// UIFont
// create a font by name and size
let avenirFont = UIFont(name: "Avenir", size: 12)
// get a font with different size from another font
let avenirLargeFont = avenirFont?.withSize(30)