Skip to content

Instantly share code, notes, and snippets.

View unakatsuo's full-sized avatar

Masahiro Fujiwara unakatsuo

View GitHub Profile
require 'spec_helper'
feature "Feature1" do
scenario "Scenario1" do
step "Do something 1"
step "Do something 2"
step "Do something 3"
step "Do something 4"
end
@unakatsuo
unakatsuo / git-watch-folder.sh
Created October 14, 2014 11:40
Find modified files under the watching path between two git branches.
#!/bin/bash
set -ue
WATCH_PATH="config/db/migrations/"
MASTER_BRANCH="$1"
WORK_BRANCH="$2"
join -1 4 -2 4 -a 2 <(git ls-tree $MASTER_BRANCH -- $WATCH_PATH) <(git ls-tree $WORK_BRANCH -- $WATCH_PATH) | \
awk '$4 != $7 {print $1 " is changed"; found++; } END{ if (found > 0){ exit 1; } }'
@unakatsuo
unakatsuo / README.md
Created January 15, 2015 07:30
Shell: Check "return" behavior using at top level.

Check "return" behavior using at top level.

Run with ENV1.

% export ENV1=1
% /bin/sh ./test.sh
ENV1 found
a=1, b=2
% echo $?
@unakatsuo
unakatsuo / celluloid-io-inotify.rb
Created June 1, 2015 12:02
Celluloid::IO & rb-inotify
require "celluloid/io"
require "rb-inotify"
require "forwardable"
module Celluloid
module IO
class INotify
extend Forwardable
def_delegators :@notifier, :watch, :close
@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")
)
@unakatsuo
unakatsuo / .gitignore
Last active September 22, 2016 11:09
packer-from-chef-bento-box
boxtemp/
output-*/
packer_cache/
@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 / README.md
Last active December 29, 2021 17:03
Jenkins Job DSL embedded variables
@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 / 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/)