Skip to content

Instantly share code, notes, and snippets.

View jamespan's full-sized avatar
😛

潘小鶸 jamespan

😛
View GitHub Profile
#!/usr/bin/python
# coding=utf-8
import datetime
import dateutil.parser
import pytz
import argparse
from collections import OrderedDict
import frontmatter
@jamespan
jamespan / dockerfile-hexo
Last active July 11, 2019 04:37
A Dockerfile for Hexo 3.0
FROM ubuntu:14.04
MAINTAINER Pan Jiabang, panjiabang@gmail.com
RUN \
# use aliyun's mirror for better download speed
sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
apt-get update && \
apt-get install -y nodejs curl git-core && \
# use nodejs as node
@jamespan
jamespan / ComparisonChain.java
Created March 9, 2015 15:52
ComparisonChain
import java.util.Comparator;
public abstract class ComparisonChain {
boolean nullValueLess = false;
public ComparisonChain nullValueLess() {
nullValueLess = true;
return this;
}

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

@jamespan
jamespan / OpenInTerminal.applescript
Created June 19, 2014 06:33
OpenInTerminal.applescript
-- OpenInTerminal.applescript
-- ForkLift
-- Created by JamesPan
tell application "System Events"
set appWasRunning to exists (processes where name is "iTerm")
tell application "iTerm"
activate
if not appWasRunning then
terminate the first session of the first terminal