Skip to content

Instantly share code, notes, and snippets.

View monyxie's full-sized avatar
🎯
Focusing

monyxie

🎯
Focusing
View GitHub Profile
@monyxie
monyxie / gimp-add-outline.scm
Last active October 21, 2024 11:07
GIMP Script For Adding Outline Around Opaque Part of Active Layer
; GIMP Script For Adding Outline Around Opaque Part of Active Layer
; Installation: save this file under ~/.config/GIMP/2.10/scripts
; Usage: Menu > Script-Fu > Add Outline
(define (add-outline image drawable outline1-width outline1-color outline2-width outline2-color feather create-group)
(gimp-image-undo-group-start image)
(let* (
(active-layer (car (gimp-image-get-active-layer image)))
(parent (car (gimp-item-get-parent active-layer)))
@monyxie
monyxie / Setting up Infobox in MediaWiki v1.41 .md
Last active August 23, 2025 01:57
Setting up Infobox in MediaWiki v1.41

The following instructions are only tested in MediaWiki 1.41.

  1. Add the following code to LocalSettings.php to enable the Scribunto extension
wfLoadExtension( 'Scribunto' );
$wgScribuntoDefaultEngine = 'luastandalone';
  1. Make sure path-to-extensions/Scribunto/includes/engines/LuaStandalone/binaries/yourOS/lua has execute permission bit set

  2. Download and install the TemplateStyles extension

@monyxie
monyxie / scancode
Last active October 15, 2020 15:38
Scan QR code on Linux using webcam and zbarcam
#!/bin/bash
# Install zbar and xdotool first and substitute /dev/video2 with your webcam device
CMD="zbarcam --prescale=320x240 /dev/video2"
while IFS= read -r newline; do echo $newline | sed 's/^[^:]*://g' | xargs xdotool type && xdotool key Return ; done < <($CMD)
@monyxie
monyxie / retry.sh
Created March 17, 2020 08:41
Simple shell script to retry a command if it fails.
#!/bin/sh
if [ "$#" -lt 3 ]; then
echo "Usage: retry.sh <max_retry> <retry_interval> command..."
exit 1
fi
MAX_RETRY="$1"
RETRY_INTERVAL="$2"
if [ "$MAX_RETRY" -eq "$MAX_RETRY" ] 2>/dev/null
@monyxie
monyxie / wireshark-mysql-query-log.lua
Last active June 26, 2019 03:37
MySQL Query Log Plugin for Wireshark
-- wireshark-mysql-query-log.lua
-- this script adds a menu entry in Wireshark for MySQL query logging
-- put this file under wiresharks' plugin directory,
-- typically "C:\Program Files\Wireshark\plugins" on Windows
-- and restart wireshark.
-- then choose "Tools > MySQL Query Log" in the menu.
instances = 0 -- number of instances of the tap created so far
@monyxie
monyxie / mysql-script-template2.php
Last active December 10, 2018 10:44
Template for quick and dirty scripting
<?php
const DBHOST = 'localhost';
CONST DBPORT = '3306';
const DBNAME = 'test';
const DBUSER = 'root';
const DBPASS = '';
withDb(function($db) {
@monyxie
monyxie / read-only-mode-for-lanhu.user.js
Last active November 13, 2018 04:15
蓝湖只读模式 A userscript that makes LanHu projects read-only
// ==UserScript==
// @name 蓝湖只读模式 Read-only Mode for LanHu
// @namespace http://tampermonkey.net/
// @version 0.2
// @description 蓝湖只读模式 Read-only Mode for LanHu
// @author You
// @match https://lanhuapp.com/web/*
// @grant none
// @require https://unpkg.com/ajax-hook/dist/ajaxhook.min.js
// @require https://code.jquery.com/jquery-3.3.1.min.js
@monyxie
monyxie / Caddyfile-windows-php-boilerplate
Created September 21, 2018 03:29
Caddyfile boilerplate for PHP development on Windows
(start-php-cgi) {
# php7.1 fastcgi processes
on startup "\"E:\php\php-7.1.19-nts-Win32-VC14-x64\php-cgi.exe\" -b 127.0.0.1:17101" &
on startup "\"E:\php\php-7.1.19-nts-Win32-VC14-x64\php-cgi.exe\" -b 127.0.0.1:17102" &
on startup "\"E:\php\php-7.1.19-nts-Win32-VC14-x64\php-cgi.exe\" -b 127.0.0.1:17103" &
# php7.2 fastcgi processes
on startup "\"E:\php\php-7.2.8-nts-Win32-VC15-x64\php-cgi.exe\" -b 127.0.0.1:17201" &
on startup "\"E:\php\php-7.2.8-nts-Win32-VC15-x64\php-cgi.exe\" -b 127.0.0.1:17202" &
on startup "\"E:\php\php-7.2.8-nts-Win32-VC15-x64\php-cgi.exe\" -b 127.0.0.1:17203" &
@monyxie
monyxie / mysql-script-template.php
Created September 20, 2018 11:35
Template for quick and dirty MySQL scripting
<?php
const DBHOST = 'localhost';
CONST DBPORT = '3306';
const DBNAME = 'test';
const DBUSER = 'root';
const DBPASS = '123456';
withTransaction(function(PDO $db) {
$insertReport = $db->prepare('INSERT INTO tbl_report (`uid`,`type`,`status`,`target_id`,`content`,`datetime`) VALUES (?,?,?,?,?,?)');
$insertAttach = $db->prepare('INSERT INTO tbl_report_attach (`rid`,`type`,`usage`,`url`,`datetime`) VALUES (?,?,?,?,?)');
@monyxie
monyxie / hash-password.js
Last active August 14, 2018 07:14
Reference Postman scripts.
var Cry = require('crypto-js');
['API_UID', 'API_TOKEN', 'API_UUID'].forEach(i => pm.environment.has(i) || pm.environment.set(i, ''))
var bodyMode = pm.request.body.mode
var bodyParams = pm.request.body[bodyMode]
var queryParams = pm.request.url.query
var params = Object.assign({}, queryParams.toObject(), bodyParams.toObject())
var timestamp = Math.floor((new Date()).getTime() / 1000);