Skip to content

Instantly share code, notes, and snippets.

ᴊ. ᴄʜᴇɴ Unknwon

Block or report user

Report or block Unknwon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Unknwon
Unknwon / chrome.sh
Last active Mar 5, 2019
[Single Page Chrome Window] #Archive
View chrome.sh
#! /bin/bash
URL=$1
if [ -z "$URL" ]; then
echo "Please enter an URL: "
read URL
fi
if [[ $URL != http://* && $URL != https://* ]]; then
URL="http://$URL"
View keybase.md

Keybase proof

I hereby claim:

  • I am unknwon on github.
  • I am unknwon (https://keybase.io/unknwon) on keybase.
  • I have a public key ASBCrPsvKjbtJGuoh-dcI-k4KiD5cDbks_i70U-HOJw6kAo

To claim this, I am signing this object:

View Install wkhtmltopdf on CentOS7
yum install -y libpng
yum install -y libjpeg
yum install -y openssl
yum install -y icu
yum install -y libX11
yum install -y libXext
yum install -y libXrender
yum install -y xorg-x11-fonts-Type1
yum install -y xorg-x11-fonts-75dpi
@Unknwon
Unknwon / .md
Last active Feb 13, 2019
spf13-vim + vim-go
View .md
  1. Install spf13-vim
sh <(curl https://j.mp/spf13-vim3 -L)
  1. Install Go bundle
echo "let g:spf13_bundle_groups=['general', 'neocomplete', 'programming', 'ruby', 'python', 'go', 'javascript', 'html', 'misc', 'writing' ]" >> ~/.vimrc.before.local 
View sample.yml
app:
image: bradrydzewski/go:1.2
git:
path: github.com/drone/drone
environment:
- GOROOT=/usr/local/go
- PATH=$PATH:$GOROOT/bin:$GOPATH/bin
services:
- redis
- mysql
View go_tips.md

Convert []uint to int64

int64(binary.LittleEndian.Uint64(data[pos:pos+8]))
int64(binary.BigEndian.Uint64(data[pos:pos+8]))

Get Windows version

View gist:a7c9162bce3f20d3bee6
package main
import (
"fmt"
"log"
)
var printFn = func(idx int, bean interface{}) error {
fmt.Printf("%d: %#v\n", idx, bean.(*Account))
return nil
View gist:861dfa5107c6e9a65974
package main
import (
"fmt"
)
const prompt = `Please enter number of operation:
1. Create new account
2. Show detail of account
3. Deposit
View gist:40b070c0ed5d959f268b

Build System

Build program only with .a files

For a package called "hello", the go tool will look for .go sources in $GOPATH/src/hello, and only rebuild if the timestamp of the .a file is before the latest timestamp of the .go files. An easy way to fool it into accepting just the .a file is to drop a dummy .go file in the correct src directory and set its timestamp to before that of the .a file.

Hide DOS window

go build -ldflags -Hwindowsgui project.go

View gist:03c4e9dec8ea97b3a010
package main
import (
"fmt"
)
const prompt = `Please enter number of operation:
1. Create new account
2. Show detail of account
3. Deposit
You can’t perform that action at this time.