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 / digest.py
Created October 20, 2018 07:36
Simple digest algorithm demonstration
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import itertools
def simple_digest(input_string):
chars = {}
for c in input_string:
chars[c] = chars.get(c, 0) + 1
items = iter(sorted(chars.items()))
@KaiserKatze
KaiserKatze / bisect.sh
Last active November 6, 2018 12:04
Continuous Integration Toolkit (Travis CI)
#!/bin/bash
which cat &> /dev/null && \
cat << EOF
################################################################################
# AutoBisect Procedure #
# ---------------------------------------------------------------------------- #
# Project: Continuous Integration Toolkit (Travis CI) #
# Author: KaiserKatze #
# #
@KaiserKatze
KaiserKatze / deploy.sh
Last active April 12, 2021 12:25
Server initialization script for newly created Vultr VPS instances
#!/bin/bash
cat << EOF
#=============================================================================#
# Startup Boot Script #
# --------------------------------------------------------------------------- #
# Platform : Vultr VPS (Debian 9) #
# Author : KaiserKatze <[email protected]> #
# --------------------------------------------------------------------------- #
# This startup script is saved to `/tmp/firstboot.exec` after execution. #
@KaiserKatze
KaiserKatze / inquisitor.py
Created November 5, 2018 09:00
Purge heresy and heretics
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Project: Inquisitor(异端审判)
Author: KaiserKatze
"""
import requests
import datetime
@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) {
}
#!/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 / .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
@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 / 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 ];
# 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