Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tadd's full-sized avatar

Tadashi Saito tadd

View GitHub Profile
@tadd
tadd / dot.lesskey
Last active July 12, 2023 10:28
readline-like `.lesskey` (Why not in /etc/skel?)
#line-edit
^A home
^E end
^P up
^N down # Overriding!
^F right
^B left
^K kill-line
^D delete
@tadd
tadd / irb-banner.rb
Last active June 2, 2023 15:53
Customization of IRB Inspection
class Array; def inspect = IO.popen(['banner', to_s], &:read).chomp; end
conf.echo_on_assignment = true # never truncate # IRB.conf[:ECHO_ON_ASSIGNMENT] = true
conf.inspect_mode = :inspect # IRB.conf[:INSPECT_MODE] = :inspect
@tadd
tadd / gen-git-push-instead-of.sh
Last active January 31, 2023 16:39
Generate shortcut urls for .gitconfig
# Usage: sh gen-git-pushj-instead-of.sh github.com-name [gitlab.com-name] >>~/.gitconfig
# Then:
# git clone gist:711a1f04cd89e488fb08ef562e045f43 # or
# git clone gh:ruby/ruby
_url()
{
printf "[url \"git@$2:${3:+$3/}\"]\n\tinsteadOf = $1:\n"
}
@tadd
tadd / git-push
Last active November 11, 2023 05:16
Force not to use `git push -f` but `--force-with-lease`
#!/bin/bash -eu
argv="$(sed -E 's/(^| )-f\b/\1--force-with-lease/g' <<<$@)"
exec git push ${argv}
type -t git-$1 >/dev/null && exec git-$1 "${@:2}" || git "$@"
@tadd
tadd / update-all-pkgs
Last active July 22, 2023 09:52
I can (not) update everything of my Debian system at once.
#!/bin/sh
# First of all, there is one bad news: you cannot update everything in this script.
# Below is my current status and methods.
#
# * System pacakges: apt update && apt upgrade
# * Firmware: fwupdgmr refresh && fwupdgmr update
# * Chrome, Firefox, and Thunderbird: they won't be updated unless booted (maybe?)
# if you installed binary from upstreams
# * Emacs itself: using distro's package
@tadd
tadd / taika.js
Last active August 20, 2022 10:42
大化の改新が二回起こる件について(蘇我入鹿は二度死ぬ)
const [lsyear, lslong] = [{year: 'numeric'}, {dateStyle: 'long'}].map(o =>
d => d && d.toLocaleString("ja-JP-u-ca-japanese", o));
const isolong = d => d && d.toISOString().slice(0, "yyyy-mm-dd".length);
const d = new Date(643, 0, 1);
let prevy, prevd;
for (let i = 0; i < 1300; i++) {
//console.debug(lslong(d));
const y = lsyear(d);
if (y !== prevy) {
@tadd
tadd / chaining.rb
Last active August 16, 2022 09:54
Easier method chaining for Ruby
# Only for those who are too lazy to write `self` at the end of their methods
def tapper(m)
Module.new do
define_method(m) do |*a, **k, &b|
tap { super(*a,**k, &b) }
end
end
end
@tadd
tadd / LICENSE
Last active December 17, 2022 10:36
Moved: https://github.com/tadd/academize.el (格調高いアカデミックな文章を自動的に生成してくれる便利なスクリプト)
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
@tadd
tadd / repack.bash
Created September 16, 2020 02:30
Repack .deb from nodesource for Debian bullseye
#!/bin/bash
set -e
ver=local1
if [ $# != 1 ]; then
echo $0: one argument of .deb needed >&2
exit 1
fi