Skip to content

Instantly share code, notes, and snippets.

@for2ando
for2ando / resolv.awk
Created January 18, 2024 14:22
Update /etc/resolv.conf from a ipconfig /all output, for Windows w/ Cygwin. Retreive from https://cygwin.com/pipermail/cygwin/2018-June/237655.html.
#!/usr/bin/awk -f
# resolv.awk - create Windows resolv.conf from ipconfig /all output
{ sub( /\r/, "", $NF) } # trim \r
# collect DNS domain suffixes
/D[Nn][Ss]\sSuffix[^:]*:\s\S/ { domain[$NF] = $NF }
# collect DNS search suffixes
/Search\sList[^:]*:\s\S/ { search[$NF] = $NF }
@for2ando
for2ando / path.sh
Last active December 24, 2023 14:47
PATH manipulation functions' library
# PATH manipulation functions' library
# if $1 exists in $PATH then true
path_exists() {
echo ":$PATH:" | grep -q ":$1:"
}
# remove all occurence of $1 in $PATH.
remove_path_all() {
PATH="$(echo $PATH| sed '
@for2ando
for2ando / wikifilename.sh
Created May 3, 2023 13:46
Return a encoded string for a filename for pukiwiki.
#!usr/bin/env bash
echo $(echo -n FrontPage|od -A x -t x1|sed "s/^......//;s/ //g"|tr "a-z" "A-Z").txt
@for2ando
for2ando / pyhttpd-start
Created March 8, 2023 10:45
Python3 http.server start/stop script
#!/usr/bin/env bash
pname="$(basename $0)"
htdocs=/var/www/htdocs
logfile=/var/log/pyhttpd/httpd.log
pidfile=/var/run/pyhttpd.pid
port=8086
httpd="python3 -m http.server --cgi $port"
proc_signature="[0-9]:[0-9][0-9] $httpd"
@for2ando
for2ando / readlink-recursive
Created December 7, 2022 16:26
A recursive version of readlink command.
@for2ando
for2ando / msys2_select.cmd
Created July 5, 2022 15:18
Msys2: A MSYSTEM selection & go script.
@echo off
:input
echo 1. msys2
echo 2. mingw32
echo 3. mingw64
echo 4. clang64
echo 5. ucrt64
echo 0. quit
set /p menu="Which ? "
if %menu%/ == / goto input
@for2ando
for2ando / ghcup
Created July 3, 2022 13:26
Ghcup setup script. I put it on ~/.bashrc.d/ghcup.
#!/bin/sh
if grep -q '^NAME=.*openSUSE' /etc/os-release; then
source "$HOME/.ghcup/env"
elif grep -q '^NAME=.*MSYS2' /etc/os-release; then
source "$(cygpath -u ${GHCUP_INSTALL_BASE_PREFIX}\\ghcup\\env)"
fi
@echo off
echo TeraTerm Serial Port
set /p comport="Port: COM"
start "" "%TTBIN%\ttermpro.exe" /F="%TTETC%\teraterm.ini" /C=%comport% /W=com%comport%
rem pause
@for2ando
for2ando / emacskey.dot
Last active January 12, 2024 07:45
A template for Microsoft Word to emulate limited Emacs key assigns.
@for2ando
for2ando / makeshortcut.bat
Last active January 7, 2022 11:26
A one-file script to make a Windows's shortcut from https://qiita.com/y-takano/items/b94312abc17159dce8be . Thanks to @y-takano.
@if(0)==(0) echo off
cscript.exe //nologo //E:JScript "%~f0" %*
goto :EOF
@end
// メイン処理
function main() {
var shortcut = null;
try {
// ショートカットを作成する