Skip to content

Instantly share code, notes, and snippets.

View cuiwm's full-sized avatar
🎯
Focusing

cuiwm cuiwm

🎯
Focusing
  • UK
View GitHub Profile
@cuiwm
cuiwm / Makefile
Created March 1, 2017 02:52 — forked from kwk/Makefile
Compiling with Address Sanitizer (ASAN) with CLANG and with GCC-4.8
.PHONY: using-gcc using-gcc-static using-clang
using-gcc:
g++-4.8 -o main-gcc -lasan -O -g -fsanitize=address -fno-omit-frame-pointer main.cpp && \
ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=$(shell which llvm-symbolizer) ./main-gcc
using-gcc-static:
g++-4.8 -o main-gcc-static -static-libstdc++ -static-libasan -O -g -fsanitize=address -fno-omit-frame-pointer main.cpp && \
ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=$(shell which llvm-symbolizer) ./main-gcc-static
--[[ config
root = "./"
listen = "127.0.0.1:8786"
redisaddr = "127.0.0.1:6379[1]"
dbfile = root .. "backup.db"
thread = 4
logger = nil
harbor = 1
@cuiwm
cuiwm / mysql_tcpdump.sh
Created September 11, 2018 10:45 — forked from ffeast/mysql_tcpdump.sh
Mysql traffic tcpdump one-liner
# a handy one-liner to print out sql queries if you wouldn't like to enable
# queries logging in mysql server itself
tcpdump -i lo -s 0 -l -w - dst port 3306 | strings | perl -e '
while(<>) { chomp; next if /^[^ ]+[ ]*$/;
if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER)/i) {
if (defined $q) { print "$q\n\n"; }
$q=$_;
} else {
$_ =~ s/^[ \t]+//; $q.=" $_";
}
@cuiwm
cuiwm / redisjobqueue.go
Created October 30, 2018 09:53 — forked from brunocassol/redisjobqueue.go
A simple demo implementation of a Redis job queue in Go inspired on http://stackoverflow.com/a/34754632
package main
// A simple demo implementation of a Redis job queue in Go inspired on http://stackoverflow.com/a/34754632
// You'll need to get redis driver package in terminal with: go get -u gopkg.in/redis.v5
// Once it is running, Redis should look like: http://i.imgur.com/P4XlwlP.png
// Terminal should look like: http://i.imgur.com/AS2IIbP.png
// I have 4 days of Go programming experience, have mercy.
import (
"fmt"
@cuiwm
cuiwm / pstack-osx.sh
Created November 1, 2018 07:36 — forked from theirix/pstack-osx.sh
pstack for osx
#!/bin/sh
#
# Script prints gdb stack of the process with a specified pid
if [ -z $1 ]; then
echo "Usage: $0 pid"
exit 1
fi
PID=$1
@cuiwm
cuiwm / gist:56a4446cc24078d0cd1f032a40f3fb66
Created November 1, 2018 10:08 — forked from tobym/gist:3538214
My pwdx implementation for a mac
#!/bin/bash
lsof -a -p $1 -d cwd -n | tail -1 | awk '{print $NF}'
@cuiwm
cuiwm / pwdx_and_portpwdx_for_mac.bash
Created November 1, 2018 10:11 — forked from gerrard00/pwdx_and_portpwdx_for_mac.bash
pwdx for mac. Usage: pwx pid also portpwdx that finds the pwd for the process that owns a port. Usage: portpwdx port
function pwdx {
# note: NF is the number of columns, so $NF gives us the last column
lsof -a -p $1 -d cwd -n | tail -1 | awk '{print $1, "\t", $NF}'
}
function portpwdx {
# pid=$(lsof -i :5858 | tail -1 | perl -pe 's/[^\s]+\s+([^\s]+)\s.*/$1/')
pid=$(lsof -i :$1 | tail -1 | perl -pe 's/[^\s]+\s+([^\s]+)\s.*/$1/')
if [[ ! -z $pid ]]; then
echo $pid
@cuiwm
cuiwm / codesign_gdb.md
Created November 4, 2018 14:13 — forked from gravitylow/codesign_gdb.md
Codesign gdb on macOS

If you are getting this in gdb on macOS while trying to run a program:

Unable to find Mach task port for process-id 57573: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
  1. Open Keychain Access
  2. In menu, open Keychain Access > Certificate Assistant > Create a certificate
  3. Give it a name (e.g. gdbc)
@cuiwm
cuiwm / codesign_gdb.md
Created November 4, 2018 14:13 — forked from hlissner/codesign_gdb.md
Codesign gdb on OSX

Note: these instructions are for pre-Sierra MacOS. Sierra Users: see https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d by @gravitylow.

If you are getting this in gdb on OSX while trying to run a program:

Unable to find Mach task port for process-id 57573: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
  1. Open Keychain Access
@cuiwm
cuiwm / GitConfigHttpProxy.md
Created November 12, 2018 06:59 — forked from evantoli/GitConfigHttpProxy.md
Configure Git to use a proxy

Configure Git to use a proxy

##In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like: