Skip to content

Instantly share code, notes, and snippets.

Avatar

Allen.YL allenyllee

View GitHub Profile
View iptables-ipset-limiter.sh
#!/bin/bash
# Assumming brute force attack has constant hit rate, says X hit per Y seconds, across enough long time range, says T seconds.
# Every time we block a suspisuous ip for a period of time and unblock it,
# we should wait T seconds to see if there were further attack with rate X/Y hit/seconds.
# If this ip still has attack action during T seconds with hit rate X/Y, send it to block list which has doubled block time.
#
L1_period=300
L2_period=3600
L1_hit_upper=12
@allenyllee
allenyllee / pandas-to-excel.py
Created Dec 18, 2020 — forked from ojdo/pandas-to-excel.py
From Pandas to Excel using Openpyxl
View pandas-to-excel.py
import pandas as pd
from io import StringIO
from openpyxl.formatting.rule import ColorScaleRule
from openpyxl.styles import Alignment, Font, NamedStyle
from openpyxl.utils import get_column_letter
df = pd.read_csv(StringIO("""\
alpha beta gamma
2000-01-01 -0.173215 0.119209 -1.044236
2000-01-02 -0.861849 -2.104569 -0.494929
@allenyllee
allenyllee / defaultdict.py
Last active Nov 27, 2019 — forked from ohe/defaultdict.py
emulation of collections.defaultdict
View defaultdict.py
"""
emulation of collections.defaultdict
"""
class defaultdict(dict):
"""
emulation of collections.defaultdict
to test, run python defaultdict.py -v
>>> dd = defaultdict(list)
View add_cron_jobs.sh
#!/bin/bash
# automatically repair filesystems with inconsistencies during boot
#sudo cp rcS /etc/default/
# automatically repair filesystems with inconsistencies during boot
# linux - What should I do to force the root filesystem check (and optionally a fix) at boot? - Unix & Linux Stack Exchange
# https://unix.stackexchange.com/questions/400851/what-should-i-do-to-force-the-root-filesystem-check-and-optionally-a-fix-at-bo/400927#400927
sudo sed -i 's|GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX="fsck.repair=yes"|' /etc/default/grub
sudo update-grub
View list_dns.sh
#!/bin/bash
# Command-line to list DNS servers used by my system - Ask Ubuntu
# https://askubuntu.com/questions/152593/command-line-to-list-dns-servers-used-by-my-system
DEVICE_NAME="eno1"
# get interface name
interface=$(nmcli device | grep "$DEVICE_NAME" | cut -d' ' -f1)
@allenyllee
allenyllee / install_tools.sh
Last active Jul 24, 2021
mount vhdx in linux
View install_tools.sh
#!/bin/bash
# install qemu utils
sudo apt install qemu-utils
# install nbd client
sudo apt install nbd-client
@allenyllee
allenyllee / dynupdate.sh
Last active Sep 2, 2018 — forked from kylegibson/dynupdate.sh
Simple bash script to update a dyndns host entry
View dynupdate.sh
#!/bin/bash
HOST=foo.example.com
USER=
PASS=
IPADDR=$(curl -s https://api.ipify.org)
RESULT=$(wget -q -O- "https://$USER:$PASS@members.dyndns.org/nic/update?hostname=$HOST&myip=$IPADDR&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG")
@allenyllee
allenyllee / arxiv-pdf-to-abstract-url-bookmarklet.js
Last active May 29, 2018
If you open an pdf url of arxiv paper, then wants to jump to its abstract page, using this javascript as bookmarklet. https://bookmarkify.it/9634
View arxiv-pdf-to-abstract-url-bookmarklet.js
javascript:(function()%7Bvar%20str%20%3D%20location.href%3Bstr%20%3D%20str.replace(%2F%5C.pdf%2Fg%2C%20%22%22)%3Bstr%20%3D%20str.replace(%2Fpdf%2Fg%2C%20%22abs%22)%3Blocation.href%20%3D%20str%7D)()
@allenyllee
allenyllee / uuid.sh
Created Jan 12, 2018 — forked from markusfisch/uuid.sh
Generate a random UUID in bash
View uuid.sh
#!/usr/bin/env bash
# Generate a pseudo UUID
uuid()
{
local N B C='89ab'
for (( N=0; N < 16; ++N ))
do
B=$(( $RANDOM%256 ))
@allenyllee
allenyllee / Convolutional Arithmetic.ipynb
Created Dec 21, 2017 — forked from akiross/Convolutional Arithmetic.ipynb
Few experiments on how convolution and transposed convolution (deconvolution) should work in tensorflow.
View Convolutional Arithmetic.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.