Skip to content

Instantly share code, notes, and snippets.

View KaiserKatze's full-sized avatar
🎯
Focusing

KaiserKatze KaiserKatze

🎯
Focusing
  • MiGo Future Tech Group
  • Chongqing, China
View GitHub Profile
@KaiserKatze
KaiserKatze / logipt.sh
Last active July 10, 2019 13:55
Logging all packets handled by iptables, intended for Debian/Ubuntu OS
#!/bin/bash
IPT=iptables
del() {
table=$1
$IPT -t $table -F
$IPT -t $table -X
$IPT -t $table -Z
}
/*
* Traverse file system
*/
private int calcDepth(string path) => System.IO.Path.GetFullPath(path).Split(System.IO.Path.DirectorySeparatorChar).Length;
public void scanDirectory(string path, int maxDepth=1)
{
// assert `path` is directory
System.Diagnostics.Debug.Assert(System.IO.Directory.Exists(path));
#!/bin/bash
#
# Generated iptables firewall script for the Linux 2.4 kernel
# Script generated by Easy Firewall Generator for IPTables 1.15
# copyright 2002 Timothy Scott Morizot
#
# Redhat chkconfig comments - firewall applied early,
# removed late
# chkconfig: 2345 08 92
# description: This script applies or removes iptables firewall rules
@KaiserKatze
KaiserKatze / .gitconfig
Created June 28, 2019 07:00
Personal Git configuration
[user]
name = KaiserKatze
email = [email protected]
[core]
editor = vim
autocrlf = true
whitespace = trailing-space,space-before-tab
alias = adda
[color]
ui = true
# Cook iptables
apt-get -y install build-essential automake libtool
git clone git://git.netfilter.org/iptables
cd iptables
./autogen.sh
./configure
make
make install
@KaiserKatze
KaiserKatze / get_ext_ip.sh
Last active June 29, 2019 13:38
Get external IP of your machine
#!/bin/bash
printerr() { echo "$@" 1>&2; }
get_host_ip() {
adapters=$(ip -4 a | awk '/inet/{print $2}' | cut -d'/' -f1)
for adapter in $adapters;
do
# exclude address of loopback interface
if [ "$adapter" == 127.0.0.1 ];
@KaiserKatze
KaiserKatze / angle.py
Created February 17, 2019 01:54
Angle calculation
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Angle:
val = 0
def __init__(self, x, y, z):
self.val = ((x * 60) + y) * 60 + z
self.x = x
@KaiserKatze
KaiserKatze / .travis.yml
Last active December 1, 2018 16:23
Install CPython 3.7 on Travis CI
# Travis CI configuration
language: generic
sudo: required
dist: trusty
# DO NOT CACHE DEBIAN PACKAGES
before_install:
- pwd
- git clone --quiet --branch 3.7 --depth 1 --no-tags -- https://github.com/python/cpython cpython-3.7
- cd cpython-3.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Solution:
def __init__(self):
self.array = None
def create_array(self, array_length):
result = [0] * array_length;
@KaiserKatze
KaiserKatze / spider.ts
Created November 10, 2018 00:35
Scrape data from bilibili.com
function extractTotalViewFromHtmlResponse(response) {
// TODO
}
// test mid=299999920
// test mid=6290510
export class User {
User(mid: number) {
}