2014-12-18

Benchmark of Go's (Current) Best Router/Mux

Yesterday I stumbled upon a benchmark by euforic. So today I sort all the benchmark, remove all with high memory usages, and ones with worst performance and end up with this spreadsheet visualization (oh before I forgot, LibreOffice Calc conditional formatting is freakin' buggy).


And if you asked me, what's the best for all case? Just search for one that have the most green. Denco seems to have consistent performance, and FYI the older benchmark favors to HttpRouter.

2014-11-28

How to Remotely Run Command on Windows PC from Linux

So, sometimes the server uses Windows instead of Linux or BSD, and we need to execute certain command on the server, because the web interface not suffice, for example, exporting 1.2GB of data from MySQL using PHPMyAdmin? timeout! :3
We could use a tool called winexe, to install it, type:

yaourt -S winexe

Then just execute:

winexe -U USERNAME //IPADDRESS cmd.exe

Voila~ :3

2014-11-27

How to use Go-Couchbase

Today I will try to use Go-Couchbase, to insert, fetch, update and delete from database. To install go-couchbase, type this commands:

go get -u -v github.com/couchbaselabs/go-couchbase

Then just create an example source code and run it:

package main

import (
"fmt"

"github.com/couchbaselabs/go-couchbase"
//"github.com/davecgh/go-spew/spew"
"encoding/json"

"github.com/kr/pretty"
//"reflect"
"errors"
"runtime"
"strings"
)

var FILE_PATH string
var CB *couchbase.Bucket

// initialize file path
func init() {
_, file, _, _ := runtime.Caller(1)
FILE_PATH = file[:4+strings.Index(file, "/src/")]
err := errors.New("no error")
CB, err = couchbase.GetBucket("http://127.0.0.1:8091/", "default", "default")
Panic(err, "Error connection, getting pool or bucket:  %v")
}

// print warning message
func Check(err error, msg string, args ...interface{}) error {
if err != nil {
_, file, line, _ := runtime.Caller(1)
str := fmt.Sprintf("%s:%d: ", file[len(FILE_PATH):], line)
fmt.Errorf(str+msg, args...)
res := pretty.Formatter(err)
fmt.Errorf("%# v\n", res)
}
return err
}

// print error message and exit program
func Panic(err error, msg string, args ...interface{}) {
if Check(err, msg, args...) != nil {
panic(err)
}
}

// describe a variable
func Explain(args ...interface{}) {
_, file, line, _ := runtime.Caller(1)
//res, _ := json.MarshalIndent(variable, "   ", "  ")
for _, arg := range args {
res := pretty.Formatter(arg)
fmt.Printf("%s:%d: %# v\n", file[len(FILE_PATH):], line, res)
}
//spew.Dump(variable)
}

func main() {

var err error

// save values (upsert)
err = CB.Set("someKey", 0, []string{"an", "example", "list"})
Check(err, "failed to set somekey")

err = CB.Set("primaryKey", 0, 1)
Check(err, "failed to set primaryKey")

// fetch one value
var rv interface{}
err = CB.Get("someKey", &rv)
Check(err, "failed to get someKey")
Explain(rv)

// fetch with CheckAndSet id
cas := uint64(0)
err = CB.Gets("primaryKey", &rv, &cas)
Check(err, "failed to get primaryKey")
Explain(cas, rv)

// fetch multivalue
rows, err := CB.GetBulk([]string{"someKey", "primaryKey", "nothingKey"})
Check(err, "failed to get someKey or primaryKey or nothingKey")
Explain(rows)

jsonStr := rows["someKey"].Body
Explain(string(jsonStr))

stringList := []string{}
err = json.Unmarshal(jsonStr, &stringList)
Check(err, "failed to convert back to json")
Explain(stringList)

// increment value, returns new value
nv, err := CB.Incr("primaryKey", 1, 1, 0)
Check(err, "failed to increment primaryKey")
Explain(nv)

// increment value, defaults to 1 if not exists
nv, err = CB.Incr("key3", 1, 1, 60)
Check(err, "failed to increment primaryKey")
Explain(nv)

}

This would give an output:

/test.go:92: []interface {}{
    "an",
    "example",
    "list",
}
/test.go:98: uint64(0x13aa8b32b9f7f091)
/test.go:98: float64(1)
/test.go:103: map[string]*gomemcached.MCResponse{
    "primaryKey": &gomemcached.MCResponse{
        Opcode: 0x0,
        Status: 0x0,
        Opaque: 0x0,
        Cas:    0x13aa8b32b9f7f091,
        Extras: {0x0, 0x0, 0x0, 0x0},
        Key:    {},
        Body:   {0x31},
        Fatal:  false,
    },
    "someKey": &gomemcached.MCResponse{
        Opcode: 0x0,
        Status: 0x0,
        Opaque: 0x0,
        Cas:    0x13aa8b32b9e4690f,
        Extras: {0x0, 0x0, 0x0, 0x0},
        Key:    {},
        Body:   {0x5b, 0x22, 0x61, 0x6e, 0x22, 0x2c, 0x22, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x22, 0x2c, 0x22, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x5d},
        Fatal:  false,
    },
}
/test.go:106: "[\"an\",\"example\",\"list\"]"
/test.go:111: []string{"an", "example", "list"}
/test.go:116: uint64(0x2)
/test.go:121: uint64(0x4)

How to install Couchbase on ArchLinux

Couchbase is NoSQL database with the best performance AFAIK. To install Couchbase, we need git and repo tool, that could be installed using this command:

sudo pacman -S git libtool gcc libevent make gperftools sqlite erlangautomake autoconf make curl dmidecode
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod +x ~/bin/repo

Change first line from python to python2.7, then initialize and start fetch the Couchbase repository:

mkdir couchbase
cd couchbase
repo init -u git://github.com/couchbase/manifest.git -m released/3.0.1.xml
repo snyc

To prevent failure when building python-based programs, symlink your python to the older one:

sudo ln -sf python2.7 /usr/bin/python

Install older version of v8 (3.21.17 or less), using this command:

yaourt -S v8-3.15
V8PKG=v8-3.19.18.4-1-x86_64.pkg.tar.xz
wget http://seblu.net/a/arm/packages/v/v8/$V8PKG
sudo pacman -U $V8PKG

Then compile the Couchbase:

make

Note if this step failed clean the couchbase first using make clean, then compile the v8 on the v8 folder in the couchbase directory. If you're using latest version of GCC, remove all werror string from build/standalone.gypi and build/toolchain.gpyi file:

make dependencies
export PYTHON=python2
  find build/ test/ tools/ src/ -type f \
    -exec sed -e 's_^#!/usr/bin/env python$_&2_' \
              -e 's_^\(#!/usr/bin/python2\).[45]$_\1_' \
              -e 's_^#!/usr/bin/python$_&2_' \
              -e "s_'python'_'python2'_" -i {} \;
  sed -i 's/python /python2 /' Makefile
sed -i 's/-Werror//' build/standalone.gypi build/common.gypi
make x64.release library=shared console=readline

Alternatively use this modified PKGBUILD file:

wget http://goo.gl/miEmFt -O PKGBUILD
makepkg
sudo pacman -U v8-3.21-3.21.17-1-x86_64.pkg.tar.xz

Don't forget to increase the default number of files:

echo '
*               soft    nofile          65536
*               hard    nofile          65536
' | sudo tee -a /etc/security/limits.conf

And last, start the server:

./install/bin/couchbase-server

Then just visit the web interface to setup the cluster http://localhost:8091/

That's it, that's how you install Couchbase on ArchLinux from source.

2014-11-26

How to start Martini Golang Project

Martini is another Golang web framework, that the design similar to Sinatra, to install it, just type this command:

go get -u -v github.com/go-martini/martini

Then, just create new source code, for example main.go:

package main
import "github.com/go-martini/martini"
func main() {
  m := martini.Classic()
  m.Get("/", func() string {
    return "Hello world!"
  })
  m.Run()
}

To run the website, just type:

go run main.go

Then visit http://localhost:3000/

We must recompile the source everytime the source code changed, that quite annoying and time consuming, to overcome that problem we could use a tool called gin, this program automatically run a program everytime there are code changed. To install this tool, type:

go get -u -v github.com/codegangsta/gin

Then run it using this command:

gin go run main.go

That command would create a proxy, if there are compilation errors, it would also show on the page.

How to install Goclipse and Golang IDEA plugin

Warning: current master version of these plugins (2014-11-25) are not good enough for daily coding, don't bother to try them for now.
Edit: latest alpha version of Golang IDEA plugin for IntelliJ are the best plugin for now.

Goclipse is another IDE for golang, that based on the infamous Eclipse platform. To install Eclipse, just type:

pacman -S eclipse

To install Goclipse, you must first clone the repository, for example using this command:

git clone --depth 1 https://github.com/GoClipse/goclipse.git

Then you must download all dependencies and start building:

cd goclipse
mvn clean integration-test
ant -f releng/ CreateProjectSite
ant -f releng/ PublishProjectSite

Last command would fail when not supplied with correct DprojectSiteGitURL parameter, but the required jars still resides in bin-maven/projectSite/, just use any webserver to serve the files as Eclipse update site, for example using php:

cd bin-maven/projectSite/
php -S localhost:9009

To install Goclipse, open Eclipse, Help > Install New Software..,  just add http://localhost:9009/releases

Then select Goclipse, next, accept the license, and finish.

Now the bad parts: bad coloring (for example, the operator color is not configurable), gocode doesn't work (even when GOPATH and GOROOT already configured on settings page and restarted), and autocomplete doesn't work at all.

Next we'll try IntelliJ with Golang IDEA plugin, first you must clone the repository:

git clone --depth 1 https://github.com/go-lang-plugin-org/go-lang-idea-plugin.git

Then place (or symlink) the IntelliJ program directory inside that folder that created by git, with name idea-IC, then just run:

ant -f build-package.xml

That command would produce a file named: google-go-language.jar, just install that plugin normally using on IntelliJ.

Now the bad parts: member autocomplete doesn't work at all (even when GOROOT and GOPATH configured on settings page and restarted).



2014-11-25

Wide: Web-based IDE for Go

Wide is one new web-based IDE, it has a lot of potential, for now, it has autocomplete and one that have working "go to definition".

To install Wide, type:

go get -u -v github.com/88250/ide_stub
go get -u -v github.com/nsf/gocode
go get -u -v github.com/b3log/wide

To start the program, type:

cd $GOPATH/src/github.com/b3log/wide/
wide

Then visit using your browser on http://your_ip_address:7070


There are some other web-based IDE such as GoDev (lags when showing godoc), LimeText, Carpo, Atom (aur/atom-editor-bin), Brackets.io, and Conception-go (this one not a web-based :3 it's OpenGL)
Btw, I make a list on GoogleDocs to list all Go IDEs, you can contribute/edit it if you want..

2014-11-24

Database GUI for MongoDB

There are many database GUI for MongoDB, today I will review about GenghisApp, Humongous, and RoboMongo.

You could install the Ruby-based one using this command:

gem install humongous
gem install genghisapp bson_ext

to start it, use this command:

humongous # visit http://localhost:9000
genghisapp # visit http://localhost:8000
php -S localhost:8000 genghis.php # php version

to stop it, use this command:

humongous -K
genghisapp --kill

I don't know why but when I tried both, they are not running at all, just stopped after showing "trying port xxxx", those programs closes immediately after that, the program doesn't show up on ps and netstat.

The next in line is RoboMongo, first, you must download using this command:

wget -c http://robomongo.org/files/linux/robomongo-0.8.4-x86_64.tar.gz

Extract it, then run the robomongo.sh shell script on the bin/ folder, set the connection, then it would show up something like this:


This one quote good, it shows the command line when doing any action, but as usual, Java-based app doesn't work well with dark GTK+ theme.

There are some other GUI for MongoDB that support live-monitoring, for example MongoBird and MongOwl, but don't forget, there are also built-in web monitoring on port 28017.

2014-11-15

How to Prevent ISP's DNS Poisoning

The case was, my fourth ISP redirect every DNS request to their own DNS servers, and the poison certain domain names (for example: Manga sites) to their own server (114.127.223.16). How to prevent this? first of all you'll need to install dnscrypt, this program could encrypt DNS requests, so it's become harder to poison.

pacman -Sy dnscrpyt-proxy

then you'll need to start the service:

sudo systemctl enable dnscrypt-proxy
sudo systemctl start dnscrypt-proxy

then, change your /etc/resolv.conf to localhost:

nameserver 127.0.0.1

voila, now your DNS resolving not poisoned anymore :3 yayy~

2014-11-04

How to start Revel, GORM with PostgreSQL project on Archlinux

Revel is one of many Go Web Application Framework that uses Go programming language. After installing Archlinux, first of all you'll need to install yaourt, the easiest way to install AUR packages. After that you'll need to run this command:

yaourt -Sy --noconfirm go postgresql postgresql-libs liteide chromium google-chrome-stable

Then setup your GOPATH and GOROOT environment variables on your .bashrc

export GOROOT=/usr/lib/go
export GOPATH=$HOME/Dropbox/go
export PATH="$PATH:$GOPATH/bin"


Change the permission of this folder:

sudo chmod -Rv a+rwx /usr/share/liteide/liteenv

Then open LiteIDE, select menu View > Edit Environment, then add this line and save:

GOROOT=/usr/lib/go

Add also a GOPATH directory on menu View > Manage GOPATH...
That is ~/Dropbox/go on my computer.

To test if your Go and LiteIDE working correctly, create a new .go file and press Build > FileRun to run, for example:

package main
import "fmt"
func main() {
  fmt.Println("Hello my PC <3")
}

The code above should give an output on Build output window.

To install revel, type this on shell:

go get -u -v github.com/revel/cmd/revel
go get -u -v github.com/revel/revel


To create a new project (for example, the name would be "puis"), type:

cd $GOPATH
revel new puis

Then you could start the app using this command:

revel run puis

And visit http://localhost:9000 to view your app.

Next, we should install PostgreSQL driver and GORM, type:

go get -u -v github.com/lib/pq
go get -u -v github.com/jinzhu/gorm

Then initialize and start your database server:

sudo su - postgres
initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'
exit
sudo systemctl enable postgresql
sudo systemctl start postgresql
sudo su - postgres
createuser puis
createdb puis
psql 
GRANT ALL PRIVILEGES ON DATABASE puis TO puis;
\q
exit

Then create a model, for example in app/models/user.go

package models
import "time"
type User struct {
  Id                int64
  Name              string
  Gmail             string
  PuMail            string
  Password          string
  CreatedAt         time.Time
  UpdatedAt         time.Time
  DeletedAt         time.Time
  LastLoginAt       time.Time
  PasswordUpdatedAt time.Time
}

And create a controller for GORM in app/controllers/gorm.go

package controllers
import (
  "database/sql"
  "github.com/jinzhu/gorm"
  _ "github.com/lib/pq"
  "github.com/revel/revel"
  "puis/app/models"
)
type GormController struct {
  *revel.Controller
  Tx *gorm.DB
}
var Db gorm.DB
func InitDB() {
  var err error
  Db, err = gorm.Open("postgres", "user=puis sslmode=disable")
  if err != nil {
    revel.ERROR.Println("FATAL", err)
    panic(err)
  }
  tab := &models.User{}
  Db.AutoMigrate(tab)
  Db.Model(tab).AddUniqueIndex("idx_user__gmail", "gmail")
  Db.Model(tab).AddUniqueIndex("idx_user__pu_mail", "pu_mail")
}
func (c *GormController) Begin() revel.Result {
  txn := Db.Begin()
  if txn.Error != nil {
    panic(txn.Error)
  }
  c.Tx = txn
  revel.INFO.Println("c.Tx init", c.Tx)
  return nil
}
func (c *GormController) Commit() revel.Result {
  if c.Tx == nil {
    return nil
  }
  c.Tx.Commit()
  if err := c.Tx.Error; err != nil && err != sql.ErrTxDone {
    panic(err)
  }
  c.Tx = nil
  revel.INFO.Println("c.Tx commited (nil)")
  return nil
}

func (c *GormController) Rollback() revel.Result {
  if c.Tx == nil {
    return nil
  }
  c.Tx.Rollback()
  if err := c.Tx.Error; err != nil && err != sql.ErrTxDone {
    panic(err)
  }
  c.Tx = nil
  return nil
}

Also call those functions when application starts also before and after controller calling, add these lines in app/init.go on func init()

revel.OnAppStart(controllers.InitDB)
revel.InterceptMethod((*controllers.GormController).Begin, revel.BEFORE)
revel.InterceptMethod((*controllers.GormController).Commit, revel.AFTER)
revel.InterceptMethod((*controllers.GormController).Rollback, revel.FINALLY)

Two more things, add a testing code, for example in app/controllers/app.go on func Index()

user := &models.User{Name: "Kiswono Prayogo"}
c.Tx.NewRecord(user)
c.Tx.Create(user)
return c.Render(user) 

Last thing, just add one more line anywhere on Index.html

{{.user.Name}}

That's it, this is how to connect Revel to PostgreSQL using GORM. This tutorial adapted from Ivan Black's stackoverflow answer.

To solve slow Revel hot-reload or Go build/install, just use this command:

go get -u -v github.com/mattn/go-sqlite3

2014-08-23

How to change resolution that doesn't exists on display settings on Linux

Sometimes we need to change the resolution of our monitor, but the resolution doesn't show up on the xfce4-display-settings, what should we do? First you'll need a terminal or command prompt, then type cvt or gtf command with your desired resolution, for example:

cvt 1920 1080 

it would show something like this:

# 1920x1080 59.96 Hz (CVT 2.07M9) hsync: 67.16 kHz; pclk: 173.00 MHz Modeline "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync

now, you should add it using xrandr command:

xrandr --newmode "1920x1080"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync

now, assign it the desired display port from the graphics card, first let see our graphic card available ports, type xrandr again without parameter, it would show something like this:

Screen 0: minimum 8 x 8, current 1600 x 1200, maximum 32767 x 32767
VGA1 connected primary 1600x1200+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1024x768      70.07 +  85.00    75.08    60.00 
   1600x1200     60.00* 
   1280x1024     85.02    75.02 
   1440x900      59.89
   1280x960      85.00
   1280x800      59.81
   1152x864      75.00 
   1024x768      86.96 
   832x624       74.55
   800x600       85.06    72.19    75.00    60.32    56.25 
   640x480       85.01    75.00    72.81    66.67    60.00
   720x400       87.85    70.08
HDMI1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
  1920x1080 (0x2ee) 173.000MHz
    h: width  1920 start 2048 end 2248 total 2576 skew 0 clock  67.16KHz
    v: height 1080 start 1083 end 1088 total 1120 clock  59.96Hz

Now we know that we have 3 ports: VGA1, HDMI1 and VIRTUAL1, of course the current monitor was plugged into VGA1 because it shows "connected", now we could assign using this command:

xrandr --addmode VGA1 1920x1080 

and set the display resolution using this command:

xrandr --output VGA1 --mode 1920x1080

Voila, now your resolution changed!

Note: if you're using VGA Video Splitter, make sure that the monitor plugged into the first port, so it would send correct EDID.

SLock simplest screen locker ever!

SLock is the simplest screen locker ever, it works without hassle or configuration. If you havent isntall any of screensaver (gnome-screensaver, xscreensaver), you could use it as the default screensaver. B-b-b-but how to unlock the screen? there's no password box to type '____' ?

You just need to type your password (screen would change color as you type first letter) and press enter to unlock the screen.

What if I have inputted wrong password? just press backspace or enter to restart inputting the password.

How to lock the screen? just type slock on terminal or run-dialog.

Well.. that's all for now~

Where to put fonts on Linux

To install fonts on Linux (especially Arch Linux), you must copy the fonts on the ~/.local/share/fonts folder (for old distribution, use ~/.fonts directory). To view fonts, install gnome-font-viewer, that program could also be used to install fonts locally. I have selected some fonts that good for programming imho. Contact me (if you can ^^ myahahah!) if the server is down or expired, or just google for these fonts:

BPmono.ttf BPmonoBold.ttf BPmonoItalics.ttf DejaVuSans-Bold.ttf DejaVuSans-BoldOblique.ttf
DejaVuSans-ExtraLight.ttf DejaVuSans-Oblique.ttf DejaVuSans.ttf DejaVuSansCondensed-Bold.ttf DejaVuSansCondensed-BoldOblique.ttf
DejaVuSansCondensed-Oblique.ttf DejaVuSansCondensed.ttf DejaVuSansMono-Bold.ttf DejaVuSansMono-BoldOblique.ttf DejaVuSansMono-Oblique.ttf
DejaVuSansMono.ttf DejaVuSerif-Bold.ttf DejaVuSerif-BoldItalic.ttf DejaVuSerif-Italic.ttf DejaVuSerif.ttf
DejaVuSerifCondensed-Bold.ttf DejaVuSerifCondensed-BoldItalic.ttf DejaVuSerifCondensed-Italic.ttf DejaVuSerifCondensed.ttf DroidSansMono.ttf
Envy Code B 10pt.ttf Envy Code R Bold.ttf Envy Code R Italic.ttf Envy Code R VS Italic-as-bold.ttf Envy Code R VS.ttf
Envy Code R.ttf FantasqueSansMono-Bold.ttf FantasqueSansMono-BoldItalic.ttf FantasqueSansMono-RegItalic.ttf FantasqueSansMono-Regular.ttf
FiraMono-Bold.ttf FiraMono-Medium.ttf FiraMono-Regular.ttf FiraSans-Bold.ttf FiraSans-BoldItalic.ttf
FiraSans-Book.ttf FiraSans-BookItalic.ttf FiraSans-Eight.ttf FiraSans-EightItalic.ttf FiraSans-ExtraBold.ttf
FiraSans-ExtraBoldItalic.ttf FiraSans-ExtraLight.ttf FiraSans-ExtraLightItalic.ttf FiraSans-Four.ttf FiraSans-FourItalic.ttf
FiraSans-Hair.ttf FiraSans-HairItalic.ttf FiraSans-Heavy.ttf FiraSans-HeavyItalic.ttf FiraSans-Italic.ttf
FiraSans-Light.ttf FiraSans-LightItalic.ttf FiraSans-Medium.ttf FiraSans-MediumItalic.ttf FiraSans-Regular.ttf
FiraSans-SemiBold.ttf FiraSans-SemiBoldItalic.ttf FiraSans-Thin.ttf FiraSans-ThinItalic.ttf FiraSans-Two.ttf
FiraSans-TwoItalic.ttf FiraSans-Ultra.ttf FiraSans-UltraItalic.ttf FiraSans-UltraLight.ttf FiraSans-UltraLightItalic.ttf
LiberationMono-Bold.ttf LiberationMono-BoldItalic.ttf LiberationMono-Italic.ttf LiberationMono-Regular.ttf LiberationSans-Bold.ttf
LiberationSans-BoldItalic.ttf LiberationSans-Italic.ttf LiberationSans-Regular.ttf LiberationSerif-Bold.ttf LiberationSerif-BoldItalic.ttf
LiberationSerif-Italic.ttf LiberationSerif-Regular.ttf MesloLGLDZ-Bold.ttf MesloLGLDZ-BoldItalic.ttf MesloLGLDZ-Italic.ttf
MesloLGLDZ-Regular.ttf MesloLGMDZ-Bold.ttf MesloLGMDZ-BoldItalic.ttf MesloLGMDZ-Italic.ttf MesloLGMDZ-Regular.ttf
MesloLGSDZ-Bold.ttf MesloLGSDZ-BoldItalic.ttf MesloLGSDZ-Italic.ttf MesloLGSDZ-Regular.ttf Monaco.ttf
PTM55F.ttf PTM75F.ttf VeraMono-Bold-Italic.ttf VeraMono-Bold.ttf VeraMono-Italic.ttf
VeraMono.ttf drucifer_0.ttf drucifer_i.ttf edlo.ttf mplus-1c-black.ttf
mplus-1c-bold.ttf mplus-1c-heavy.ttf mplus-1c-light.ttf mplus-1c-medium.ttf mplus-1c-regular.ttf
mplus-1c-thin.ttf mplus-1m-bold.ttf mplus-1m-light.ttf mplus-1m-medium.ttf mplus-1m-regular.ttf
mplus-1m-thin.ttf mplus-1mn-bold.ttf mplus-1mn-light.ttf mplus-1mn-medium.ttf mplus-1mn-regular.ttf
mplus-1mn-thin.ttf mplus-1p-black.ttf mplus-1p-bold.ttf mplus-1p-heavy.ttf mplus-1p-light.ttf
mplus-1p-medium.ttf mplus-1p-regular.ttf mplus-1p-thin.ttf mplus-2c-black.ttf mplus-2c-bold.ttf
mplus-2c-heavy.ttf mplus-2c-light.ttf mplus-2c-medium.ttf mplus-2c-regular.ttf mplus-2c-thin.ttf
mplus-2m-bold.ttf mplus-2m-light.ttf mplus-2m-medium.ttf mplus-2m-regular.ttf mplus-2m-thin.ttf
mplus-2p-black.ttf mplus-2p-bold.ttf mplus-2p-heavy.ttf mplus-2p-light.ttf mplus-2p-medium.ttf
mplus-2p-regular.ttf mplus-2p-thin.ttf

How to Install VirtualBox 4.3.14 on ArchLinux

VirtualBox is one of many virtualization software that could be run on Linux, one with slowest cpu performance according to this article. Installing VirtualBox is quite simple, but to make it run you must also install certain package. To install VirtualBox, type:

yaourt --needed --noconfirm -S --force virtualbox virtualbox-host-modules linux-headers

To make it able to run, you must create the kernel module first, the easiest way is using dkms:

sudo dkms autoinstall

or

sudo dkms vboxhost/4.3.14

then enable it using:

sudo modprobe vboxdrv

Now you can start and run VirtualBox images without error.
if you want to auto-recompile when installing new kernel, use this command:

sudo systemctl enable dkms


Installing Go 1.3.1 with LiteIDE x23.2 on Arch Linux

So I installing new computer on my company, using Arch Linux as usual.

How to install Go? it's really easy when using yaourt, just type:

yaourt --needed --noconfirm -S --force go mercurial git bzr subversion liteide gdb

Go took about 40.76 MB
Mercurial, Git, Bzr and Subversion requires about 13.12 MB
LiteIDE took about 13.14 MB
Gdb took about 3.06 MB

Set your working directory:

mkdir ~/go
export GOPATH=~/go
export PATH=$PATH:~/go/bin


I suggest that you should put those environment variables on .bashrc

Then you can test the installation, create a file named test1.go

package main
import "fmt"
func main() {
  fmt.Println("Hello my lovely PC :3")
}


Run it using:

go run test1.go 

or

go build test1.go && ./test1

or press Ctrl+R on LiteIDE.

2014-08-21

Which program that uses the bandwidth the most?

So, my boarding house internet connection has been down for 4 days now, and I decided to find alternate internet connection. On Indonesia it's really hard to find mobile internet provider that has unlimited bandwidth without FUP. I decided to use one with limited quota (8GB/month) T__T seriously.. 8GB it's my daily usage, not monthly. So I buy a router with modem support (TP-Link Wireless N Router TL-MR3420) a modem (Huawei E173) and GSM card for internet (Three). Long story short, I want to know which program that uses so much bandwidth since the beginning, so I install nethogs). That program should be used as root, and the first argument is default to eth0. Nethogs will show the list of process that uses most bandwith.




2014-08-11

How to make git ignore changes on commited files?

Sometimes there are some file that we want to ignore some file on git, of course we could use .gitignore, but that only take effect on untracked files. When the files already tracked/commited, we could make that file changes ignored using git update-index command, for example:

git update-index --assume-unchanged file-to-be-ignored

From now on, that file would not appear on git status or git diff when changed. When you want to track back the changes, use --no-assume-unchanged flag.

What to do when git pull conflict before commit?

Sometimes we want to pull from git without committing current changes, and yes, the correct way is to commit our changes first before pulling, so we could merge the conflict. But if you doesn't want to do that, there are some trick that you could use, that is git stash, the usage example:

# to store all changes on the stash
git stash
# this should no longer conflict
git pull
# to overwrite from previous stash
git stash pop
# you could see the difference using
git diff

2014-08-05

How to setup SSH Tunneling (SOCKS) Proxy

Sometimes we need to connect to some site via a very secure way without our nearby computers able to see (or sniff) which sites we are visiting, or to prevent any blocking from our LAN's firewall. One easy solution to solve this, but you'll need a VPS (Virtual Private Server) with public IP address of course, all you have to do is start a SSH connection to your VPS, for example:

sudo ssh -D my_local_port my_vps_user@my_vps_public_ip

for example:

ssh -D 8081 aurora@w.x.y.z

Then, setup your browser to use SOCKS to localhost:my_local_port, for example:


Voila, now everything that you browse will encrypted through to w.x.y.z.

2014-08-04

Open Source Desktop Database GUI

When developing database apps sometimes we need easier user interface to query the database, instead of using command line (mysql for MySQL, psql for PostgreSQL), or using MySQL Workbench or the default pgAdmin. When you're using any of IDE from JetBrains you could use their Database Explorer.

DBeaver is one open source and cross platform database explorer, but it doesn't really work well with dark theme.
SQL Workbench also open source java-based database explorer, works fine with dark theme, but failed to display invalid Date.
Execute Query quite fine, I have no rants about this one.
Oh well I'll find and try another later on.

2014-07-31

How to set Komodo Edit as Go IDE with komodo-go

LiteIDE 23.1 is quite good enough IDE for Go in my opinion, the autocomplete and method hint works fine. All we need after installing is just configure the Environment file (View > Edit Environment) such as this:

GOROOT=/usr/lib/go
GOBIN=/home/kyz/Dropbox/go/bin

Don't forget to change the ownership or you won't able to save:

sudo chown `whoami` /usr/share/liteide/liteenv/*

Also don't forget to add custom GOPATH (View > Manage GOPATH..) if necessary


But sometimes the jump to declaration feature doesn't work at all.
There are another alternative that is komodo-edit, you can install it using:

pacman -Sy komodo-edit

Then you could clone the komodo-go repository:

cd /tmp
git clone https://github.com/Komodo/komodo-go
cd komodo-go

Make sure that you have installed Python 2.x, and then just built the extension

/opt/komodo-edit/lib/sdk/bin/koext build

Then drag the .xpi file into Komodo Extension Manager.
Now, install godef to make it support jump to declaration command:

go get -u -v code.google.com/p/rog-go/exp/cmd/godef

Now your komodo-edit with Go integration will work as expected.



2014-07-30

Tracking or auditing Linux configuration changes

As a paranoid user, we sometimes want to know what configuration changed since we install something or upgrading using apt-get upgrade or pacman -Syu. We can use git to track changes in our filesystem, for example:

cd /
sudo git init .

create .gitignore file containing, for example:

/bin
/boot
/dev
/lib
/lib64
/media
/proc
/root
/run
/sbin
/sys
/tmp
/usr

/opt
/var

/etc/ld.so.cache

/home/whoami/.cache
/home/whoami/.xsession-errors
/home/whoami/.viminfo
/home/whoami/.bash_history
/home/whoami/.wine
/home/whoami/.config/pulse
/home/whoami/.gstreamer-0.10
/home/whoami/.local/share/recently-used.xbel
/home/whoami/.local/share/gvfs-metadata


and then just add it to our repository:

git add .
git commit -m 'initial filesystem'

After that, just run the package manager's upgrade system command. When there are changes, we could see which files/folders that changed, by typing:

git status




And see the changes for one file:

git diff /path/to/file



This trick also can be used to track history or backup your system's configuration, just use private repository on bitbucket.