Skip to content

Instantly share code, notes, and snippets.

View allenyllee's full-sized avatar

Allen.YL allenyllee

View GitHub Profile
@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

Linux Driver Coding Notes

##I/O Device Driver

  • Character Driver
  • Block Driver
@allenyllee
allenyllee / reverse_sshfs.sh
Created November 8, 2017 03:53
reverse sshfs
#!/bin/bash
##/*
## * @Author: AllenYL
## * @Date: 2017-11-08 11:37:31
## * @Last Modified by: allen7575@gmail.com
## * @Last Modified time: 2017-11-08 11:37:31
## */
#
// import_json_appsscript.js
// https://gist.github.com/allenyllee/c764c86ed722417948fc256b7a5077c4
//
// Changelog:
// (Oct. 16 2019) tag: allenyllee-20191016
// 1. Fixed google script error: urlfetchapp - service invoked too many times https://stackoverflow.com/questions/10598179/google-apps-script-urlfetchapp-service-invoked-too-many-times
// (Jul. 16 2018) tag: allenyllee-20180716
// 1. Fixed the issue "If you try to query /arrayA[k]/arrayB[n]/arrayC[m]/.../member, you will always get /arrayA[k]/arrayB[k]/arrayC[k]/.../member."
// (Nov. 30 2017) tag: allenyllee-20171130
// 1. Add the ability to query array elements by using xpath like "/array[n]/member" where "n" is array index
@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 / ppt2pdf.ps1
Last active December 15, 2021 07:24 — forked from mp4096/ppt2pdf.ps1
Batch convert PowerPoint files to PDF with pen markups
# Batch convert all .ppt/.pptx files encountered in folder and all its subfolders
# The produced PDF files are stored in the invocation folder
#
# Adapted from http://stackoverflow.com/questions/16534292/basic-powershell-batch-convert-word-docx-to-pdf
# Thanks to MFT, takabanana, ComFreek
#
##
## about_Execution_Policies | Microsoft Docs
## https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1&viewFallbackFrom=powershell-Microsoft.PowerShell.Core
## Beginning in Windows PowerShell 3.0, you can use the Stream parameter of the Get-Item cmdlet to detect files that are blocked because they were downloaded from the Internet, and you can use the Unblock-File cmdlet to unblock the scripts so that you can run them in Windows PowerShell.
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
#!/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)