Skip to content

Instantly share code, notes, and snippets.

View jeromesun14's full-sized avatar

Sun Yongfeng jeromesun14

View GitHub Profile
#!/bin/bash
PORTS=`sed '1d' port_config.ini | awk '{print $1}'`
j=1
for i in ${PORTS[@]} ;
do
#echo "$i"
ip addr $1 $j.0.0.1/24 dev $i
#!/usr/bin/env python
import sys
from scapy.all import *
from scapy.utils import wrpcap
def IP2Int(ip):
print ip
o = list(map(int, ip.split('.')))
print o[0]
@jeromesun14
jeromesun14 / git_branch.sh
Created April 6, 2018 14:15 — forked from dciccale/git_branch.sh
Bash script to get the current git branch and last commit
#!/usr/bin/env bash
# checks if branch has something pending
function parse_git_dirty() {
git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo "*"
}
# gets the current git branch
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
@jeromesun14
jeromesun14 / Makefile
Created January 9, 2018 17:12 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@jeromesun14
jeromesun14 / netpps.sh
Created July 13, 2017 08:29 — forked from joemiller/netpps.sh
shell: quick linux scripts for showing network bandwidth or packets-per-second
#!/bin/bash
if [ -z "$1" ]; then
echo
echo usage: $0 network-interface
echo
echo e.g. $0 eth0
echo
echo shows packets-per-second
@jeromesun14
jeromesun14 / getrss.c
Created June 1, 2016 10:01
Linux C get maximum resident set size
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
static void getrss(void)
{
FILE *pp = NULL;
char buf[128];
char cmd[128];
@jeromesun14
jeromesun14 / sslocal
Last active June 2, 2016 07:35 — forked from Jimmy-Xu/sslocal
/etc/init.d/sslocal
#!/bin/bash
set -e
### BEGIN INIT INFO
# Provides: sslocal
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
@jeromesun14
jeromesun14 / redis_serialize_mem_test.c
Created May 20, 2016 12:26
比较 redis hash set 与 set 序列化对象耗费的内存
#include <string.h>
#include <stdio.h>
#include "hiredis.h"
struct test {
int item1;
int item2;
int item3;
int item4;
int item5;
@jeromesun14
jeromesun14 / redis_serialize_mem_test.py
Last active May 20, 2016 12:24
比较 redis hash set 与 set 序列化对象耗费的内存
import redis
import pickle
class ser:
item1 = 1
item2 = 2
item3 = 3
item4 = 4
item5 = 5
item6 = 6
@jeromesun14
jeromesun14 / redis_serialize.c
Last active May 20, 2016 09:17
Linux c redis 序列化/反序列化
#include <string.h>
#include <stdio.h>
#include "hiredis.h"
struct test {
int a;
char b[4];
int c;
}