Showing posts with label tools. Show all posts
Showing posts with label tools. Show all posts

2015-02-24

State of Go REPL (February 2015)

REPL is one thing that quite important to test simple snippet, useful to make sure that a part of code would work as expected. Previously I have tried go-repl, go-eval, rango, but none of them enjoyable to use.

One of the promising one is go-fish, with limited import option, you can install it using these commands:

go get -u -v github.com/rocky/go-types
go get -u -v github.com/rocky/go-loader
go get -u -v github.com/rocky/go-fish
go build make_env.go
make
mv go-fish $GOPATH/bin

One thing that annoys me is no history (Up/Down key) and limited set of import (that can be added), but I haven't found a way to import package on runtime.


Another one that quite promising is gore, to install it use run these commands:

# workaround for moved astutil repository
mkdir $GOPATH/src/golang.org/x/tools/go/ast
ln -s $GOPATH/src/golang.org/x/tools/astutil $GOPATH/src/golang.org/x/tools/go/ast

go get -u -v github.com/nsf/gocode
go get -u -v github.com/k0kubun/pp 
go get -u -v github.com/davecgh/go-spew

go get -u -v golang.org/x/tools/cmd/godoc
go get -u -v github.com/motemen/gore

Gore is one that works fine, to import package use colon, import and package name without quote, for example:

:import fmt

You can also use Tab key for auto complete, Up/Down key to see typed commands, Ctrl+D for canceling last command, but you cannot erase 1 previous word using Alt+Backspace. I think this program has the less annoyance than other alternatives.



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-08-23

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


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-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-28

Keep commands even when SSH disconnected (byobu)

Sometimes we need to run a command over SSH, but when SSH session disconnected that command will be also terminated. There are some solution to overcome this, that is create a service, nohup or use terminal multiplexer such as screen or byobu. Using Byobu, you can run multiple commands using single SSH session, the terminal that shown will be appear exactly the same over multiple computer that connected as the same user. To install byobu you can run this command on Ubuntu:

sudo apt-get install byobu

or when using ArchLinux:

sudo pacman -Sy byobu

There are some important shortcut to remember:

  • F2 to create tab (or subsession)
  • F3 to switch to previous tab
  • F4 to switch to next tab
  • F6 to exit from byobu, but the commands would keep running, type byobu on shell to get back to last session
  • shift+F2 to split horizontally
  • ctrl+F2 to split vertically
  • shift+F3/F4 to switch between split region
  • ctrl+F3/F4 to swap between split region
  • alt+PgUp/PgDn to enter scrollback mode (not shift+PgUp/PgDn like normal terminal)
Here's some screenshot about Byobu in action:


Better Grep, Grep files with line numbers (ag)

Sometimes when programming on my old Netbook (that not powerful enough top open any IDE, so I must use just a standard text editor such as Vim or GEdit), I need to quickly search some string (function, symbol or signature) on all source code in my project, that I will use:

grep -n Symbol *.rb */*.rb */*/*.rb

(-n is line number, Symbol is the search string) that will show something like this:


Now I found a better way, The Silver Searcher! Ag (argentum, latin name for Silver), when using Ubuntu, you could install it using this command:

sudo apt-get install silversearcher-ag

or when using ArchLinux:

sudo pacman -Sy the_silver_searcher

and use it just like grep ^_^)b for example:

ag --ruby Symbol .

(--ruby means all ruby source code, dot means only on current directory, recursively) that will show something like this: 





Linux Command Line Hardware Specs Information (inxi)

So today I tried to print my PCs specs, normally I use /proc/cpuinfo, free, or lspci and its friends, but I found something new :3 inxi!
If you're using Ubuntu/Debian-based, you can install it using:

sudo apt-get install inxi

or when using ArchLinux:

pacman -Sy inxi

When executed on console, it would output something like this:

on my office's server (VMWare, ArchLinux):

CPU(s)~4 Single core Intel Xeon E5-2407 0s (-SMP-) clocked at 2200 Mhz Kernel~3.14.1-1-ARCH i686 Up~5 days Mem~361.6/2019.6MB HDD~34.4GB(48.6% used) Procs~103 Client~Shell inxi~2.1.28 

on my VPS (OpenVZ, Ubuntu):

CPU~Quad core Intel Xeon CPU E3-1230 V2 (-HT-MCP-) clocked at 3300.082 Mhz Kernel~2.6.32-042stab090.5 x86_64 Up~2 days Mem~33.9/1024.0MB HDD~NA(-) Procs~37 Client~Shell inxi~1.9.17 

on my current PC:

CPU~Quad core AMD A8-6600K APU with Radeon HD Graphics (-MCP-) clocked at Min:1900.000Mhz Max:3900.000Mhz Kernel~3.15.5-2-ARCH x86_64 Up~2 days Mem~5845.2/15436.9MB HDD~12674.6GB(71.4% used) Procs~242 Client~Shell inxi~2.1.28

on my office PC:

CPU~Dual core Intel Core i3-4130 (-HT-MCP-) clocked at Min:3400.000Mhz Max:3400.265Mhz Kernel~3.16.1-1-ARCH x86_64 Up~2 days Mem~7087.3/15743.8MB HDD~1120.2GB(5.7% used) Procs~194 Client~Shell inxi~2.2.1

as you can see, it shows up quite useful information ^_^)b, and when you run it using -F flag, it will show up something like this: