Skip to content

Instantly share code, notes, and snippets.

View allenyllee's full-sized avatar

Allen.YL allenyllee

View GitHub Profile
This file has been truncated, but you can view the full file.
2021-08-05T11:00:33.049Z INFO Configuration loaded {"Location": "/app/config/config.yaml"}
2021-08-05T11:00:33.059Z INFO Operator email {"Address": "...."}
2021-08-05T11:00:33.059Z INFO Operator wallet {"Address": "...."}
2021-08-05T11:00:34.935Z INFO Telemetry enabled {"instance ID": "15ZiPFXywuYhVi53kn5Ki2oujqBfdybVt54i7uTTPgUQJpdaCg"}
2021-08-05T11:00:35.325Z INFO db.migration.53 Add address to satellites, inserts stefan-benten satellite into satellites db
2021-08-05T11:00:35.555Z INFO db.migration Database Version {"version": 53}
2021-08-05T11:00:36.620Z INFO preflight:localtime start checking local system clock with trusted satellites' system clock.
2021-08-05T11:00:37.742Z INFO preflight:localtime local system clock is in sync with trusted satellites' system clock.
2021-08-05T11:00:37.742Z INFO bandwidth Performing bandwidth usage rollups
2021-08-05T11:00:37.742Z INFO Node 15ZiPFXywuYhVi53kn5Ki2oujqBfdybVt54i7uTTPgUQJpdaCg started
#!/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 December 18, 2020 10:50 — forked from ojdo/pandas-to-excel.py
From Pandas to Excel using Openpyxl
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 November 27, 2019 10:46 — forked from ohe/defaultdict.py
emulation of collections.defaultdict
"""
emulation of collections.defaultdict
"""
class defaultdict(dict):
"""
emulation of collections.defaultdict
to test, run python defaultdict.py -v
>>> dd = defaultdict(list)
@allenyllee
allenyllee / add_cron_jobs.sh
Last active December 18, 2018 02:18
crontab jobs
#!/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
#!/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 April 14, 2024 21:31
mount vhdx in linux
#!/bin/bash
# install qemu utils
sudo apt install qemu-utils
# install nbd client
sudo apt install nbd-client
@allenyllee
allenyllee / dynupdate.sh
Last active September 2, 2018 13:38 — forked from kylegibson/dynupdate.sh
Simple bash script to update a dyndns host entry
#!/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 November 18, 2022 17:41
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
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 January 12, 2018 14:57 — forked from markusfisch/uuid.sh
Generate a random UUID in bash
#!/usr/bin/env bash
# Generate a pseudo UUID
uuid()
{
local N B C='89ab'
for (( N=0; N < 16; ++N ))
do
B=$(( $RANDOM%256 ))