Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am dafang on github.
  • I am dafang (https://keybase.io/dafang) on keybase.
  • I have a public key ASCOurYfXFBpCGOiQOyTzHzrFOeRF_2s-MCyAuQcaIbRZgo

To claim this, I am signing this object:

@dafang
dafang / perf-flame-graph-notes.md
Created May 13, 2016 03:15 — forked from trevnorris/perf-flame-graph-notes.md
Quick steps of how to create a flame graph using perf

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel.kptr_restrict=0
# May also have to do the following:
# (additional reading http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar )
sudo sysctl kernel.perf_event_paranoid=0
@dafang
dafang / aliyun.sources.list
Created December 22, 2015 00:59 — forked from cloverstd/aliyun.sources.list
阿里云 ubuntu 14.04 镜像
# deb http://mirrors.aliyun.com/ubuntu trusty main restricted
# deb http://mirrors.aliyuncs.com/ubuntu trusty main restricted
# deb http://mirrors.aliyun.com/ubuntu trusty-updates main restricted
# deb http://mirrors.aliyuncs.com/ubuntu trusty-updates main restricted
# deb http://security.ubuntu.com/ubuntu trusty-security main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.aliyun.com/ubuntu trusty main restricted
/**
* 对公众平台发送给公众账号的消息加解密示例代码.
*
* @copyright Copyright (c) 1998-2014 Tencent Inc.
*/
// ------------------------------------------------------------------------
/**
* 针对org.apache.commons.codec.binary.Base64,
#!/bin/bash
packlist=`mktemp`
git gc 2>&1 |
grep '^warning: packfile .* cannot be accessed$' |
cut -d' ' -f3 |
sort -u > $packlist
packs_count=`wc -l < $packlist`
temp=`mktemp`

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

@dafang
dafang / ChunkedInputStream.java
Last active December 15, 2015 06:49
Android: ChunkedInputStream
/*
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java $
* $Revision: 569843 $
* $Date: 2007-08-26 10:05:40 -0700 (Sun, 26 Aug 2007) $
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@dafang
dafang / gist:4369774
Created December 24, 2012 16:06
How to expose local ports via server
  • Change server sshd_config to allow client binding artitray network interface

    GatewayPorts yes
    
  • Use -R [bind_address:]port:host:hostport to setup port forwarding. bind_address should be 0.0.0.0, which means binding on all network addresses. Following example forward local ports 3000 to server 8080, and local ports 22 to server 2222. So others can open http://server:8080 to access your web server, and ssh -p 2222 server to log into your local machine.

ssh -R 0.0.0.0:8080:localhost:3000 -R 0.0.0.0:2222:localhost:22 server

@dafang
dafang / README.md
Created December 24, 2012 16:03 — forked from doitian/README.md
  • Change server sshd_config to allow client binding artitray network interface

    GatewayPorts yes
    
  • Use -R [bind_address:]port:host:hostport to setup port forwarding. bind_address should be 0.0.0.0, which means binding on all network addresses. Following example forward local ports 3000 to server 8080, and local ports 22 to server 2222. So others can open http://server:8080 to access your web server, and ssh -p 2222 server to log into your local machine.

    ssh -R 0.0.0.0:8080:localhost:3000 -R 0.0.0.0:2222:localhost:22 server
    
@dafang
dafang / Castle.xml
Created December 23, 2012 14:31 — forked from bemasher/Castle.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Data>
<Series>
<id>83462</id>
<Actors>|Nathan Fillion|Stana Katic|Molly C. Quinn|Jon Huertas|Seamus Dever|Tamala Jones|Susan Sullivan|Ruben Santiago-Hudson|Monet Mazur|</Actors>
<Airs_DayOfWeek>Monday</Airs_DayOfWeek>
<Airs_Time>10:00 PM</Airs_Time>
<ContentRating>TV-PG</ContentRating>
<FirstAired>2009-03-09</FirstAired>
<Genre>|Drama|</Genre>