Skip to content

Instantly share code, notes, and snippets.

@herry13
herry13 / root-ro
Created September 21, 2017 06:16 — forked from niun/root-ro
Read-only Root-FS with overlayfs for Raspian
#!/bin/sh
#
# Read-only Root-FS for Raspian
#
# Modified 2015 by Pascal Rosin to work on raspian-ua-netinst with
# overlayfs integrated in Linux Kernel >= 3.18.
#
# Originally written by Axel Heider (Copyright 2012) for Ubuntu 11.10.
# This version can be found here:
# https://help.ubuntu.com/community/aufsRootFileSystemOnUsbFlash#Overlayfs
@herry13
herry13 / japronto_vs_tornado-static_file.md
Last active March 1, 2018 03:52
Japronto vs Tornado performances on static file
  • Python, version 3.6.2, macOS 10.12.6 (from Brew)

  • MacBook Pro 2016, Intel i5 3.1GHz, mem 16GB

  • Content of main.html

    <html>
      <body>
        <h1>Hello World!</h1>
//
// To compile:
// gcc -Wall -pedantic -O3 -fomit-frame-pointer -o agent udp.c
//
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
@herry13
herry13 / remove_transitive_edges.c
Last active June 2, 2017 17:19
Algorithm to remove transitive edges on directed graphs
// `M` is a N x N adjacency matrix.
// `M[0][2] != 0` means that there is a directed edge from node 0 to 2.
void remove_transitive_edges(int ** M, int N) {
// transform to path matrix
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (i == j || M[j][i] == 0) continue;
for (int k = 0; k < N; k++) {
if (M[j][k] == 0) M[j][k] = M[i][k];
}
@herry13
herry13 / .bash_profile
Last active July 6, 2018 00:06
bash profile for macOS
PS1=$'\\033[38;5;141m\A\\033[0m \\033[38;5;160m\xe3\x81\xb8\xe3\x83\xaa\\033[0m\\033[38;5;178m@\\033[0m\\033[38;5;120m\h\\033[0m \\033[38;5;75m\\w\\033[0m\n\xe2\x9e\xa5 '
alias ls='ls -G'
@herry13
herry13 / .vimrc
Created February 22, 2017 17:20
VIM config file
filetype plugin indent on
set encoding=utf-8
set tabstop=2
set expandtab
set autoindent
set shiftwidth=2
set softtabstop=2
set number
set ruler
@herry13
herry13 / arp-packet-scanner.go
Created February 17, 2017 02:32
Catching ARP packet in Go
package main
import (
"fmt"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
"log"
"net"
)
@herry13
herry13 / bootable-usb-windows.sh
Created May 13, 2016 15:10
Create a bootable USB pen drive of Windows OS ISO
#!/bin/bash
# create a GPT partition table and a FAT32 partition
sudo sgdisk --zap-all /dev/sdb
sudo sgdisk --new=1:0:0 --typecode=1:ef00 /dev/sdb
sudo mkfs.vfat -F32 -n GRUB2EFI /dev/sdb1
# mount the partition
sudo mount -t vfat /dev/sdb1 /mnt -o uid=1000,gid=1000,umask=022
@herry13
herry13 / docker-remove-offline-containers
Created June 9, 2015 10:47
Remove all offline docker containers
#!/bin/bash
sudo docker rm $(sudo docker ps -a | grep 'Exited' | awk "{print \$1"})