Skip to content

Instantly share code, notes, and snippets.

@twinbird
twinbird / wsl_port_forward.ps1
Created May 16, 2023 08:49
Port forwarding to WSL2 from windows host
<#
.SYNOPSIS
Port forwarding from Windows Host environment to WSL2 environment.
.DESCRIPTION
A simple wrapper windows command 'netsh'.
Requires administrator privileges to run.
.PARAMETER FromPort
Specifies the port in the Windows Host environment for port forwarding.
#!/bin/bash
# nco.sh
# checkout next/prev commit on current git repository
# Usage:
# nco [next|prev]
# use only on detached HEAD branch
if [[ ! -e .git ]]; then
echo "$PWD is not git repository."
#!/bin/sh
####################################################################################################################
# Upload by FTP
# NAME:
# send_ftp.sh
# SYNOPSIS:
# send_ftp.sh [FTP SERVER NAME] [FTP USER] [FTP PASSWORD] [SEND FILE PATH] [SEND REMOTE DIR]
####################################################################################################################
# append for .bash_profile
# bash-completion for ssh
function _compreply_ssh(){
COMPREPLY=(`cat ~/.ssh/config | grep -i -e '^host' | cut -d " " -f 2 | grep -E "$2"`)
}
complete -F _compreply_ssh ssh
@twinbird
twinbird / pearson.go
Created February 17, 2017 07:32
Pearson hashing sample by golang
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
sc := bufio.NewScanner(os.Stdin)
#!/bin/sh
if [ $# != 1 ]; then
echo "Usage: $0 [binary name]"
exit 0
fi
GOOS=linux GOARCH=amd64 go build -o ./bin/linux64/$1
GOOS=linux GOARCH=386 go build -o ./bin/linux386/$1
/*
* Cプログラムの行数を数え,
* コメントを印字するプログラム
*/
/* ここから定義部 */
/* Cと同じ記法でここはコメントになります */
/* yaccと連携するためのmain関数を出力しないオプション */