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.
programming: the action or process of writing computer programs. | rants: speak or shout at length in a wild, [im]passioned way.
2014-07-30
Easier ArchLinux-based Distribution
So, maybe you're a newbie who wants to use ArchLinux, but scared with it's installation, well well, we have some ArchLinux-based distribution for you from:
Maybe some poeple ask, why ArchLinux or Arch-based distribution? well.. because it's easy to install almost anything, easy (automated) to build programs from source via AUR. Why I chose ArchLinux? Umm.. because I'm hipster XD (Ubuntu, Mint, Debian, Fedora, Zorin, PCLinuxOS, CentOS are too mainstream). Things to read or consider before migrating or decide using ArchLinux:
- http://wiki.archlinux.org/index.php/Arch_based_distributions_(active)
- http://distrowatch.com/search.php?basedon=Arch
Maybe some poeple ask, why ArchLinux or Arch-based distribution? well.. because it's easy to install almost anything, easy (automated) to build programs from source via AUR. Why I chose ArchLinux? Umm.. because I'm hipster XD (Ubuntu, Mint, Debian, Fedora, Zorin, PCLinuxOS, CentOS are too mainstream). Things to read or consider before migrating or decide using ArchLinux:
- http://wiki.archlinux.org/index.php/The_Arch_Way
- http://wiki.archlinux.org/index.php/Arch_compared_to_other_distributions
- http://wiki.archlinux.org/index.php/Pacman_Rosetta
- http://en.wikipedia.org/wiki/Comparison_of_Linux_distributions
- http://blog.srvthe.net/archlinux-vs-gentoo/
- http://beej.us/blog/data/arch-vs-slackware/
- http://distrowatch.com/dwres.php?resource=major
- http://distrowatch.com/dwres.php?resource=package-management
- https://www.digitalocean.com/community/tutorials/how-to-use-yaourt-to-easily-download-arch-linux-community-packages
2014-07-28
Xfce4 CPU, RAM, Network and Disk Monitoring Applet
When using Gnome or Xfce4, I always have the urge to monitor CPU, RAM, network and disk usage/throughput. This is the screenshot of my xfce4 panel:
To make it happened, I modified Ciriaco's source code to suit my need:
curl -L http://goo.gl/MO3lx5 > netmon.cpp
g++ -O3 -lrt netmon.cpp -o netmon
sudo mv netmon /usr/bin/
So when netmon program executed, it would give an XML ouput (note that enp1s0 is my network interface name):
netmon enp1s0
<txt>D: 312 KB/s | U: 15 KB/s | CPU: 12% | RAM: 7008 MB | sdc: . . | sda: . . | sdb: . 1 | sdf: . . | sde: . . | sdd: . . | sdg: . .</txt><tool> enp1s0:
3102.07 MB received
261.08 MB sent
CPU usage:
15.6% since boot
RAM usage:
45.4% of 15436 MB</tool>
The next step is installing Generic Monitor Applet:
yaourt -Sy xfce4-genmon-plugin
Add it to your panel (right click on panel > Panel > Add New Item..), and configure it:
And your CPU, RAM, network and disk is now appeared on the panel ^_^)b
Disk monitoring notes:
To make it happened, I modified Ciriaco's source code to suit my need:
curl -L http://goo.gl/MO3lx5 > netmon.cpp
g++ -O3 -lrt netmon.cpp -o netmon
sudo mv netmon /usr/bin/
So when netmon program executed, it would give an XML ouput (note that enp1s0 is my network interface name):
netmon enp1s0
<txt>D: 312 KB/s | U: 15 KB/s | CPU: 12% | RAM: 7008 MB | sdc: . . | sda: . . | sdb: . 1 | sdf: . . | sde: . . | sdd: . . | sdg: . .</txt><tool> enp1s0:
3102.07 MB received
261.08 MB sent
CPU usage:
15.6% since boot
RAM usage:
45.4% of 15436 MB</tool>
The next step is installing Generic Monitor Applet:
yaourt -Sy xfce4-genmon-plugin
Add it to your panel (right click on panel > Panel > Add New Item..), and configure it:
Disk monitoring notes:
- dot means idle
- zero means <1MB/s read/write
- others in MB/s
ArchLinux Installation Tutorial
ArchLinux is top 10 major Linux binary-based distribution, but in my opinion, it has the easiest source-based installation process. Here's my past experience of minimal installation process:
First, download latest .iso from https://www.archlinux.org/download/
You may want to burn it or dump to USB flashdrive using this command:
dd bs=4M if=/path/to/archlinux-yyyy.mm.dd-dual.iso of=/dev/your_usb_disk
the /dev/your_usb_disk could be found using dmesg or lsblk or gparted command, for example /dev/sdg
Things to do after preparing the boot CD/USB:
1. Boot your PC using that USB or CD/DVD.
2. Find out which partition or disk to be the installation target, normally I only create 1 or 2 partition that is / (root) for software and /home.
lsblk # find disk name
disk=/dev/vda
Create partition using cfdisk command, set bootable, set partition type (83), write and quit.
cfdisk $disk
Format partitions and mount it:
part=/dev/vda1
mkfs.ext4 $part
mount $part /mnt
3. Update repository, bootstrap and chroot, this process requires internet, make sure you're connected to the internet using DHCP cable connection.
pacman -Syy
pacstrap -i /mnt base base-devel vim bash openssh curl
genfstab -U -p /mnt >> /mnt/etc/fstab
arch-chroot /mnt
4. Configure language, I always prefer Canada and Indonesia, not US.
bash
loadkeys us
Uncomment en_CA.UTF-8 and id_ID.UTF-8, using vim or nano
vim /etc/locale.gen
locale-gen
export LANG=en_CA.UTF-8
5. Configure time, for example: Jakarta, Indonesia
location=/usr/share/zoneinfo/Asia/Jakarta
ln -s $location /etc/localtime
hwclock --systohc --utc
Clock correction:
current="2014-07-28 21:15:00"
date -s "$current"
6. Change name, use Google DNS, configure network and enable SSH
echo 'your_hostname' > /etc/hostname
echo nameserver 8.8.8.8 > /etc/resolv.conf
systemctl enable sshd
Uncomment PermitRootLogin yes:
vim /etc/ssh/sshd_config
Check your network device name, could be eno11, eth0, enp1s0, wlp2s1, or anything else.
ip link
dev=eno1
6a. For permanent DHCP
systemctl enable dhcpcd@$dev
6b. For static address
addr=192.168.20.41
nmask=24
bcast=192.168.20.255
gw=192.168.20.1
6b1. for permanent static address
echo "address=$ipaddr
netmask=$nmask
broadcast=$bcast
gateway=$gw
" > /etc/conf.d/network@interface
curl -L 'http://goo.gl/X8d8k9' > /etc/systemd/system/network@.service
systemctl enable network@$dev
6b2. For temporary static address (gone when reboot)
ip link set dev $dev up
ip addr add $addr/$nmask broadcast $bcast dev $dev
ip route add default via $gw
7. Enable 32-bit repository and set password
vim /etc/pacman.conf # uncomment multilib section
pacman -Sy
passwd # remember!
8. Install and configure bootloader, this part really complicated when you're using UEFI BIOS
pacman -S grub-bios os-prober
grub-install --recheck /dev/vda
grub-mkconfig -o /boot/grub/grub.cfg
9. reboot
exit
exit
reboot
Things to do after reboot:
1. Install yaourt, easy way to use AUR
echo '
[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/$arch
' >> /etc/pacman.conf
pacman -Syy
pacman -Sy yaourt
2. Install desktop environment, one of the lightest DE is Xfce4
pacman -S xfce4 xfce4-goodies gvim gnome-tweak-tool xfwm4 metacity firefox yakuake
First, download latest .iso from https://www.archlinux.org/download/
You may want to burn it or dump to USB flashdrive using this command:
dd bs=4M if=/path/to/archlinux-yyyy.mm.dd-dual.iso of=/dev/your_usb_disk
the /dev/your_usb_disk could be found using dmesg or lsblk or gparted command, for example /dev/sdg
Things to do after preparing the boot CD/USB:
1. Boot your PC using that USB or CD/DVD.
2. Find out which partition or disk to be the installation target, normally I only create 1 or 2 partition that is / (root) for software and /home.
lsblk # find disk name
disk=/dev/vda
Create partition using cfdisk command, set bootable, set partition type (83), write and quit.
cfdisk $disk
Format partitions and mount it:
part=/dev/vda1
mkfs.ext4 $part
mount $part /mnt
3. Update repository, bootstrap and chroot, this process requires internet, make sure you're connected to the internet using DHCP cable connection.
pacman -Syy
pacstrap -i /mnt base base-devel vim bash openssh curl
genfstab -U -p /mnt >> /mnt/etc/fstab
arch-chroot /mnt
4. Configure language, I always prefer Canada and Indonesia, not US.
bash
loadkeys us
Uncomment en_CA.UTF-8 and id_ID.UTF-8, using vim or nano
vim /etc/locale.gen
locale-gen
export LANG=en_CA.UTF-8
5. Configure time, for example: Jakarta, Indonesia
location=/usr/share/zoneinfo/Asia/Jakarta
ln -s $location /etc/localtime
hwclock --systohc --utc
Clock correction:
current="2014-07-28 21:15:00"
date -s "$current"
6. Change name, use Google DNS, configure network and enable SSH
echo 'your_hostname' > /etc/hostname
echo nameserver 8.8.8.8 > /etc/resolv.conf
systemctl enable sshd
Uncomment PermitRootLogin yes:
vim /etc/ssh/sshd_config
Check your network device name, could be eno11, eth0, enp1s0, wlp2s1, or anything else.
ip link
dev=eno1
6a. For permanent DHCP
systemctl enable dhcpcd@$dev
6b. For static address
addr=192.168.20.41
nmask=24
bcast=192.168.20.255
gw=192.168.20.1
6b1. for permanent static address
echo "address=$ipaddr
netmask=$nmask
broadcast=$bcast
gateway=$gw
" > /etc/conf.d/network@interface
curl -L 'http://goo.gl/X8d8k9' > /etc/systemd/system/network@.service
systemctl enable network@$dev
6b2. For temporary static address (gone when reboot)
ip link set dev $dev up
ip addr add $addr/$nmask broadcast $bcast dev $dev
ip route add default via $gw
7. Enable 32-bit repository and set password
vim /etc/pacman.conf # uncomment multilib section
pacman -Sy
passwd # remember!
8. Install and configure bootloader, this part really complicated when you're using UEFI BIOS
pacman -S grub-bios os-prober
grub-install --recheck /dev/vda
grub-mkconfig -o /boot/grub/grub.cfg
9. reboot
exit
exit
reboot
Things to do after reboot:
1. Install yaourt, easy way to use AUR
echo '
[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/$arch
' >> /etc/pacman.conf
pacman -Syy
pacman -Sy yaourt
2. Install desktop environment, one of the lightest DE is Xfce4
pacman -S xfce4 xfce4-goodies gvim gnome-tweak-tool xfwm4 metacity firefox yakuake
3. Install graphic card drivers, this part not required when using intel
# for Nvidia
pacman -Sy xf86-video-nouveau nouveau-dri lib32-nouveau-dri
modprobe nouveau
# for AMD/ATI
yaourt -Sy catalyst-hook catalyst-libgl catalyst-utils lib32-catalyst-utils lib32-opencl-catalyst opencl-catalyst
For intel graphic cards mostly you don't need to install additional things other than xorg.
Then reboot or try to start Xserver, see the /var/log/Xorg.0.log file when error
Then reboot or try to start Xserver, see the /var/log/Xorg.0.log file when error
echo exec startxfce4 > ~/.xinitrc
startx
4. Add another admin user
usrnm=your_username
useradd -m -g users -G wheel -s /bin/bash $usrnm
passwd your_username
echo "
%wheel ALL=(ALL) ALL
Defaults:$usrnm timestamp_timeout=86400
" >> /etc/sudoers
5. Install browsers, tools, etc
yaourt --needed --noconfirm -S --force google-chrome chromium traceroute net-tools vlc smplayer sshfs meld gedit bash-completion htop
And so on~ :3
yaourt --needed --noconfirm -S --force google-chrome chromium traceroute net-tools vlc smplayer sshfs meld gedit bash-completion htop
And so on~ :3
Installing HHVM on Ubuntu or ArchLinux
As we already know, HHVM is the fastest PHP interpreter/JIT-compiler for 64-bit systems. To install HHVM on Ubuntu, the easiest way is use the PPA using these commands:
# install HHVM repos' public key
wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -
# add HHVM repos
echo deb http://dl.hhvm.com/ubuntu trusty main | sudo tee /etc/apt/sources.list.d/hhvm.list
# update list of available software
sudo apt-get update
# install hhvm
sudo apt-get install hhvm
Or when using archlinux, use yaourt command (warning: this would compile the hhvm package, that requires about ~1 hour and more than 2GB of RAM, so add a virtual memory if your RAM not big enough)
sudo yaourt --needed --noconfirm -S --force hhvm
As we already know, since PHP 5.4, PHP can be used without installing any webserver (Apache, Nginx, IIS), use this command to run built-in web server on localhost:8083:
hhvm -m server -p 8083
mapping self...
mapping self took 0'00" (18015 us) wall time
loading static content...
loading static content took 0'00" (0 us) wall time
page server started
all servers started
or when using standard PHP:
php -S localhost:8083
PHP 5.5.15 Development Server started at Mon Jul 28 20:48:06 2014
Listening on http://localhost:8083
Document root is /tmp
Press Ctrl-C to quit.
# install HHVM repos' public key
wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -
# add HHVM repos
echo deb http://dl.hhvm.com/ubuntu trusty main | sudo tee /etc/apt/sources.list.d/hhvm.list
# update list of available software
sudo apt-get update
# install hhvm
sudo apt-get install hhvm
Or when using archlinux, use yaourt command (warning: this would compile the hhvm package, that requires about ~1 hour and more than 2GB of RAM, so add a virtual memory if your RAM not big enough)
sudo yaourt --needed --noconfirm -S --force hhvm
As we already know, since PHP 5.4, PHP can be used without installing any webserver (Apache, Nginx, IIS), use this command to run built-in web server on localhost:8083:
hhvm -m server -p 8083
mapping self...
mapping self took 0'00" (18015 us) wall time
loading static content...
loading static content took 0'00" (0 us) wall time
page server started
all servers started
or when using standard PHP:
php -S localhost:8083
PHP 5.5.15 Development Server started at Mon Jul 28 20:48:06 2014
Listening on http://localhost:8083
Document root is /tmp
Press Ctrl-C to quit.
Create swap file or virtual memory without partition
In my experience, Linux is an OS that quite require much RAM, especially for running software that was should be executed using Virtual Machines. When our programs using more than available memory, the OS will be unresponsive, to solve those problem, we could virtually add more RAM using disk. Here's some example to add 8GB swapfile to our system:
# create new file on "/swapfile" with size 1MB * 8192 = 8GB
sudo dd if=/dev/zero of=/swapfile bs=1048576 count=8192
# format the newly created file as swap and give correct permissions
sudo mkswap /swapfile
sudo chmod 0600 /swapfile
# enable swap temporarily (swap will be gone when computer restart)
sudo swapon /swapfile
# add configuration on fstab to enable swap on boot
echo /swapfile swap swap defaults 0 0 | sudo tee -a /etc/fstab
to check swap usage, use free -m command.
# create new file on "/swapfile" with size 1MB * 8192 = 8GB
sudo dd if=/dev/zero of=/swapfile bs=1048576 count=8192
# format the newly created file as swap and give correct permissions
sudo mkswap /swapfile
sudo chmod 0600 /swapfile
sudo swapon /swapfile
# add configuration on fstab to enable swap on boot
echo /swapfile swap swap defaults 0 0 | sudo tee -a /etc/fstab
to check swap usage, use free -m command.
Installing Ruby 2.1+ on Ubuntu (via RVM)
On some distro, Ruby interpreter was out of date
apt-cache show ruby2.0 | grep Version
Version: 2.0.0.484-1ubuntu2
And we want the latest version, we could use Brightbox's PPA:
# install add-apt-repository command
sudo apt-get install software-properties-common python-software-properties
# add brightbox's repository
apt-cache show ruby2.0 | grep Version
Version: 2.0.0.484-1ubuntu2
And we want the latest version, we could use Brightbox's PPA:
# install add-apt-repository command
sudo apt-get install software-properties-common python-software-properties
# add brightbox's repository
sudo apt-add-repository ppa:brightbox/ruby-ng
# update list of available software
sudo apt-get update
# install ruby
sudo apt-get install ruby2.1
Or use RVM, the Ruby Version Manager, that could be installed using these commands:
# install rvm
curl -sSL https://get.rvm.io | bash
# use rvm (or relogin/restart bash, since it's inserted into .bashrc)
source /etc/profile.d/rvm.sh
to see the list of available version, we could use:
rvm list known
to install the latest version, run this command:
rvm install ruby-2.1.2
ruby-2.1.2 - #removing src/ruby-2.1.2..
ruby-2.1.2 - #removing rubies/ruby-2.1.2..
Searching for binary rubies, this might take some time.
Found remote file https://rvm.io/binaries/ubuntu/14.04/x86_64/ruby-2.1.2.tar.bz2
Checking requirements for ubuntu.
Requirements installation successful.
ruby-2.1.2 - #configure
ruby-2.1.2 - #download
######################################################################## 100.0%
ruby-2.1.2 - #validate archive
ruby-2.1.2 - #extract
ruby-2.1.2 - #validate binary
ruby-2.1.2 - #setup
ruby-2.1.2 - #gemset created /usr/local/rvm/gems/ruby-2.1.2@global
ruby-2.1.2 - #importing gemset /usr/local/rvm/gemsets/global.gems....................................
ruby-2.1.2 - #generating global wrappers........
ruby-2.1.2 - #gemset created /usr/local/rvm/gems/ruby-2.1.2
ruby-2.1.2 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.1.2 - #generating default wrappers........
Making gemset ruby-2.1.2 pristine.............................................................
Making gemset ruby-2.1.2@global pristine..............................................................
ruby-2.1.2 - #removing rubies/ruby-2.1.2..
Searching for binary rubies, this might take some time.
Found remote file https://rvm.io/binaries/ubuntu/14.04/x86_64/ruby-2.1.2.tar.bz2
Checking requirements for ubuntu.
Requirements installation successful.
ruby-2.1.2 - #configure
ruby-2.1.2 - #download
######################################################################## 100.0%
ruby-2.1.2 - #validate archive
ruby-2.1.2 - #extract
ruby-2.1.2 - #validate binary
ruby-2.1.2 - #setup
ruby-2.1.2 - #gemset created /usr/local/rvm/gems/ruby-2.1.2@global
ruby-2.1.2 - #importing gemset /usr/local/rvm/gemsets/global.gems....................................
ruby-2.1.2 - #generating global wrappers........
ruby-2.1.2 - #gemset created /usr/local/rvm/gems/ruby-2.1.2
ruby-2.1.2 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.1.2 - #generating default wrappers........
Making gemset ruby-2.1.2 pristine.............................................................
Making gemset ruby-2.1.2@global pristine..............................................................
Voila, done! now we could use it using this command:
rvm use ruby-2.1.2
ruby --version
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
gem install pry
Fetching: coderay-1.1.0.gem ( 52%)
Fetching: coderay-1.1.0.gem (100%)
Successfully installed coderay-1.1.0
Fetching: slop-3.6.0.gem (100%)
Successfully installed slop-3.6.0
Fetching: method_source-0.8.2.gem (100%)
Successfully installed method_source-0.8.2
Fetching: pry-0.10.0.gem (100%)
Successfully installed pry-0.10.0
invalid options: -SNw2
(invalid options are ignored)
Parsing documentation for coderay-1.1.0
Installing ri documentation for coderay-1.1.0
Parsing documentation for method_source-0.8.2
Installing ri documentation for method_source-0.8.2
Parsing documentation for pry-0.10.0
Installing ri documentation for pry-0.10.0
Parsing documentation for slop-3.6.0
Installing ri documentation for slop-3.6.0
Done installing documentation for coderay, method_source, pry, slop after 4 seconds
4 gems installed
Fetching: coderay-1.1.0.gem (100%)
Successfully installed coderay-1.1.0
Fetching: slop-3.6.0.gem (100%)
Successfully installed slop-3.6.0
Fetching: method_source-0.8.2.gem (100%)
Successfully installed method_source-0.8.2
Fetching: pry-0.10.0.gem (100%)
Successfully installed pry-0.10.0
invalid options: -SNw2
(invalid options are ignored)
Parsing documentation for coderay-1.1.0
Installing ri documentation for coderay-1.1.0
Parsing documentation for method_source-0.8.2
Installing ri documentation for method_source-0.8.2
Parsing documentation for pry-0.10.0
Installing ri documentation for pry-0.10.0
Parsing documentation for slop-3.6.0
Installing ri documentation for slop-3.6.0
Done installing documentation for coderay, method_source, pry, slop after 4 seconds
4 gems installed
Installing Go 1.3+ on Ubuntu via GVM (Go Version Manager)
Sometimes on some Linux distribution, the Go package are out of date, for example:
apt-cache show golang | grep Version
Version: 2:1.2.1-2ubuntu1
and we look for the PPA (user repository) but failed to see the latest version!
One solution that we could use is using GVM that could be installed using this command:
# install dependencies
sudo apt-get install curl git mercurial make binutils bison gcc
apt-cache show golang | grep Version
Version: 2:1.2.1-2ubuntu1
and we look for the PPA (user repository) but failed to see the latest version!
One solution that we could use is using GVM that could be installed using this command:
# install dependencies
sudo apt-get install curl git mercurial make binutils bison gcc
# install gvm
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
# use gvm (or relogin/restart bash, since it's inserted into .bashrc)
source ~/.gvm/scripts/gvm
to see the list of available version, we could use:
gvm listall
to install Go 1.3, we could use this command:
gvm install go1.3
Installing go1.3...
* Compiling...
Voila, done! now we could use it using this command:
gvm use go1.3
Now using version go1.3
go version
go version go1.3 linux/amd64Keep 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:
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:
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:
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:
2014-06-26
Dark Theme for RubyMine and PHPStorm
Today I want to share my theme, that been inspired a lot by Turbo C++ (my first IDE that I used to code when I started studying on Informatics Engineering).
For RubyMine: https://gist.github.com/kokizzu/bb2dfbabd0b649812fe8
For PhpStorm: https://gist.github.com/kokizzu/af51dd79e5140064b03c
For RubyMine: https://gist.github.com/kokizzu/bb2dfbabd0b649812fe8
For PhpStorm: https://gist.github.com/kokizzu/af51dd79e5140064b03c
2014-06-19
Go 1.2.2 vs 1.3 Benchmark
Golang 1.3 is released, we'll see how much the difference in performance between both of them. Using autobench tool, here's the result on 64-bit Linux, i5-3470 CPU @ 3.20GHz:
# go1
# runtime
# http
# floats
# cipher
# megajson
# snappy
retry~
# go1
# runtime
# http
# floats
# cipher
# megajson
# snappy
# go1
benchmark old ns/op new ns/op delta BenchmarkBinaryTree17 4393668071 3439380995 -21.72% BenchmarkFannkuch11 2905431683 2571691532 -11.49% BenchmarkFmtFprintfEmpty 82.6 67.3 -18.52% BenchmarkFmtFprintfString 203 210 +3.45% BenchmarkFmtFprintfInt 171 158 -7.60% BenchmarkFmtFprintfIntInt 272 256 -5.88% BenchmarkFmtFprintfPrefixedInt 250 238 -4.80% BenchmarkFmtFprintfFloat 365 347 -4.93% BenchmarkFmtManyArgs 1024 1100 +7.42% BenchmarkGobDecode 7575925 7713419 +1.81% BenchmarkGobEncode 4223057 4591922 +8.73% BenchmarkGzip 381224443 373719944 -1.97% BenchmarkGunzip 1342948555 93186405 -93.06% BenchmarkHTTPClientServer 45743 44988 -1.65% BenchmarkJSONEncode 20200172 19540321 -3.27% BenchmarkJSONDecode 77714796 69865804 -10.10% BenchmarkMandelbrot200 4036132 4021347 -0.37% BenchmarkGoParse 4277297 4028435 -5.82% BenchmarkRegexpMatchEasy0_32 112 114 +1.79% BenchmarkRegexpMatchEasy0_1K 300 298 -0.67% BenchmarkRegexpMatchEasy1_32 92.9 97.6 +5.06% BenchmarkRegexpMatchEasy1_1K 783 766 -2.17% BenchmarkRegexpMatchMedium_32 169 181 +7.10% BenchmarkRegexpMatchMedium_1K 57654 63410 +9.98% BenchmarkRegexpMatchHard_32 2841 2915 +2.60% BenchmarkRegexpMatchHard_1K 92579 95782 +3.46% BenchmarkRevcomp 641546393 608532901 -5.15% BenchmarkTemplate 93262429 97820865 +4.89% BenchmarkTimeParse 388 391 +0.77% BenchmarkTimeFormat 349 342 -2.01% benchmark old MB/s new MB/s speedup BenchmarkGobDecode 101.31 99.51 0.98x BenchmarkGobEncode 181.75 167.15 0.92x BenchmarkGzip 50.90 51.92 1.02x BenchmarkGunzip 14.45 208.24 14.41x BenchmarkJSONEncode 96.06 99.31 1.03x BenchmarkJSONDecode 24.97 27.77 1.11x BenchmarkGoParse 13.54 14.38 1.06x BenchmarkRegexpMatchEasy0_32 285.59 279.63 0.98x BenchmarkRegexpMatchEasy0_1K 3405.77 3428.58 1.01x BenchmarkRegexpMatchEasy1_32 344.29 328.03 0.95x BenchmarkRegexpMatchEasy1_1K 1307.08 1335.30 1.02x BenchmarkRegexpMatchMedium_32 5.90 5.52 0.94x BenchmarkRegexpMatchMedium_1K 17.76 16.15 0.91x BenchmarkRegexpMatchHard_32 11.26 10.98 0.98x BenchmarkRegexpMatchHard_1K 11.06 10.69 0.97x BenchmarkRevcomp 396.18 417.67 1.05x BenchmarkTemplate 20.81 19.84 0.95x
# runtime
benchmark old ns/op new ns/op delta BenchmarkAppend 87.1 42.2 -51.55% BenchmarkAppend1Byte 115 102 -11.30% BenchmarkAppend4Bytes 107 98.4 -8.04% BenchmarkAppend8Bytes 105 103 -1.90% BenchmarkAppend16Bytes 109 102 -6.42% BenchmarkAppend32Bytes 110 110 +0.00% BenchmarkAppendSpecialCase 31.5 24.5 -22.22% BenchmarkSelectUncontended 228 189 -17.11% BenchmarkSelectContended 224 189 -15.62% BenchmarkSelectNonblock 93.1 91.1 -2.15% BenchmarkChanUncontended 54.5 52.8 -3.12% BenchmarkChanContended 54.7 52.8 -3.47% BenchmarkChanSync 131 123 -6.11% BenchmarkChanProdCons0 133 125 -6.02% BenchmarkChanProdCons10 79.1 76.4 -3.41% BenchmarkChanProdCons100 58.4 58.8 +0.68% BenchmarkChanProdConsWork0 589 478 -18.85% BenchmarkChanProdConsWork10 530 425 -19.81% BenchmarkChanProdConsWork100 510 406 -20.39% BenchmarkChanCreation 147 146 -0.68% BenchmarkChanSem 53.2 51.9 -2.44% BenchmarkCallClosure 2.23 3.44 +54.26% BenchmarkCallClosure1 3.11 3.72 +19.61% BenchmarkCallClosure2 33.6 23.9 -28.87% BenchmarkCallClosure3 34.6 25.8 -25.43% BenchmarkCallClosure4 35.9 26.5 -26.18% BenchmarkComplex128DivNormal 17.3 17.6 +1.73% BenchmarkComplex128DivNisNaN 13.1 13.4 +2.29% BenchmarkComplex128DivDisNaN 12.5 12.8 +2.40% BenchmarkComplex128DivNisInf 9.48 9.76 +2.95% BenchmarkComplex128DivDisInf 9.75 9.49 -2.67% BenchmarkConvT2ESmall 8.92 9.47 +6.17% BenchmarkConvT2EUintptr 0.56 0.56 +0.00% BenchmarkConvT2ELarge 44.6 51.7 +15.92% BenchmarkConvT2ISmall 10.3 10.6 +2.91% BenchmarkConvT2IUintptr 0.98 0.98 +0.00% BenchmarkConvT2ILarge 46.8 53.8 +14.96% BenchmarkConvI2E 3.90 3.90 +0.00% BenchmarkConvI2I 14.5 15.1 +4.14% BenchmarkAssertE2T 10.3 10.6 +2.91% BenchmarkAssertE2TLarge 11.1 11.7 +5.41% BenchmarkAssertE2I 15.6 15.9 +1.92% BenchmarkAssertI2T 10.3 11.1 +7.77% BenchmarkAssertI2I 15.6 15.9 +1.92% BenchmarkAssertI2E 3.90 4.18 +7.18% BenchmarkAssertE2E 0.56 0.70 +25.00% BenchmarkMalloc8 31.5 21.9 -30.48% BenchmarkMalloc16 36.2 33.3 -8.01% BenchmarkMallocTypeInfo8 47.5 45.6 -4.00% BenchmarkMallocTypeInfo16 51.1 49.6 -2.94% BenchmarkHashStringSpeed 23.4 22.9 -2.14% BenchmarkHashInt32Speed 14.4 14.7 +2.08% BenchmarkHashInt64Speed 14.5 15.0 +3.45% BenchmarkHashStringArraySpeed 73.3 62.3 -15.01% BenchmarkMegMap 20.3 21.2 +4.43% BenchmarkMegOneMap 12.8 13.4 +4.69% BenchmarkMegEqMap 60138 61645 +2.51% BenchmarkMegEmptyMap 3.35 3.71 +10.75% BenchmarkSmallStrMap 19.2 19.8 +3.12% BenchmarkMapStringKeysEight_16 22.9 20.9 -8.73% BenchmarkMapStringKeysEight_32 19.5 19.8 +1.54% BenchmarkMapStringKeysEight_64 19.5 19.8 +1.54% BenchmarkMapStringKeysEight_1M 19.5 19.8 +1.54% BenchmarkIntMap 17.3 19.8 +14.45% BenchmarkRepeatedLookupStrMapKey32 34.5 35.8 +3.77% BenchmarkRepeatedLookupStrMapKey1M 292271 292336 +0.02% BenchmarkNewEmptyMap 107 113 +5.61% BenchmarkMemmove32 4.74 4.74 +0.00% BenchmarkMemmove4K 94.9 96.6 +1.79% BenchmarkMemmove64K 2305 2334 +1.26% BenchmarkMemmove4M 384353 398570 +3.70% BenchmarkMemmove64M 14539833 14359420 -1.24% BenchmarkFinalizer 140 1101 +686.43% BenchmarkFinalizerRun 550 1721 +212.91% BenchmarkStackGrowth 520 421 -19.04% BenchmarkStackGrowthDeep 72650 57003 -21.54% BenchmarkCreateGoroutines 107 80.5 -24.77% BenchmarkCreateGoroutinesParallel 107 80.8 -24.49% BenchmarkMatmult 7.02 5.12 -27.07% BenchmarkIfaceCmp100 194 104 -46.39% BenchmarkIfaceCmpNil100 147 147 +0.00% BenchmarkDefer 71.0 43.9 -38.17% BenchmarkDefer10 63.4 39.8 -37.22% BenchmarkDeferMany 95.6 1928 +1916.74% BenchmarkCompareStringEqual 8.36 6.69 -19.98% BenchmarkCompareStringIdentical 3.90 3.34 -14.36% BenchmarkCompareStringSameLength 7.53 5.57 -26.03% BenchmarkCompareStringDifferentLength 1.67 0.84 -49.70% BenchmarkCompareStringBigUnaligned 62710 62551 -0.25% BenchmarkCompareStringBig 60338 61690 +2.24% benchmark old MB/s new MB/s speedup BenchmarkMemmove32 6752.83 6746.83 1.00x BenchmarkMemmove4K 43174.80 42409.11 0.98x BenchmarkMemmove64K 28422.35 28074.73 0.99x BenchmarkMemmove4M 10912.61 10523.37 0.96x BenchmarkMemmove64M 4615.52 4673.51 1.01x BenchmarkCompareStringBigUnaligned 16721.08 16763.66 1.00x BenchmarkCompareStringBig 17378.34 16997.66 0.98x
# http
benchmark old ns/op new ns/op delta BenchmarkHeaderWriteSubset 856 796 -7.01% BenchmarkReadRequestChrome 4952 4626 -6.58% BenchmarkReadRequestCurl 2724 2704 -0.73% BenchmarkReadRequestApachebench 2755 2683 -2.61% BenchmarkReadRequestSiege 3557 3455 -2.87% BenchmarkReadRequestWrk 1975 2042 +3.39% BenchmarkClientServer 45364 45086 -0.61% BenchmarkClientServerParallel4 40594 40459 -0.33% BenchmarkClientServerParallel64 38802 37238 -4.03% BenchmarkServer 112993 109860 -2.77% BenchmarkServerFakeConnNoKeepAlive 9968 9586 -3.83% BenchmarkServerFakeConnWithKeepAlive 8078 7392 -8.49% BenchmarkServerFakeConnWithKeepAliveLite 5058 5178 +2.37% BenchmarkServerHandlerTypeLen 6668 6471 -2.95% BenchmarkServerHandlerNoLen 6098 5858 -3.94% BenchmarkServerHandlerNoType 6400 6312 -1.38% BenchmarkServerHandlerNoHeader 4699 4643 -1.19% benchmark old MB/s new MB/s speedup BenchmarkReadRequestChrome 123.38 132.06 1.07x BenchmarkReadRequestCurl 28.63 28.84 1.01x BenchmarkReadRequestApachebench 29.76 30.56 1.03x BenchmarkReadRequestSiege 42.45 43.70 1.03x BenchmarkReadRequestWrk 20.25 19.58 0.97x
# floats
benchmark old ns/op new ns/op delta BenchmarkMinSmall 11.4 11.6 +1.75% BenchmarkMinMed 606 618 +1.98% BenchmarkMinLarge 56508 59211 +4.78% BenchmarkMinHuge 7129637 7118827 -0.15% BenchmarkAddTwoSmall 19.7 19.5 -1.02% BenchmarkAddFourSmall 42.6 38.5 -9.62% BenchmarkAddTwoMed 858 855 -0.35% BenchmarkAddFourMed 2558 2544 -0.55% BenchmarkAddTwoLarge 85419 87294 +2.20% BenchmarkAddFourLarge 256032 261904 +2.29% BenchmarkAddTwoHuge 22318732 22296116 -0.10% BenchmarkAddFourHuge 68351963 68398657 +0.07% BenchmarkLogSumExpSmall 222 223 +0.45% BenchmarkLogSumExpMed 16617 16940 +1.94% BenchmarkLogSumExpLarge 1660844 1684650 +1.43% BenchmarkLogSumExpHuge 167184482 169930103 +1.64% BenchmarkDotSmall 15.2 12.1 -20.39% BenchmarkDotMed 854 845 -1.05% BenchmarkDotLarge 83652 83666 +0.02% BenchmarkDotHuge 14198837 14076741 -0.86%
# cipher
benchmark old ns/op new ns/op delta BenchmarkAESCFBEncrypt 6283 3366 -46.43% BenchmarkAESCFBDecrypt 6225 3560 -42.81% BenchmarkAESOFB 4915 2346 -52.27% BenchmarkAESCTR 5303 2101 -60.38% BenchmarkAESCBCEncrypt 4967 2723 -45.18% BenchmarkAESCBCDecrypt 6934 2618 -62.24% benchmark old MB/s new MB/s speedup BenchmarkAESCFBEncrypt 162.82 303.85 1.87x BenchmarkAESCFBDecrypt 164.31 287.33 1.75x BenchmarkAESOFB 208.10 436.06 2.10x BenchmarkAESCTR 192.87 486.76 2.52x BenchmarkAESCBCEncrypt 206.12 376.01 1.82x BenchmarkAESCBCDecrypt 147.68 391.11 2.65x
# megajson
benchmark old ns/op new ns/op delta BenchmarkCodeEncoder 11781406 11780666 -0.01% BenchmarkCodeDecoder 46571748 46638330 +0.14% benchmark old MB/s new MB/s speedup BenchmarkCodeEncoder 164.71 164.72 1.00x BenchmarkCodeDecoder 41.67 41.61 1.00x
# snappy
Makefile:64: recipe for target 'snappy' failed
retry~
# go1
benchmark old ns/op new ns/op delta BenchmarkBinaryTree17 3654353852 3434368270 -6.02% BenchmarkFannkuch11 2854598755 2552370388 -10.59% BenchmarkFmtFprintfEmpty 82.4 67.2 -18.45% BenchmarkFmtFprintfString 199 210 +5.53% BenchmarkFmtFprintfInt 170 157 -7.65% BenchmarkFmtFprintfIntInt 272 251 -7.72% BenchmarkFmtFprintfPrefixedInt 247 235 -4.86% BenchmarkFmtFprintfFloat 358 362 +1.12% BenchmarkFmtManyArgs 1004 1078 +7.37% BenchmarkGobDecode 7546739 7677827 +1.74% BenchmarkGobEncode 4231271 4878852 +15.30% BenchmarkGzip 374066721 372888806 -0.31% BenchmarkGunzip 92557469 93076166 +0.56% BenchmarkHTTPClientServer 45742 45069 -1.47% BenchmarkJSONEncode 19902803 19574255 -1.65% BenchmarkJSONDecode 77741697 72790242 -6.37% BenchmarkMandelbrot200 4011793 4016369 +0.11% BenchmarkGoParse 4269777 4062284 -4.86% BenchmarkRegexpMatchEasy0_32 111 115 +3.60% BenchmarkRegexpMatchEasy0_1K 299 297 -0.67% BenchmarkRegexpMatchEasy1_32 92.9 97.2 +4.63% BenchmarkRegexpMatchEasy1_1K 786 766 -2.54% BenchmarkRegexpMatchMedium_32 169 177 +4.73% BenchmarkRegexpMatchMedium_1K 58737 64574 +9.94% BenchmarkRegexpMatchHard_32 2845 2923 +2.74% BenchmarkRegexpMatchHard_1K 92750 96424 +3.96% BenchmarkRevcomp 641986169 598134442 -6.83% BenchmarkTemplate 93200532 96877619 +3.95% BenchmarkTimeParse 388 400 +3.09% BenchmarkTimeFormat 346 343 -0.87% benchmark old MB/s new MB/s speedup BenchmarkGobDecode 101.70 99.97 0.98x BenchmarkGobEncode 181.40 157.32 0.87x BenchmarkGzip 51.88 52.04 1.00x BenchmarkGunzip 209.65 208.48 0.99x BenchmarkJSONEncode 97.50 99.13 1.02x BenchmarkJSONDecode 24.96 26.66 1.07x BenchmarkGoParse 13.57 14.26 1.05x BenchmarkRegexpMatchEasy0_32 287.60 276.88 0.96x BenchmarkRegexpMatchEasy0_1K 3414.12 3439.59 1.01x BenchmarkRegexpMatchEasy1_32 344.32 329.32 0.96x BenchmarkRegexpMatchEasy1_1K 1302.57 1336.36 1.03x BenchmarkRegexpMatchMedium_32 5.89 5.65 0.96x BenchmarkRegexpMatchMedium_1K 17.43 15.86 0.91x BenchmarkRegexpMatchHard_32 11.24 10.94 0.97x BenchmarkRegexpMatchHard_1K 11.04 10.62 0.96x BenchmarkRevcomp 395.91 424.93 1.07x BenchmarkTemplate 20.82 20.03 0.96x
# runtime
benchmark old ns/op new ns/op delta BenchmarkAppend 87.2 41.8 -52.06% BenchmarkAppend1Byte 115 102 -11.30% BenchmarkAppend4Bytes 107 98.7 -7.76% BenchmarkAppend8Bytes 105 105 +0.00% BenchmarkAppend16Bytes 109 99.9 -8.35% BenchmarkAppend32Bytes 110 110 +0.00% BenchmarkAppendSpecialCase 31.2 24.6 -21.15% BenchmarkSelectUncontended 228 188 -17.54% BenchmarkSelectContended 224 191 -14.73% BenchmarkSelectNonblock 93.4 91.2 -2.36% BenchmarkChanUncontended 54.6 52.8 -3.30% BenchmarkChanContended 54.9 52.7 -4.01% BenchmarkChanSync 131 124 -5.34% BenchmarkChanProdCons0 133 126 -5.26% BenchmarkChanProdCons10 78.4 76.9 -1.91% BenchmarkChanProdCons100 58.3 59.0 +1.20% BenchmarkChanProdConsWork0 589 480 -18.51% BenchmarkChanProdConsWork10 531 427 -19.59% BenchmarkChanProdConsWork100 511 407 -20.35% BenchmarkChanCreation 148 145 -2.03% BenchmarkChanSem 53.3 51.9 -2.63% BenchmarkCallClosure 2.23 3.44 +54.26% BenchmarkCallClosure1 3.12 3.73 +19.55% BenchmarkCallClosure2 33.6 24.0 -28.57% BenchmarkCallClosure3 34.1 26.5 -22.29% BenchmarkCallClosure4 36.0 25.7 -28.61% BenchmarkComplex128DivNormal 17.3 17.6 +1.73% BenchmarkComplex128DivNisNaN 13.1 13.4 +2.29% BenchmarkComplex128DivDisNaN 12.5 12.8 +2.40% BenchmarkComplex128DivNisInf 9.48 9.78 +3.16% BenchmarkComplex128DivDisInf 9.78 9.49 -2.97% BenchmarkConvT2ESmall 8.92 9.50 +6.50% BenchmarkConvT2EUintptr 0.56 0.56 +0.00% BenchmarkConvT2ELarge 44.7 51.5 +15.21% BenchmarkConvT2ISmall 10.3 10.6 +2.91% BenchmarkConvT2IUintptr 0.98 0.98 +0.00% BenchmarkConvT2ILarge 47.0 53.8 +14.47% BenchmarkConvI2E 3.90 3.90 +0.00% BenchmarkConvI2I 14.5 14.8 +2.07% BenchmarkAssertE2T 10.3 10.6 +2.91% BenchmarkAssertE2TLarge 11.2 11.8 +5.36% BenchmarkAssertE2I 15.7 15.9 +1.27% BenchmarkAssertI2T 10.3 11.1 +7.77% BenchmarkAssertI2I 15.7 15.9 +1.27% BenchmarkAssertI2E 3.90 4.18 +7.18% BenchmarkAssertE2E 0.56 0.70 +25.00% BenchmarkMalloc8 31.8 22.0 -30.82% BenchmarkMalloc16 35.8 33.1 -7.54% BenchmarkMallocTypeInfo8 47.4 45.5 -4.01% BenchmarkMallocTypeInfo16 51.0 49.7 -2.55% BenchmarkHashStringSpeed 22.8 23.0 +0.88% BenchmarkHashInt32Speed 14.4 14.6 +1.39% BenchmarkHashInt64Speed 14.9 14.6 -2.01% BenchmarkHashStringArraySpeed 73.5 65.2 -11.29% BenchmarkMegMap 20.3 21.2 +4.43% BenchmarkMegOneMap 12.9 13.8 +6.98% BenchmarkMegEqMap 60513 60180 -0.55% BenchmarkMegEmptyMap 3.36 3.72 +10.71% BenchmarkSmallStrMap 19.2 19.8 +3.12% BenchmarkMapStringKeysEight_16 22.9 20.9 -8.73% BenchmarkMapStringKeysEight_32 19.5 19.8 +1.54% BenchmarkMapStringKeysEight_64 19.5 19.8 +1.54% BenchmarkMapStringKeysEight_1M 19.6 19.8 +1.02% BenchmarkIntMap 17.3 19.8 +14.45% BenchmarkRepeatedLookupStrMapKey32 34.8 35.8 +2.87% BenchmarkRepeatedLookupStrMapKey1M 292872 292774 -0.03% BenchmarkNewEmptyMap 108 114 +5.56% BenchmarkMemmove32 4.75 4.75 +0.00% BenchmarkMemmove4K 94.0 96.6 +2.77% BenchmarkMemmove64K 2292 2326 +1.48% BenchmarkMemmove4M 364318 382791 +5.07% BenchmarkMemmove64M 14604954 14430825 -1.19% BenchmarkFinalizer 140 1107 +690.71% BenchmarkFinalizerRun 547 1810 +230.90% BenchmarkStackGrowth 520 421 -19.04% BenchmarkStackGrowthDeep 72767 57273 -21.29% BenchmarkCreateGoroutines 108 80.9 -25.09% BenchmarkCreateGoroutinesParallel 107 81.3 -24.02% BenchmarkMatmult 7.06 5.08 -28.05% BenchmarkIfaceCmp100 194 104 -46.39% BenchmarkIfaceCmpNil100 147 147 +0.00% BenchmarkDefer 71.3 45.3 -36.47% BenchmarkDefer10 63.4 38.5 -39.27% BenchmarkDeferMany 96.1 1952 +1931.22% BenchmarkCompareStringEqual 8.36 6.70 -19.86% BenchmarkCompareStringIdentical 3.91 3.34 -14.58% BenchmarkCompareStringSameLength 7.53 5.58 -25.90% BenchmarkCompareStringDifferentLength 1.67 0.84 -49.70% BenchmarkCompareStringBigUnaligned 62086 62540 +0.73% BenchmarkCompareStringBig 60163 60314 +0.25% benchmark old MB/s new MB/s speedup BenchmarkMemmove32 6734.08 6740.08 1.00x BenchmarkMemmove4K 43570.28 42403.47 0.97x BenchmarkMemmove64K 28585.59 28168.56 0.99x BenchmarkMemmove4M 11512.74 10957.14 0.95x BenchmarkMemmove64M 4594.94 4650.38 1.01x BenchmarkCompareStringBigUnaligned 16889.04 16766.54 0.99x BenchmarkCompareStringBig 17428.81 17385.17 1.00x
# http
benchmark old ns/op new ns/op delta BenchmarkHeaderWriteSubset 860 814 -5.35% BenchmarkReadRequestChrome 5013 4657 -7.10% BenchmarkReadRequestCurl 2760 2674 -3.12% BenchmarkReadRequestApachebench 2745 2696 -1.79% BenchmarkReadRequestSiege 3549 3386 -4.59% BenchmarkReadRequestWrk 1976 2028 +2.63% BenchmarkClientServer 45085 46721 +3.63% BenchmarkClientServerParallel4 40607 39882 -1.79% BenchmarkClientServerParallel64 37787 37199 -1.56% BenchmarkServer 106776 108775 +1.87% BenchmarkServerFakeConnNoKeepAlive 9923 9572 -3.54% BenchmarkServerFakeConnWithKeepAlive 7972 7485 -6.11% BenchmarkServerFakeConnWithKeepAliveLite 5033 5082 +0.97% BenchmarkServerHandlerTypeLen 6538 6476 -0.95% BenchmarkServerHandlerNoLen 5976 5859 -1.96% BenchmarkServerHandlerNoType 6202 6282 +1.29% BenchmarkServerHandlerNoHeader 4584 4656 +1.57% benchmark old MB/s new MB/s speedup BenchmarkReadRequestChrome 121.87 131.18 1.08x BenchmarkReadRequestCurl 28.25 29.17 1.03x BenchmarkReadRequestApachebench 29.87 30.41 1.02x BenchmarkReadRequestSiege 42.54 44.59 1.05x BenchmarkReadRequestWrk 20.24 19.72 0.97x
# floats
benchmark old ns/op new ns/op delta BenchmarkMinSmall 11.4 11.5 +0.88% BenchmarkMinMed 605 619 +2.31% BenchmarkMinLarge 56596 59358 +4.88% BenchmarkMinHuge 7141490 7148974 +0.10% BenchmarkAddTwoSmall 19.8 19.5 -1.52% BenchmarkAddFourSmall 43.0 38.5 -10.47% BenchmarkAddTwoMed 860 855 -0.58% BenchmarkAddFourMed 2565 2543 -0.86% BenchmarkAddTwoLarge 85567 87913 +2.74% BenchmarkAddFourLarge 256388 263466 +2.76% BenchmarkAddTwoHuge 22670204 22297992 -1.64% BenchmarkAddFourHuge 69202089 68393846 -1.17% BenchmarkLogSumExpSmall 223 223 +0.00% BenchmarkLogSumExpMed 16614 16953 +2.04% BenchmarkLogSumExpLarge 1659305 1690761 +1.90% BenchmarkLogSumExpHuge 167223818 169963080 +1.64% BenchmarkDotSmall 15.1 12.3 -18.54% BenchmarkDotMed 856 848 -0.93% BenchmarkDotLarge 83808 83722 -0.10% BenchmarkDotHuge 14141122 14071509 -0.49%
# cipher
benchmark old ns/op new ns/op delta BenchmarkAESCFBEncrypt 6259 3366 -46.22% BenchmarkAESCFBDecrypt 6221 3570 -42.61% BenchmarkAESOFB 5632 2351 -58.26% BenchmarkAESCTR 5304 2100 -60.41% BenchmarkAESCBCEncrypt 4979 2728 -45.21% BenchmarkAESCBCDecrypt 6933 2617 -62.25% benchmark old MB/s new MB/s speedup BenchmarkAESCFBEncrypt 163.42 303.90 1.86x BenchmarkAESCFBDecrypt 164.43 286.52 1.74x BenchmarkAESOFB 181.63 435.00 2.39x BenchmarkAESCTR 192.84 486.98 2.53x BenchmarkAESCBCEncrypt 205.64 375.33 1.83x BenchmarkAESCBCDecrypt 147.70 391.16 2.65x
# megajson
benchmark old ns/op new ns/op delta BenchmarkCodeEncoder 11849738 11814373 -0.30% BenchmarkCodeDecoder 46539678 46528214 -0.02% benchmark old MB/s new MB/s speedup BenchmarkCodeEncoder 163.76 164.25 1.00x BenchmarkCodeDecoder 41.70 41.71 1.00x
# snappy
Makefile:64: recipe for target 'snappy' failed
2014-06-13
Web Framework for Go
Let's try to use some server side web framework, I found two that support hot-compile/reload, that is Revel and Beego. Revel does not include any ORM by default, but it has example that uses GORP. Beego have its built-in ORM, even although I think I will like GORM better since it's similar to Ruby's DataMapper. There are no example that show combination of Beego+GORM or Revel+GORM. One more difference I found between Beego and Revel, Beego always immediately recompile when any file changed, Revel doesn't, Revel wait until there are request before recompiling, I guess on this part, Rever more likely to use fewer resource. Revel take about 15 seconds to recompile in my AMD C-60 netbook processor, Beego take about 12 seconds. Both framework uses Go's template engine (which I don't like >w<). For development, Revel gives better flow just edit and refresh the site, even when there's an error, the error shows up on the browser, not on the console. Beego shows the error on the console (just like Sinatra), not on the browser. Some other web framework I found is Martini, this one looks like just a plain NodeJS. This one doesn't support hot-compile/reload, but you could use gin or fresh (just like rerun on Ruby, or supervisor/nodemon for NodeJS) as stated on it's documentation.
I guess I will try to use Revel+GORM, wish me luck~
I guess I will try to use Revel+GORM, wish me luck~
2014-06-08
IDEs for Go
As programmer, we need good IDE (or just editor if you have good memory of the APIs), well.. In C/C++ we have QtCreator and Visual Studio, in Object-Pascal we Have Embarcadero Delphi, in Javascript we have Brackets.io or Webstorm, in Ruby we have RubyMine, in PHP we have PHPStorm, in Java-based languages (Scala, Clojure, Groovy) we have Eclipse, Netbeans and IntelliJ IDEA. What's for Golang?
First of all don't forget to set GOROOT (/usr/lib/go on ArchLinux) and GOPATH.
1. Vim + Vim-Go
Actually I've used vim for so long to edit a single source file, but not for IDE with many files, I've tried nedtree and many vim plugins but nothing capture my heart, except for the color scheme. Anyway you need Pathogen to install it easily, also YCM and the autocomplete works well (autocomplete: Ctrl+X + Ctrl+O). Sometimes when exiting vim it shows some error.
2. Goclipse
Just install eclipse pacman -S eclipse, add http://releases.goclipse.googlecode.com/git/ to the update site and install Goclipse. Set all the Go path configuration on the Preferences, kill gocode and start manually if necessary.
The autocomplete works fine. But the eclipse color configuration is quite annoying for dark theme desktop.
3. GolangIDE
Seems good, latest version was LiteIDE X26, cross-platform, available on ArchLinux via pacman -S liteide
set the correct GOROOT on your /usr/share/liteide/liteenv/linux64.env file (for 64-bit), and the autocomplete works fine!
4. IntelliJ IDEA CE + Golang Plugin
Just install IntelliJ IDEA Community Edition pacman -S intellij-idea-community-edition, go to plugins, browse, install Golang.
The autocomplete doesn't work well at all, it only shows sout, souf, soutm, soutp.
EDIT: it works by modifying the Exec= line of the .desktop file into: sh -c "/usr/bin/idea.sh" %f
Which one better?
I guess, for now I'll go with GolangIDE and Vim :3
First of all don't forget to set GOROOT (/usr/lib/go on ArchLinux) and GOPATH.
1. Vim + Vim-Go
Actually I've used vim for so long to edit a single source file, but not for IDE with many files, I've tried nedtree and many vim plugins but nothing capture my heart, except for the color scheme. Anyway you need Pathogen to install it easily, also YCM and the autocomplete works well (autocomplete: Ctrl+X + Ctrl+O). Sometimes when exiting vim it shows some error.
2. Goclipse
Just install eclipse pacman -S eclipse, add http://releases.goclipse.googlecode.com/git/ to the update site and install Goclipse. Set all the Go path configuration on the Preferences, kill gocode and start manually if necessary.
The autocomplete works fine. But the eclipse color configuration is quite annoying for dark theme desktop.
Seems good, latest version was LiteIDE X26, cross-platform, available on ArchLinux via pacman -S liteide
set the correct GOROOT on your /usr/share/liteide/liteenv/linux64.env file (for 64-bit), and the autocomplete works fine!
4. IntelliJ IDEA CE + Golang Plugin
Just install IntelliJ IDEA Community Edition pacman -S intellij-idea-community-edition, go to plugins, browse, install Golang.
The autocomplete doesn't work well at all, it only shows sout, souf, soutm, soutp.
EDIT: it works by modifying the Exec= line of the .desktop file into: sh -c "/usr/bin/idea.sh" %f
Which one better?
I guess, for now I'll go with GolangIDE and Vim :3
2014-06-03
Go's Scanln (GoLang)
So.. Today I tried to study about Go, programming language by Google, that i expect would be good replacement for C/C++/Java..
Instalation? easy~
sudo pacman -S go # ArchLinux
go version # go version go1.2.2 linux/amd64
running? easy~
go build try1.go && ./try1 # or
go run try1.go
input and output? easy~ ^^)b
package main
import (
"bufio"
"fmt"
"os"
)
func main(){
var i int
var f float64
var s string
r := bufio.NewReader(os.Stdin)
_, err := fmt.Scan(&i,&f,&s)
if err == nil {
fmt.Println("read int, float and string:",i,f,s)
} else {
fmt.Println("Error:",err)
}
s, err = r.ReadString('\n')
if err == nil {
fmt.Println("read line:",s)
} else {
fmt.Println("Error:",err)
}
}
Just some tricy part, I expect that fmt.Scanln would behave like C++'s getline(cin,str) or Java's Scanner scan.nextLine(), but it doesn't.. oh well..
Subscribe to:
Posts
(
Atom
)