Search This Blog

Tuesday, December 3, 2013

Arquillian WebSite Ruby HAML use textile filter plugin ERROR

I forked the source code for website from arquillian - code.
It uses several technologies under the hood - starting from Ruby, Bootstrap-sass, HAML and end awestruct.

HAML can interpret textile fragments. Recently, however, the textile and maruku plugin filters have been moved to another gem - haml-contrib.

After installing ruby 1.9.3 and haml with haml-contrib I received the following error when interpreting *.haml files with the ":textile" fragment:

> haml test.html.haml
Haml error on line 261: To use the "textile" filter, please install the haml-contrib gem.
Use --trace for backtrace.

I tested the application on Ubuntu 12.10. The only way I got it to work is when I compiled yaml, ruby and rubygems from source. The following tutorial from CentOS should be of help:

#preparing packages
$ sudo yum groupinstall 'Development Tools'
$ sudo yum install -y httpd-devel openssl-devel zlib-devel gcc gcc-c++ curl-devel expat-devel gettext-devel patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel make bzip2 zlib1g mysql-server
#compaling libyaml
$ wget
$ tar xzvf yaml-0.1.4.tar.gz
$ cd yaml-0.1.4
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
#compiling ruby 1.9.3
$ wget
$ tar xvzf ruby-1.9.3-p194.tar.gz
$ cd ruby-1.9.3-p194
$ ./configure
$ make
$ sudo make install
$ wget
$ tar xvzf rubygems-1.8.24.tgz
$ cd rubygems-1.8.24
$ sudo /usr/local/bin/ruby setup.rb

sudo gem install bundler

Go to your arquillian directory and:
sudo bundle install

Simulate INTERMEC EA15 barcode scanner via UDP packages

The EA15 intermec barcode scanner sends barcodes as UDP packages. To simulate its behaviour without actually owning the device you can send appropriate packages to the device.

PORT: 4080
barcode prefix: 0000

So to send barcode: 5900116011295
You actully need to send: 00005900116011295
which in HEX is: 30 30 30 30 35 39 30 30 31 31 36 30 31 31 32 39 35

On Windows there is Packet Sender.

On Linux you can easily send udp packages from terminal to simulate barcode scanning:

sudo sendip -p ipv4 -is -p udp -us 5070 -ud 4080 -d "0x3030303035393030313136303131323935" -v

where 30 30 30 30 35 39 30 30 31 31 36 30 31 31 32 39 35
is the HEX: 00005900116011295
-is  output IP address
-us  output port number
-v destination ip address
-ud destination port address

to send a simple string do:
sudo sendip -p ipv4 -is -p udp -us 5070 -ud 4080 -d "Hello this is a string" -v

The same result can be achieved with the socat command on linux:

echo "00005900116011295" | socat - udp-datagram:

The scanner looks like this:

Friday, November 15, 2013

Android/IntelliJ - ADB display only debugging lines from logcat that DO NOT contain a phrase

Does not contain regexp


In the Android tab, go to: "Logcat" and create a new filter.
enter the above string in the
"by Log Message (regex):"

Android Java - Convert day year month hour minute second to miliseconds since epoch / convert to java.util.Date

public Date getDate()
    final Calendar cal = Calendar.getInstance();
    cal.set(2013, 12 - 1, 7, 17, 33, 01);
    long secondsSinceEpoch = cal.getTimeInMillis();
    Date date = new Date();
    return date;

Saturday, October 19, 2013

Ubuntu 12.04 - create a simple daemon (service) for your application

Creating a daemon in Linux is as simple as creating a BASH/SH script in /etc/init.d. BASH is NOT part of this short tutorial so I won't go into the details of the script itself.

To create a daemon create a script in /etc/init.d. To simplify the creation you can copy the skeleton script in /etc/init.d/skeleton. Your script need to handle the following daemon commands:

cp /etc/init.d/skeleton /etc/init.d/daemonName
sudo chmod 775 /etc/init.d/daemonName

To enable the daemon to start at boot:
update-rc.d daemonName defaults 97 03

To disable the daemon from starting at boot:

update-rc.d -f daemonName remove

Tuesday, October 15, 2013

Git - tips for console users

Get the tree-like view of commits in terminal

git log --graph --oneline --all

Get current branch name

git branch

Pull and rebase local changes

git pull --rebase

Revert all local changes in a GIT managed project

git reset --hard HEAD


git checkout .
git reset
git revert ...


git clean -df & git checkout -- .
(and press enter)

Check whether there are any uncommited branches

git log --branches --not --remotes

Extract three topmost commits from the current branch 

git format-patch -3

Check if there are any conflicts before applying the patch

git apply --check patch_name.patch

Apply a patch file to the local work-space

git apply patch_name.patch

Archlinux setting up VPN - couldn't open the /dev/ppp device: No such device or address

While configuring VPN on archlinux I followed the guide on:

archlinux couldn't open the /dev/ppp device: No such device or address

add a new file:

nano /etc/modprobe.d/modules.conf

with the line:
alias char-major-108 ppp_generic

Linux - simple rar archive operations - checksum and rar archive test

1. Check checksums of files listed in ’files.sfv’: 
cksfv -f files.sfv 

2. Create checksums for a bunch of files: 
cksfv *.rar > files.sfv

3. Test rar achive
unrar t archive_name.rar

Sunday, October 13, 2013

Spring REST - access HTTP header data on the server side

This is an example of a simple REST call on the server side;

The call looks like the following:

[GET] http://localhost:8080/rest/user/getUser/userNameABC
Accept: application/json
Authorization: 123456

@RequestMapping(value="/getUser/{login}", method = RequestMethod.GET, produces="application/json", headers="Accept=application/json")
public User getUser(
   @RequestHeader(value = "Authorization", required = true) String authorization,
   @PathVariable String login) {
     if (login.isEmpty())
        return null;


The @RequestHeader accesses for us data in the header. We can also get the Accept parameter by adding:

@RequestHeader(value = "Accept") String acceptString

Friday, October 11, 2013

Android - Find main activity name of the running application

Run as Android superuser:
adb shell dumpsys activity

This gives you the dump of all running activities. I wanted to find the activity name of the sftp server that was running in the background.

The line of interest was:

Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10104000 pkg=com.icecoldapps.httpsftpsserver cmp=com.icecoldapps.httpsftpsserver/.viewStart bnds=[145,610][345,787] }
      Hist #2: ActivityRecord{42d5cb18 com.icecoldapps.httpsftpsserver/.viewStart}
        Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10104000 pkg=com.icecoldapps.httpsftpsserver cmp=com.icecoldapps.httpsftpsserver/.viewStart bnds=[145,610][345,787] }
        ProcessRecord{42c29950 15592:com.icecoldapps.httpsftpsserver/u0a6} 

So the main activity name is:

I was able to remotely start the application by firing up the command:
adb shell su -c "am start -n "com.icecoldapps.httpsftpsserver/.viewStart""
( I needed superuser priviledges)

To start this Android application as a regular user enter:
adb shell am start -n "com.icecoldapps.httpsftpsserver/.viewStart"

To kill the application:
adb shell am force-stop com.icecoldapps.httpsftpsserver

To uninstall the application:
adb shell pm uninstall com.icecoldapps.httpsftpsserver

Thursday, October 10, 2013

IntelliJ Android application - Android SDK is not specified

Are you getting a compile error:
Android Source Generator: [] Android SDK is not specified

These screens show how to properly configure IntelliJ to compile an Android application.

Monday, October 7, 2013

Android adb pull from specific device; adb pull error: more than one device and emulator

When your computer is connected to multiple devices which communicate via IP based adb the command:

adb pull /mnt/local/your_app/config/config.xml

will no longer work giving an error:

error: more than one device and emulator

You need to specify which device you want to download from:

adb -s pull /mnt/local/your_app/config/config.xml


adb -s 0123456789ABCDEF pull /mnt/local/your_app/config/config.xml

Friday, October 4, 2013

Ubuntu install cyanogenmod on Galaxy S3 I9300 - running heimdall on Ubuntu 10.04

Tutorial on cyanogenmod wiki for flashing CWM on the Galaxy S3 is here.

This is the easy guide to flash Cyanogenmod 10.1.3 on I9300. The machine is Ubuntu 10.04 x64

Download the required file.
run the script before running heimdall!
Ubuntu 10.04 lacks lib!

$./heimdall flash --RECOVERY recovery-clockwork-touch- --no-reboot

Uploading RECOVERY
RECOVERY upload successful

Ending session...
Releasing device interface...
Re-attaching kernel driver...

The device will hang on completion! You need now to manually reboot the phone into ClockworkMod Recovery mode by holding Home & Volume Up & Power.

After that the i9300 will enter the new TOUCH ClockworkmodRecovery.

Do the following steps:
- wipe CACHE&User data
- install from external SD card

  • cyanogenmod 10.1
  • gapps

Solutions for the following problems:

1. Heimdall does NOT WORK ON UBUNTU!

Run the 32-bit of heimdall on Ubuntu 12.04 ! The 64-bit version currently does NOT work!
The 32-bit version needs lib. Download the required file.

2. Problem with detecting the device:

Detecting device...
ERROR: Failed to access device. libusb error: -3

sudo chmod -R 777 /dev/bus/usb/001

The problem with libusb1.0: => not found
- download the libraries from the package and copy them to:

Git clone - use different keys for different repositories / user another private key

To clone git repository with a different private key than your /home/user/.ssh/id_rsa

  1. Create a script called:
  2. Give the script executable permissions:

    chmod 777
  3. The contents of the script should look like the following:

    ssh -i /home/user/RSA_Keys/id_rsa $1 $2

  4. Export variable GIT_SSH:
    export GIT_SSH=~/
  5. Clone the repository as usual:

    git clone

Tuesday, October 1, 2013

Draw a dotted line with GIMP

To draw a dotted line with GIMP:
  • Select an area with the Rectangle Tool ('R' key), when necessary change the "Rounded corners" option to an appropriate radius (usually from 10px to 20px)
  • RMB (Right mouse button): Select -> "To Path"   to convert your selection to Path
  • In the layers window choose the "Paths tab" and set the newly created path to "visible"

  • Choose the Path tool ('B' key) and select the path that you created earlier
  • Click "Stroke Path" and choose appropriate line styles