Skip to content

Instantly share code, notes, and snippets.

View justlaputa's full-sized avatar
:octocat:
coding 🐾🐾

Han Xiao justlaputa

:octocat:
coding 🐾🐾
View GitHub Profile
@justlaputa
justlaputa / get-imdb-oscar-movies.js
Last active March 6, 2016 14:44
run this script in chrome console in imdb's oscar awards page, you can get a list of all oscar movies
var movies = {}
var order = 0
function getLink(link) {
link = link.substring(0, link.lastIndexOf('?'))
return 'http://www.imdb.com' + link
}
function addMovie(category, title, link) {
if (!movies[title]) {
version: "2"
services:
mongodb:
container_name: mongodb
image: mongo:3.2
volumes:
- ./data/db:/data/db
ports:
- "27017:27017"
var codes = []
$('table.basic>tbody tr td[lang="en"]').each(function(i) {
td = $(this)
en_name = td.text()
siblings = td.siblings()
ja_name = siblings.get(0).textContent
iso_3166_2_code = siblings.get(1).textContent
codes.push({
@justlaputa
justlaputa / SimpleHTTPServerWithUpload.py
Created June 21, 2016 10:46 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@justlaputa
justlaputa / tmux.md
Created June 24, 2016 02:54 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

# Copy from https://github.com/MarvAmBass/docker-nginx-registry-proxy/blob/master/docker-registry.conf
# For versions of Nginx > 1.3.9 that include chunked transfer encoding support
# Replace with appropriate values where necessary
upstream docker-registry {
server registry:5000;
}
server {
listen 443 default_server;
@justlaputa
justlaputa / latency.markdown
Created November 6, 2016 06:15 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@justlaputa
justlaputa / ps-rslsync
Last active December 24, 2016 14:16
fix resiliosync daemon user
laputa@laputa-nuc-ubuntu:~$ ps aux | grep rslsync
rslsync 8388 0.2 0.0 504900 13676 ? Ssl 23:03 0:01 /usr/bin/rslsync --config /etc/resilio-sync/config.json
laputa 8420 0.0 0.0 15208 928 pts/17 S+ 23:10 0:00 grep --color=auto rslsy
$ sudo systemctl cat resilio-sync.service
# /lib/systemd/system/resilio-sync.service
[Unit]
Description=Resilio Sync service
Documentation=http://help.getsync.com/
After=network.target network-online.target
[Service]
Type=forking
User=rslsync
#!/bin/sh
mkdir -p $HOME/.config/resilio-sync
BTSYNC_STORAGE=$HOME/.config/btsync/storage
RESILIO_STORAGE=$HOME/.config/resilio-sync/storage
CONFIG_PATH=$HOME/.config/resilio-sync/config.json