Skip to content

Instantly share code, notes, and snippets.

View crazyguitar's full-sized avatar
🎯
Focusing

CHANG-NING TSAI crazyguitar

🎯
Focusing
View GitHub Profile
" python file template "
au BufNewFile *.py 0r ~/.vim/templates/template.py
" Makefile template "
au BufNewFile Makefile,makefile 0r ~/.vim/templates/Makefile.temp
" c template "
au BufNewFile *.c 0r ~/.vim/templates/c.temp
" folding *.h comment"
@crazyguitar
crazyguitar / README.md
Created February 6, 2017 01:13 — forked from datagrok/README.md
What happens when you cancel a Jenkins job

When you cancel a Jenkins job

Unfinished draft; do not use until this notice is removed.

We were seeing some unexpected behavior in the processes that Jenkins launches when the Jenkins user clicks "cancel" on their job. Unexpected behaviors like:

  • apparently stale lockfiles and pidfiles
  • overlapping processes
  • jobs apparently ending without performing cleanup tasks
  • jobs continuing to run after being reported "aborted"
@crazyguitar
crazyguitar / docker-ovs.md
Created February 25, 2017 14:43 — forked from noteed/docker-ovs.md
Docker - Open vSwitch setup
@crazyguitar
crazyguitar / kcm-sample.c
Created December 6, 2017 01:11 — forked from peo3/kcm-sample.c
A sample program of KCM
/*
* A sample program of KCM.
*
* $ gcc -lbcc kcm-sample.c
* $ ./a.out 10000
*/
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@crazyguitar
crazyguitar / bpf.c
Created December 9, 2017 09:02 — forked from msantos/bpf.c
Example of using bpf to capture packets
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <err.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
@crazyguitar
crazyguitar / Makefile
Created December 12, 2017 02:08 — forked from llj098/Makefile
a sample tcp server runs in kernel
obj-m += tcp_svr_sample.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clea
1. Execute make first. This will result in a netlinkKernel.ko output among many others.
2. Execute $ gcc netlinkUser.c -o netlinkUser
3. Insert kernel module by :$ sudo insmod netlinkKernel.ko
4. Run ./netlinkUser to see message and run dmesg to see debug messages
5. Remove module by : $ sudo rmmod netlinkKernel
6. Finally make clean to remove output files.
@crazyguitar
crazyguitar / epoll.go
Created December 25, 2017 14:02 — forked from tevino/epoll.go
Golang example for using epoll
package main
import (
"fmt"
"net"
"os"
"syscall"
)
const (
@crazyguitar
crazyguitar / ecc.py
Created January 12, 2018 14:22 — forked from bellbind/ecc.py
[python]basics of elliptic curve cryptography
# Basics of Elliptic Curve Cryptography implementation on Python
import collections
def inv(n, q):
"""div on PN modulo a/b mod q as a * inv(b, q) mod q
>>> assert n * inv(n, q) % q == 1
"""
for i in range(q):
if (n * i) % q == 1:
@crazyguitar
crazyguitar / dns.md
Last active September 24, 2023 12:10
learn dns hard way

Domain Name Server (DNS)

Concept

  1. Two type of DNS network activities:
    1. lookup: DNS client queries a DNS server for information
    2. zone transfers: DNS server (the secondary server) requests from another DNS server (the primary server)
  2. DNS lookups are usualy executed usin UDP. (If some of data is lost in transit by UDP, the lookup will be redone using TCP)
  3. DNS sever uses well-known port 53 (UDP/TCP)
  4. Proxying characteristics of DNS: