Skip to content

Instantly share code, notes, and snippets.

👻
ghost in the machine

DungSaga dungsaga

👻
ghost in the machine
View GitHub Profile
@dungsaga
dungsaga / committer-date-from-author-date.sh
Created May 7, 2020
set committer date to author date for the latest git commit
View committer-date-from-author-date.sh
#!/bin/bash
# set committer date to author date for the latest git commit
env GIT_COMMITTER_DATE=$(git log -1 HEAD | grep Date: | cut -d' ' -f2-) git commit --amend --no-edit --date=$GIT_COMMITTER_DATE
#!/usr/bin/fish
# fish shell use (...) instead of $(...)
env GIT_COMMITTER_DATE=(git log -1 HEAD | grep Date: | cut -d' ' -f2-) git commit --amend --no-edit --date=$GIT_COMMITTER_DATE
View calculate-nir.js
// use the web page at http://marlot.org/util/calcul-de-la-cle-nir.php
// when you input the data, it will calculate the check digits (Clé de contrôle)
// ref: https://en.wikipedia.org/wiki/INSEE_code
// run this in console to get the NIR string:
v=ids=>ids.split(',').map(id=>(e=document.getElementById(id),e.value||e.textContent)).join(' ');
v('sexe,annee,mois,dept,commune,ordre,cle');
// or, patch function CalculerCleNir in http://marlot.org/util/js/global.js
// line 149: cle.innerHTML=calculCle;
@dungsaga
dungsaga / route.sh
Last active Jan 14, 2020
Access remote host via a specific network interface
View route.sh
#!/bin/bash
# SSH can access a remote host using a specified network interface
# just use -b with local address of that network interface
ssh -b 10.20.30.40 root@12.34.56.78
# add a route to a remote host via a specified network interface
sudo ip route add 12.34.56.0/24 via 40.30.20.10 dev wlp2s0
# delete a route in the routing table
sudo ip route delete 12.34.56.0/24
@dungsaga
dungsaga / sync-time.sh
Created Jun 24, 2019
sync local clock in bash without NTP
View sync-time.sh
# I want to sync the local clock but don't have access to any NTP server.
# I can see my time offset at https://time.is and adjust the local clock accordingly.
# But then I recall that a HTTP response contains a date header which is often the current date & time.
# I'll use it to set the system clock with the precision of 1 or 2 seconds.
# in Linux
sudo date -us "$(curl -Is google.com | grep "^Date: " | cut -d" " -f3-)"
# in MacOS
@dungsaga
dungsaga / README.md
Last active Mar 18, 2019
Line chart with tag cloud
View README.md
@dungsaga
dungsaga / README.md
Created Mar 17, 2019
Candlestick chart demo
View README.md
View Rationale_for_using_CPL_as_an_installer_format.txt
** Rationale for using CPL as an installer format **
An issue with EXE installers is that they are likely to pick up bogus DLLs
from the directory they execute from, which, from security perspective, must
be assumed to be polluted with malicious stuff of all kinds. This holds even
for installers which carefully avoid DLL dependencies to the possible extent,
because the various DLL injection mechanisms built into Windows may introduce
additional dependencies which practically go beyond anyone's control.
https://blogs.msdn.microsoft.com/oldnewthing/20130802-00/?p=3633 provides some
View latest free version of Synergy.md

latest free version of Synergy

  • You can use Barrier which is almost similar to Synergy 1.9. It's actively maintained (receiving bug fixes) as an open source project. But it doesn't have digital certificates on binary releases.
  • You can use Synergy 1.9.0-rc3 or 1.8.8 from some github repository. It's not maintained as Symless is working on Synergy 2.x.

References:

@dungsaga
dungsaga / deobfuscate-odttf-in-xps.js
Last active Nov 7, 2019
deobfuscate odttf file (extracted from M$ XPS file)
View deobfuscate-odttf-in-xps.js
const purpose = "Purpose: deobfuscate odttf file (extracted from M$ XPS file)"
const usage = "Usage: node deobfuscate-odttf-in-xps.js <guid-obfuscated-font-file.odttf> [<output-file.ttf>]"
const obfuscatedStartOffset = 0 //start of obfuscated bytes in font file
const obfuscatedEndOffset = 32 //start of obfuscated bytes in font file
const guidSize = 32 // length of GUID string (only hex characters included)
const fs = require('fs')
const path = require('path')
View ios-8-web-app.html
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
You can’t perform that action at this time.