Skip to content

Instantly share code, notes, and snippets.

View phanect's full-sized avatar

Jumpei Ogawa phanect

View GitHub Profile
@phanect
phanect / alllinks.py
Created May 19, 2013 01:07
Export all pages of Pukiwiki to html pages. Optimized for KDE Capacity framework.
@phanect
phanect / dropnhalt
Last active May 28, 2016 21:57
Shutdown computer when Dropbox sync finished
dropbox start
while [[ $(dropbox status) != "Up to date" ]]; do
sudo echo $(dropbox status)
sleep 120
done && sudo shutdown now
/**
* Assert if objects are equal. This function also considers `not`
* @return true if obj1 and obj2 are equal, otherwise false
*/
function _objEquals(obj1, obj2) {
const keys1 = obj1.getOwnPropertyNames().sort(sortByCharCode),
keys2 = obj2.getOwnPropertyNames().sort(sortByCharCode),
sortByCharCode = function(key1, key2) {
if (key1 < key2) {
return -1;
var fs = require("fs");
function copydir(srcdir : string, destdir : string, options) {
var _srcdir = srcdir.endsWith("/") ? srcdir : srcdir + "/";
var files = fs.readdirSync(srcdir);
files.forEach(function(filename) {
var srcfilepath = _srcdir + file;
if (options.emptydir) {

How to show total directory size of directories in current directory:

$ du --max-depth=1 -h ./
47M     ./foo
2.0M    ./bar
6.6G    ./hoge
4.0K    ./fuga
@phanect
phanect / createdb.md
Last active March 7, 2021 07:16
Create database
docker rm --force $(docker ps --all --quiet); docker rmi --force $(docker images --all --quiet); docker volume rm $(docker volume ls --quiet)
git clean -dX --force
#!/usr/bin/env bash
set -eu
DIRNAME="$(realpath "$(dirname -- "${BASH_SOURCE[0]}")")"
PROJECT_ROOT="$(realpath "${DIRNAME}/..")"
@phanect
phanect / replace-git-identities.sh
Created December 5, 2023 12:50
Commands to replace all the committer emails in the commit logs.
echo -e "Jumpei Ogawa <git@phanective.org> <phanect@users.noreply.github.com>\nJumpei Ogawa <git@phanective.org> <old@example.com>" | tee ./mailmap
git filter-repo --mailmap mailmap