Skip to content

Instantly share code, notes, and snippets.

View henryscala's full-sized avatar

henryscala henryscala

  • China
View GitHub Profile
@henryscala
henryscala / wireshark_SIP.py
Created November 24, 2015 05:01
ONE-OFF script to split SIP messages captured via wireshark, and group the messages by call-id.
import re
import collections
from collections import defaultdict
from collections import namedtuple
fileName='all-packet.txt'
fileNameOut = fileName+"out.txt"
file = open(fileName)
@henryscala
henryscala / iBash_setup.md
Last active December 14, 2015 04:19
install virtual BOX, CentOS, Anaconda, iBash

This article describes my steps to setup the iBash environment in my Windows 7 OS.

install virtual box

create a VM and install CentOS

  • While installing, just select Linux, instead of Redhat
  • Rember to select Desktop CentOS in one of the step, instead of using the default minimal CentOS, to use the GUI
  • Install Enhance functions to the VM(Just click the menu item of the virtual box)
  • Enable bi-directionaly Clipboard between VM and the Host OS.
  • Specify a Share Folder to transfer to/from CentOS
@henryscala
henryscala / goserver.go
Created January 26, 2016 15:04
A simple http server implemented in golang, can be used to serve static contents in a directory.
package main
import (
"flag"
"fmt"
"net/http"
)
const ()
@henryscala
henryscala / dumpbuffer.c
Created February 1, 2016 02:16
a c function to dump the buffer in hex
#include <stdio.h>
char hexstr[]="0123456789ABCDEF";
void hexdump(char* buf, int len) {
int i;
for(i=0;i<len;++i) {
int hi=(buf[i] >> 4) & 0x0f;
int lo=(buf[i] & 0x0f);
printf("%c%c,",hexstr[hi],hexstr[lo]);
}
@henryscala
henryscala / force_coredump.c
Created February 23, 2016 02:24
to force a coredump
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
/* this program tries to generate a crash. A prove of concept program. */
/* as per my test, crash may be created in other diectory, but not in my $HOME directory, I don't know why yet */
void function1() {
@henryscala
henryscala / sum_subset.go
Created March 11, 2016 08:38
using combination to get a subset of a set of numbers and then calculate whether the sum of the subset equals a specific target
package main
import (
"fmt"
"math/big"
"os"
)
var target int = 23813
var totalNum int = 69
@henryscala
henryscala / yml2csv.py
Created May 25, 2016 06:50
Program to convert yaml to csv. only make sense for me.
input_lines = []
with open("account.yml",mode='r',encoding='utf-8') as f:
input_lines = f.readlines()
input_lines = [line.strip() for line in input_lines if line.strip() != '']
entries = []
entry = []
@henryscala
henryscala / dir_walk.py
Created December 8, 2016 09:32
a script to walk a dir, and filter each line of the files in that dir, and do something if the line fulfills some criteria
# a script to walk a dir, and filter each line of the files in that dir, and do something if the line fulfills some criteria
import os
import os.path
script_dir = r"<script-dir>"
dir_to_walk = r"<dir-to-walk>"
os.getcwd()
os.chdir(script_dir)
os.getcwd()
classes_file_name = os.path.join(script_dir, "<somefile.txt>" )
with open(classes_file_name) as file:
@henryscala
henryscala / indent.py
Created December 8, 2016 10:05
a script to indent lines of text based on given start tag and end tag
# a script to indent lines of text based on given start tag and end tag
import os
import os.path
src_file = r"<sourcefile>"
dst_file = r"<destination-file>"
with open(src_file,"rb") as srcfile:
content = srcfile.read()
@henryscala
henryscala / cpp_check_result_analysis.jl
Created January 5, 2018 08:29
a one-off script for cpp check result analysis
#!/usr/bin/env julia
function usage_exit()
println("$PROGRAM_FILE <cpp-check-result-file-name>")
exit()
end
#if length(ARGS) != 1
# usage_exit()
#end