Skip to content

Instantly share code, notes, and snippets.

View suzuki-shunsuke's full-sized avatar

Shunsuke Suzuki suzuki-shunsuke

View GitHub Profile
@suzuki-shunsuke
suzuki-shunsuke / check-broken-url.sh
Last active December 1, 2018 09:30
shell script to check whether broken urls are included in files
# xurls: https://github.com/mvdan/xurls
s=0
for url in `find . -name "*" -type f | xargs xurls | grep -v "ldap.*"`; do
if ! `curl -LI $url -o /dev/null --fail -s`; then
echo $url
s=1
fi
done
if [ $s -ne 0 ]; then
exit 1
@suzuki-shunsuke
suzuki-shunsuke / check-broken-url.sh
Created December 1, 2018 09:29
shell script to check whether broken urls are included in files
s=0
for url in `find ./test -name "*" -type f | xargs xurls | grep -v "ldap.*"`; do
if ! `curl -LI $url -o /dev/null --fail -s`; then
echo $url
s=1
fi
done
if [ $s -ne 0 ]; then
exit 1
fi
// https://play.golang.org/p/jUzWcBiO4xJ
// Output:
// B 0
// A 0
// end
package main
import (
"fmt"
// https://play.golang.org/p/2LBJbIBVw37
package main
import (
"fmt"
)
type Foo struct {
name string
}
package main
import (
"fmt"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
)
func main() {
package users
import (
"encoding/json"
)
// UserProfile contains all the information details of a given user
type UserProfile struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
@suzuki-shunsuke
suzuki-shunsuke / decode_hook.go
Last active March 29, 2018 05:16
sample code of mapstructure's DecodeHook
package main
import (
"fmt"
"log"
"reflect"
"github.com/mitchellh/mapstructure"
"github.com/suzuki-shunsuke/go-set"
)
{
"permissions" : {
"outputs" : [ "create", "edit", "terminate", "read" ],
"sources" : [ "read" ],
"indexranges" : [ "read", "rebuild" ],
"deflector" : [ "read", "cycle" ],
"loggers" : [ "readsubsystem", "edit", "editsubsystem", "read" ],
"inputs" : [ "terminate", "read", "create", "changestate", "edit" ],
"lbstatus" : [ "change" ],
"roles" : [ "edit", "create", "read", "delete" ],
@suzuki-shunsuke
suzuki-shunsuke / playbook.yml
Created January 5, 2018 12:58
ansibleのshell(command)モジュールで標準出力によってchangedを判定する方法
---
- hosts: localhost
tasks:
- shell: "echo '{\"changed\": true}'"
register: result
changed_when: (result.stdout|from_json)["changed"]
- shell: "echo '{\"changed\": false}'"
register: result
changed_when: (result.stdout|from_json)["changed"]
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/ghodss/yaml"
)