Skip to content

Instantly share code, notes, and snippets.

View unakatsuo's full-sized avatar

Masahiro Fujiwara unakatsuo

View GitHub Profile
@unakatsuo
unakatsuo / build.sh
Created April 13, 2017 04:28
Build protobuf-2.6.1 static binary similar to github.com/google/protobuf releases
curl -O https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz
tar xf protobuf-2.6.1.tar.gz
cd protobuf-2.6.1
LDFLAGS="-static-libgcc -static-libstdc++" ./configure --disable-shared --prefix=/usr/local/protobuf-2.6.1
cd src
make protoc
make install
@unakatsuo
unakatsuo / console.go
Created March 22, 2017 00:30
Check SetConsoleMode() Flags on Windows10
package main
import (
"fmt"
"os"
"github.com/Azure/go-ansiterm/winterm"
)
func main() {
@unakatsuo
unakatsuo / config.diff
Created March 18, 2017 10:23
.config diff for kernel-plus from centosplus repo
# Linux/x86_64 3.10.0-514.el7.x86_64 | # Linux/x86_64 3.10.0-514.10.2.el7.ce
# CONFIG_X86_NUMACHIP is not set | CONFIG_X86_NUMACHIP=y
> # CONFIG_BT_WILINK is not set
# CONFIG_NET_9P is not set | CONFIG_NET_9P=m
> CONFIG_NET_9P_VIRTIO=m
> # CONFIG_NET_9P_RDMA is not set
> # CONFIG_NET_9P_DEBUG is not set
# CONFIG_TI_ST is not set | CONFIG_TI_ST=m
# CONFIG_SCSI_AIC7XXX is not set | CONFIG_SCSI_AIC7XXX=m
> CONFIG_AIC7XXX_CMDS_PER_DEVICE=32
@unakatsuo
unakatsuo / flag_reflection.go
Created December 13, 2016 05:49
Go flag and reflection example.
func FlagReflection(args []string) error {
opts := map[string]interface{}{}
flags := flag.NewFlagSet("xxxx", flag.ContinueOnError)
opts["vcpu"] = flags.Int("vcpu", int(mdst.MinVcpu), "")
opts["memory_gb"] = flags.Int("memory_gb", int(mdst.MinMemoryGb), "")
if err := flags.Parse(args); err != nil {
return err
}
flags.Visit(func(f *flag.Flag) {
v := reflect.ValueOf(mdst)
@unakatsuo
unakatsuo / gotest.ps1
Created December 5, 2016 12:10
Exclude vendor/** and run "go test" on PowerShell.
go test -v $(go list ./... | Select-String -NotMatch /vendor/)
@unakatsuo
unakatsuo / find.go
Created December 1, 2016 03:14
Guess current Git branch name even on Detached HEAD.
import (
"log"
"bufio"
"os"
"strings"
"os/exec"
"bytes"
)
func findCurrentBranch() string {
@unakatsuo
unakatsuo / README.md
Last active December 29, 2021 17:03
Jenkins Job DSL embedded variables
@unakatsuo
unakatsuo / sample.md
Last active August 1, 2016 09:20
Show basic OS information using PowerShell
PS C:\> Get-CimInstance Win32_OperatingSystem | Select-Object  Caption, Version, OSType, ServicePackMajorVersion, OSAr
itecture, BuildNumber, MUILanguages, OSLanguage, Locale, CodeSet, CountryCode | FL


Caption                 : Microsoft Windows 10 Pro
Version                 : 10.0.10586
OSType                  : 18
ServicePackMajorVersion : 0
OSArchitecture : 64 ビット
@unakatsuo
unakatsuo / .gitignore
Last active September 22, 2016 11:09
packer-from-chef-bento-box
boxtemp/
output-*/
packer_cache/
@unakatsuo
unakatsuo / inotifyexec.ps1
Created January 29, 2016 12:34
Watch path and run command if changed.
[CmdletBinding()]
param(
[Parameter(Mandatory=$True,Position=1)]
[string]$WatchPath,
[Parameter(Mandatory=$True,Position=2)]
[string]$Command,
[Parameter(Mandatory=$False)]
[array]$MonitorEvents = @("Created", "Changed", "Deleted", "Renamed")
)