Skip to content

Instantly share code, notes, and snippets.

View pallat's full-sized avatar

Pallat Anchaleechamaikorn pallat

View GitHub Profile
@pallat
pallat / 2repos-sync.sh
Created April 9, 2020 02:55 — forked from yorammi/2repos-sync.sh
Sync 2 remote repositories script - Just define the 3 variables (use export command for that!)
#!/bin/bash
# REPO_NAME=<repo>.git
# ORIGIN_URL=git@<host>:<project>/$REPO_NAME
# REPO1_URL=git@<host>:<project>/$REPO_NAME
rm -rf $REPO_NAME
git clone --bare $ORIGIN_URL
if [ "$?" != "0" ]; then
echo "ERROR: failed clone of $ORIGIN_URL"
@pallat
pallat / thai-id-card.go
Created January 15, 2020 04:19 — forked from bouroo/thai-id-card.go
Thai National ID Card reader in GO
package main
// Require pcscd, libpcsclite
import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"os"
"strconv"
@pallat
pallat / runq.go
Last active October 24, 2017 03:33
example queue usage
package main
import (
"fmt"
"github.com/pallat/queue"
)
type lot struct {
items []int
package main
import (
"fmt"
)
type slice []int
type loopFn func(int)
func (a *slice) forEach(fn loopFn) {
@pallat
pallat / gist:7f1f3a9eb1f9d9a43888
Created February 17, 2016 05:08
xml tag attr chardata
package main
import (
"encoding/xml"
"fmt"
"log"
)
type Password struct {
Type string `xml:"Type,attr"`
@pallat
pallat / gist:bf84f209d1611e78bd64
Last active February 17, 2016 04:41
override method in go
package main
import "fmt"
type car interface {
color() string
model() string
}
type toyota struct{}
@pallat
pallat / mock
Last active August 29, 2015 14:10
package main
type presenter interface {
method() interface{}
}
type doing func() interface{}
func (d doing) method() interface{} {
return d()