key bindings | explanation |
---|---|
M-x shell-command-on-region(M-|) | send current region to shell |
C-u M-! <shell-command> | insert command result into buffer |
C-u M-| <shell-command> | current region is sent to the shell-command and replaced with the result |
M-^ | join line |
M-g g | jump to the specified line |
M-x apply-macro-to-region-lines | apply macro to region lines |
C-u C-space(or C-u C-@) | go back to previous line position |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function print_lua_table (lua_table, indent) | |
indent = indent or 0 | |
for k, v in pairs(lua_table) do | |
if type(k) == "string" then | |
k = string.format("%q", k) | |
end | |
local szSuffix = "" | |
if type(v) == "table" then | |
szSuffix = "{" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* ls *Page.h | while read one; do mv "$one" "$(echo "$one" | perl -ne 'print join("_", split(/(?=[A-Z])/))')"; done; | |
* for i in `ls *.t`; do perl -pi.bak -e 'print "\$ENV{TEST_NGINX_CHECK_LEAK} = 1;\n" if /HUP/' $i; done | |
* sudo watch -n 5 pkill -USR1 (-n -x) unxz | |
* TERM=xterm-256color emacs -nw | |
* for i in `seq 1 254` ; do arping -I enp9s0 -c 1 172.16.2.$i | grep reply ; done | |
* sudo tcpdump -i enp3s0 -nt -s 500 port domain | |
* du -sh .[^.]* | |
* To find all files modified in the last 24 hours (last full day) in a particular specific directory and its sub-directories: | |
* -> find /directory_path -mtime -1 -ls | |
* find . -mtime 0 |
- 管道是传递信息的手段而已,高级的功能都是通过在机制上设计协议完成的。要设计复杂的协议多看看状态机、编译原理一类的资料。计算机的奥妙就在于用最简洁的方式纪录最复杂的信息。在一个管道上控制双方的行为尤其需要这种技巧。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright 2010 Eric Ryan Harrison <[email protected]> | |
# Inspired by: | |
# http://daniel.haxx.se/blog/2010/12/14/add-latency-to-localhost/ | |
if [ -n "$1" ] | |
then | |
if [ "$1" = "off" ] | |
then | |
tc qdisc del dev lo root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Capture::Tiny 'tee'; | |
my $output = tee { system( "some command" ) }; | |
# http://stackoverflow.com/questions/634508/how-can-i-send-perl-output-to-a-both-stdout-and-a-variable | |
---- | |
use IPC::System::Simple qw(capture); | |
# Capture output into $result and throw exception on failure | |
my $result = capture("some_command"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Collection; | |
import java.util.SortedMap; | |
import java.util.TreeMap; | |
// From: http://www.tom-e-white.com/2007/11/consistent-hashing.html | |
public class ConsistentHash<T> { | |
private final HashFunction hashFunction; | |
private final int numberOfReplicas; | |
private final SortedMap<Integer, T> circle = | |
new TreeMap<Integer, T>(); |
This started out as a fork of the progress bar class which I first hosted on ActiveState Code.
It builds a text progress bar and displays it with the draw()
method.
The methods are showcased below:
from progressBar import progressBar
# Initiates the progessBar
prog = progressBar(maxValue = 50)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
## 使い方: $ perl simple-fork-httpd.pl [ポート番号(デフォルト8080)] | |
use strict; | |
use warnings; | |
use encoding 'utf8'; | |
use Encode; | |
use Socket; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/luajit | |
local M = {} | |
local ffi = require "ffi" | |
ffi.cdef[[ | |
/* | |
LZ4_compress() : | |
isize : is the input size. Max supported value is ~1.9GB | |
return : the number of bytes written in buffer dest |
OlderNewer