Skip to content

Instantly share code, notes, and snippets.

View Pagliacii's full-sized avatar
🎯
Focusing

Jason Huang Pagliacii

🎯
Focusing
View GitHub Profile
@Pagliacii
Pagliacii / convert.sh
Created April 28, 2020 08:51
Use gnash and ffmpeg to convert *.swf to *.mp4
#!/bin/bash
trap cleanup EXIT
set -eux
set -o pipefail
SWFFILE="$1"
MP4FILE="${SWFFILE%.*}.mp4"
RAWFILE=$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 32 | head -n 1).raw
WAVFILE=$(cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 32 | head -n 1).wav
@Pagliacii
Pagliacii / swf_header.py
Last active January 26, 2021 11:58
Parsing and getting the header of SWF files. [Adobe SWF File Format Specification](https://www.adobe.com/content/dam/acom/en/devnet/pdf/swf-file-format-spec.pdf)
#!/usr/bin/env python3
# _*_ coding:utf-8 _*_
"""
Author: Pagliacii
Copyright © 2020-Pagliacii-MIT License
"""
import math
from struct import unpack
@Pagliacii
Pagliacii / Makefile
Last active July 28, 2020 04:02
Makefile template, usage: `make all_src_files[ debug=mode]`. From https://tech.davis-hansson.com/p/make/
# use bash as the default shell
SHELL := bash
# ensures each Make recipe is ran as one single shell session, rather than one new shell per line
.ONESHELL:
# use bash strict mode. http://redsymbol.net/articles/unofficial-bash-strict-mode/
.SHELLFLAGS := -eu -o pipefail -c
# remove target files when Make file failed
.DELETE_ON_ERROR:
# warning when referring the undefined variables
MAKEFLAGS += --warn-undefined-variables
#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.
@Pagliacii
Pagliacii / AutoHotkey.ahk
Created July 31, 2020 08:23
Preventing the left mouse button double-click in the small period, because the microswitch of my left mouse button has some damages. Base on the AutoHotkey script.
debounceLeftClick()
{
Sleep, 10
if !GetKeyState("LButton", "P")
{
n := 1
BlockInput, On
Loop {
Sleep, 10
if (n++ > 9)
@Pagliacii
Pagliacii / proxy.sh
Last active September 22, 2021 11:25
A shell script to run command behind the proxy.
#!/usr/bin/env bash
# 0. (Optional) Rename this script name to "proxy"
# 1. Replace the <protocol>, <ip> and <port> to the actual value of your proxy respectively.
# 2. Run this command `sudo chmod +x <path to proxy>` to make sure this script is executable.
# 3. Add this script path to the PATH environment variable.
# 4. Run your actual command like this: `proxy ping www.google.com`.
PROXY="<protocol>://<ip>:<port>"
export ALL_PROXY=$PROXY
@Pagliacii
Pagliacii / SendUnicode.ahk
Last active November 14, 2020 07:30
This function pops up the input box to ask the user to enter some Unicode to input the corresponding character into the current input area.
getUnicodeFromInputBox()
{
Sleep, 10
InputBox, Code, AutoHotkey, Enter the Unicode, , 320, 112
Send, {U+%Code%}
}
; Binding to CapsLock+x
CapsLock & x::getUnicodeFromInputBox()
@Pagliacii
Pagliacii / falsehoods-programming-time-list.md
Created January 15, 2021 04:31 — forked from timvisee/falsehoods-programming-time-list.md
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@Pagliacii
Pagliacii / which_command.ps1
Last active February 21, 2021 14:53
A which command implementation in PowerShell
Function WhichCommand(
[String]$cmd
) {
try {
$Command = Get-Command -ErrorAction Stop $cmd
}
catch {
Write-Host -ForegroundColor Red ("{0} not found" -f $cmd)
Return
}
@Pagliacii
Pagliacii / add_menu_items.ahk
Created February 9, 2021 06:37
Add custom menu items to the AHK tray menu, which lets you can edit the current running script with your favored editor.
#NoEnv ; Recommended for performance and compatibility with future AutoHotKey releases.
SendModeInput ; Recommended for new scripts due to its superior speed and reliability.
#Persistent ; Keeps a script permanently running (that is, until the user closes it or ExitApp is encountered.
insertMenuItemsBeforeStandard()
;
; This functions inserts your menu items before the standard menu
;
insertMenuItemsBeforeStandard() {