Skip to content

Instantly share code, notes, and snippets.

View kingluo's full-sized avatar

jinhua luo kingluo

View GitHub Profile
@dmthuc
dmthuc / fcgi_cpp_example_with_official_fcgi_library.cpp
Last active September 18, 2024 21:23
Fast CGI example in C++ using official fcgi library
/*
using official fcgi++ library
Reference to fcgi protocol at https://tools.ietf.org/html/rfc3875#section-6.2.1
Build: g++ main.cpp -lfcgi++ -lfcgi -o main
Spawn: spawn-fcgi -a 127.0.0.1 -p 9105 -n -- main
*/
#include <iostream>
#include <string>
#include <thread>
@danielinux
danielinux / pcap_replay.py
Created October 11, 2016 21:34
replay a captured pcap stream
#!/usr/bin/python
from scapy.all import *
import time, sys
pkts = rdpcap(sys.argv[1])
clk = pkts[0].time
for p in pkts:
time.sleep(p.time - clk)
clk = p.time
sendp(p)
@kingluo
kingluo / cython.markdown
Last active November 27, 2017 11:07
python vs cython

case1:字节码执行

同样的python代码,经过cython编译后运行,一般情况下也比用python解释器运行要快。

因为python解释代码,本质上就是一个for/switch,对字节码的逐条执行,相比机器语言, 使得CPU无法预判指令分支,也破坏指令缓存的局部化。

p1.py

@mishurov
mishurov / syntax.s
Last active August 31, 2024 06:57
AT&T assembly syntax and IA-32 instructions
# --------
# Hardware
# --------
# Opcode - operational code
# Assebly mnemonic - abbreviation for an operation
# Instruction Code Format (IA-32)
# - Optional instruction prefix
# - Operational code
@mattratleph
mattratleph / vimdiff.md
Last active September 19, 2024 18:35 — forked from roothybrid7/vimdiff_cheet.md
vimdiff cheat sheet

vimdiff cheat sheet

##git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)

@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active September 22, 2024 08:03
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@the42
the42 / gist:1956518
Created March 2, 2012 07:34
GZip encoding for GO V1 using custom responsewriter
package main
import (
"compress/gzip"
"io"
"net/http"
"strings"
)
type gzipResponseWriter struct {