Skip to content

Instantly share code, notes, and snippets.

View cuiwm's full-sized avatar
🎯
Focusing

cuiwm cuiwm

🎯
Focusing
  • UK
View GitHub Profile
#!/usr/bin/python
import glob
import os
import sys
from PIL import Image
EXTS = 'jpg', 'jpeg', 'JPG', 'JPEG', 'gif', 'GIF', 'png', 'PNG'
@cuiwm
cuiwm / ios_rvictl_ios_wireshark_tcpdump_packet
Created August 10, 2017 07:10
capture net packet on real iphone
#!/bin/sh
if [ $2 == "start" ]
then
rvictl -s $1
open /Applications/Wireshark.app
elif [ $2 == "stop" ]
then
rvictl -x $1
else
echo "$0 [iOSDeviceIdentifier] [start|stop]"
mkfifo /tmp/fifo;
ssh-keygen;
ssh-copyid root@remotehostaddress;
sudo ssh root@remotehost "tshark -i eth1 -f 'not tcp port 22' -w -" > /tmp/fifo &;
sudo wireshark -k -i /tmp/fifo;
ssh root@host "tcpdump -i any -s0 -U port $1 -w -" | /Applications/Wireshark.app/Contents/MacOS/Wireshark -k -i -
@cuiwm
cuiwm / trace.go
Created June 8, 2018 03:38
runtime function
package main
import (
"fmt"
"runtime"
)
func trace2() {
pc := make([]uintptr, 15)
n := runtime.Callers(2, pc)
@cuiwm
cuiwm / Makefile_go_version
Created June 8, 2018 10:24
golang build with version info
SFILE:=$(wildcard *.go)
VERSION=`git describe --tags`
BUILD=`date +%F_%T%z`
TAGETFILE=uploadTool
LDFLAGS_DEBUG=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}"
LDFLAGS_REL=-ldflags "-w -s -X main.Version=${VERSION} -X main.Build=${BUILD}"
all: mac
@echo ${BUILD} ${VERSION} $(SFILE)
@cuiwm
cuiwm / yum_install_openresty.sh
Last active June 11, 2018 05:59
yum_install_openresty
bash -c "echo 7 > /etc/yum/vars/releasever" && yum install -y yum-utils && sudo yum-config-manager --add-repo https://openresty.org/package/rhel/openresty.repo && sudo yum install -y openresty && command -v opentresty
yum install -y yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/rhel/openresty.repo
sudo yum install -y openresty
# change info about os version
vi /etc/yum.repos.d/openresty.repo
sudo yum install openresty
#python -c 'import yum, pprint; yb = yum.YumBase(); pprint.pprint(yb.conf.yumvar, width=1)'
# 全局环境变量设置
export GOPATH=/users/choe
# 局部环境变量设置,必须是前置条件
ok1:export GOPATH=/users/choe/github/en/code/
ok1:
@echo $(GOPATH)
# 错误的环境变量的设置
error:
export GOPATH=/users/choe/github/
on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as string
set the open_target_file to open for access file target_file with write permission
if append_data is false then set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
#
# It will:
#
# deal with files with spaces, newlines, leading dashes, and other funniness
# handle an unlimited number of files
# won't repeatedly overwrite your backup.tar.gz like using tar -c with xargs will do when you have a large number of files
# Also see:
#
# GNU tar manual http://www.gnu.org/software/tar/manual/tar.html#SEC107
# How can I build a tar from stdin?, searc