Skip to content

Instantly share code, notes, and snippets.

View dungsaga's full-sized avatar
👻
ghost in the machine

DungSaga dungsaga

👻
ghost in the machine
View GitHub Profile
@dungsaga
dungsaga / save-printing-paper.js
Last active June 24, 2026 08:30
save printing paper at hoadondientu.gdt.gov.vn/tra-cuu/tra-cuu-hoa-don
// save printing paper by removing some padding
// used for printing invoices at https://hoadondientu.gdt.gov.vn/tra-cuu/tra-cuu-hoa-don
var moreCss = ".print-page{width:auto !important} body .main-page{line-height:1;margin:0;border:0} .main-title{margin-top:-90px} .day{margin:-11px 120px 0} .table-horizontal-wrapper>div:nth-child(1){width:34%} body .res-tb{margin:4px 0;min-width:auto} .res-tb td, .res-tb th{padding:1px !important} .ft-sign{padding:0 !important} .ft-sign h3{margin:0 0 -10px} .ft-sign p{margin:10px} .fd-end,.gtgt-ktkht-description,.ft-sign .vip-divide{display:none}";
window.open0 ||= window.open; window.open = function(url){let win = window.open0.call(this,url); let write = win.document.write; win.document.write = function(html){ return write.call(this, html.replace(/Mẫu số: 01 .+?<style>/, "$&"+moreCss)) }; return win};
@dungsaga
dungsaga / humorous.js
Last active April 8, 2026 03:25
humorous constants
// Once upon a time, I stumbled on a code base splattered with hard-coded constants.
// And I think to myself: why don't I spice it up with meaningful constants?
const CONST_VOID = 0;
const CONST_NEO = 1;
const CONST_REDUX = 2;
const CONST_TRINITY = 3;
const CONST_FJORD = 4;
@dungsaga
dungsaga / install-and-uninstall.sh
Last active March 6, 2026 05:16
install and uninstall LibreOffice packages (under Debian/Ubuntu/...)
# INSTALLATION:
tar xf --strip-components=1 LibreOffice_26.2.0_Linux_x86-64_deb.tar.gz
sudo dpkg -i DEBS/*.deb
# UNINSTALLATION:
tar xf --strip-components=1 LibreOffice_26.2.0_Linux_x86-64_deb.tar.gz
cd DEBS
for f in DEBS/*.deb; do sudo dpkg -r --force-depends "${f/_*/}"; done
# alternative methods of UNINSTALLATION
@dungsaga
dungsaga / Excel column name to number.js
Last active December 30, 2025 03:46 — forked from danmana/Excel column name to number.js
Convert from excel column names to a index (1 based)
function colNum(name = '') {
const val = (c) => c.charCodeAt(0) - 'A'.charCodeAt(0) + 1
return name.split('')
.reduce((acc, v) => val(v) + acc * val('Z'), 0)
}
colNum('A') === 1
colNum('Z') === 26
colNum('AA') === 27
@dungsaga
dungsaga / magento-criticisms.md
Created December 11, 2025 10:39
Magento criticisms
@dungsaga
dungsaga / Hirofumi-Nakai-Improved.md
Last active February 22, 2026 21:33
Hirofumi Nakai Improved (HNI) - a method for Doomsday calculation

Hirofumi Nakai Improved

The Doomsday rule was devised by John Conway in 1973 to compute the day of week in your head (https://en.wikipedia.org/wiki/Doomsday_rule). Others have made improvements for easier mental calculation.

Currently, the simplest one is published in 2023 in the paper "A Simple Formula for Doomsday" by Hirofumi Nakai (https://thatsmaths.com/2023/06/22/a-simple-formula-for-the-weekday/).

  • split the year into century part and the remaining 2-digit part: Y = 100c + y
  • compute the modulo 4 of these 2 parts: c₄ = c % 4, y₄ = y % 4
  • the Doomsday would be (5(c₄ + y₄ - 1) + 10y) % 7
<?php
/**
* Adminer plugin that display the first CHAR/VARCHAR column of the foreign key
*
* @category Plugin
* @link http://www.adminer.org/plugins/#use
* @author Bruno VIBERT <http://www.netapsys.fr>
* @modified by Peter Hostačný <hostacny.peter AT gmail.com>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
@dungsaga
dungsaga / 01-next-html.md
Last active July 30, 2025 06:52
what's the next HTML version? HTML6!?
@dungsaga
dungsaga / bash_strict_mode.md
Created March 18, 2025 02:26 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
@dungsaga
dungsaga / fix-osnews.md
Last active February 9, 2025 10:37
fix invisible titles in osnews.com