Skip to content

Instantly share code, notes, and snippets.

class KArayTree {
private Node bfs(List<Node> preOrder, int k){
Node root = preOrder.get(0);
Deque<Node> q = new ArrayDeque<>();
q.addLast(root);
int index=1;
while(!q.isEmpty()){
Node p = q.removeFirst();
p.deleteAllChildren();
for(int i=0;i<k;i++){

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

{
"rows": 200,
"fields": [
{
"name": "ID",
"type": "rand:char",
"length": 5
},
{
"name": "First Name",
hello world! first gist from my sublime

#Enhance my screen

.screenrc

# Here comes the pain...
 caption always "%{=b dw}:%{-b dw}:%{=b dk}[ %{-b dw}%{-b dg}$USER%{-b dw}@%{-b dg}%H %{=b dk}] [ %= %?%{-b dg}%-Lw%?%{+b dk}(%{+b dw}%n:%t%{+b dk})%?(%u)%?%{-b dw}%?%{-b dg}%+Lw%? %{=b dk}]%{-b dw}:%{+b dw}:"

 backtick 2 5 5 $HOME/scripts/meminfo
 hardstatus alwayslastline "%{+b dw}:%{-b dw}:%{+b dk}[%{-b dg} %0C:%s%a %{=b dk}]-[   %{-b dw}Load%{+b dk}:%{-b dg}%l %{+b dk}] [%{-b dg}%2`%{+b dk}] %=[ %{-b dg}%1`%{=b dk} ]%{-b dw}:%{+b dw}:%<"

 sorendition "-b dw"

enhance your screen

Create a file named .screenrc under your home folder.

# Here comes the pain...

 caption always "%{=b dw}:%{-b dw}:%{=b dk}[ %{-b dw}%{-b dg}$USER%{-b dw}@%{-b dg}%H %{=b dk}] [ %= %?%{-b dg}%-Lw%?%{+b dk}(%{+b dw}%n:%t%{+b dk})%?(%u)%?%{-b dw}%?%{-b dg}%+Lw%? %{=b dk}]%{-b dw}:%{+b dw}:"

backtick 2 5 5 $HOME/scripts/meminfo
@jiananlu
jiananlu / gist:9258032
Last active May 11, 2023 00:14
upgrade openwrt kernel and reinstall all packages manual

upgrade the system

Make sure you can ssh to the router by root and type in the command:

cd /tmp
wget http://downloads.openwrt.org/snapshots/trunk/ar71xx/openwrt-ar71xx-generic-mw4530r-v1-squashfs-sysupgrade.bin
sysupgrade -v openwrt-ar71xx-generic-mw4530r-v1-squashfs-sysupgrade.bin
@jiananlu
jiananlu / gist:5854437
Last active December 18, 2015 22:28
Home inspection report of 2828 welk

Moisture/water leakage

  • fungus damage in some spots
  • moisture damage to front, side, back
  • water stain of roof sheathing and fascia board
  • previous leakage in kitchen area
  • abandoned water supply line for fridge

Exterial areas that might need fix

@jiananlu
jiananlu / gist:5845829
Last active December 18, 2015 21:09
Homes in Fremont Area

Northgate

Relative cheap; [Warwick Elementary-9.0][1]

  • [2828 Welk Cmm][2] $755,000 2046sqft (130-430pm) => 非常好,但是没有high ceiling,看的人很多,估计会贵
  • [4345 Calypso Ter Fremont, CA 94555][3] $699,998 1826sqft (open 1pm-4pm) => 有神奇garden,有点屌丝
  • [3658 BOBWHITE Ter Fremont, CA 94555][4] $549,900 1607sqft (no open)
  • 4112 Hansen Ave, $655 1865 (open 1pm-4pm) => 便宜,还挺大,外面看很炫,装修一般,离bart近