Wednesday, December 2, 2015

Android Lollipop tips


This is a list of useful tips&tricks I learned by reading my new smartphone user manual (yes, someone still does such a thing). They are relevant for Android Lollipop (5.1) mobile operating system.

In no particular order:


  • If you tap and hold a notification, it will tell you which app produced it will allows you to tune that (or turn it off for that app).
  • Pressing the volume button, you can quickly silence the phone by tapping the icon left of the volume indicator bar.
  • If you want to hide sensitive or private notifications tap > Apps > Moto > Display and set which apps can show notifications and how much to display.
  • If an app locks up your phone as soon as you turn it on, restart in Safe Mode: turn off your phone, then turn it back on — when you see the “Motorola” logo during power-up, press and hold both volume buttons until you see the Home screen, with Safe Mode in the bottom left. Then, try removing the app.
  • To immediately silence the phone when it's ringing, press the volume button.
  • If a contact has more than one number, you can say which number to call. For example, "Call Joe Black Mobile" or "Call Suzi Smith Work".
  • If some websites are not allowing zooming of their pages, go to the accessibility settings in Chrome and use Force enable zoom to allow zooming on all webpages.
  • It is possible to do 3 way phone calls: during a call, you can start another call, switch between them or join them in a 3-way call. To answer a second call, tap the circled phone icon and drag it to the blue one. To ignore a second call, drag it to the red one. The first call goes on hold if you answer the second call. To switch between calls, tap the circle icon. To dial a second call, tap the phone+ icon  , enter a number, then tap phone to call it. The first call goes on hold when you tap the phone+ icon. To join the calls after the second call answers, tap the join icon.
  • Lock screen: if you forget your pattern, PIN or password, you can enter your Google account email and password to unlock the phone.
  • Screen pinning: tap Apps  > Settings > Security > Screen pinning. To pin a screen, open the app you want to pin, tap Overview (the square icon) and scroll up. Tap the pin icon. To unpin the screen, tap Back and Overview at the same time.

Friday, September 5, 2014

Non printable characters

Some tips to get rid of non printable characters  as often seen in text file created on Microsoft platforms.

 To see those characters you can use something like:

$ sed -n 'l' Genesis.txt 
[...]
6 \266 And God said, Let there be a firmament in the midst of the wat\
ers, and let it divide the waters from the waters.$
[...]

or using standard commands (depending on which one, the output may differ):

$ grep "Let the waters under "  Genesis.txt 
9 � And God said, Let the waters under the heaven be gathered together [...]
$ cat -v Genesis.txt   | grep "Let the waters"
9 M-6 And God said, Let the waters under the heaven be gathered together unto one place, and let the dry [land] appear: and it was so.^M

that \266 is the octal code for it. To list all special characters in the Latin-1 set see

$ man iso_8859-1

(Note that 'man ascii' will only display/list the original 7bit character set).

You can remove that using its octal code via sed (making a backup of the original file as well)

$ sed -i.bak 's/\o266//g' Genesis.txt

To remove the ^M there are other methods:

$ dos2unix Genesis.txt  Genesis_fixed.txt
$ strings Genesis.txt > Genesis_fixed.txt
$ tr -d $'\r'  <  Genesis.txt > Genesis_fixed.txt

or just use sed (note that you need to type Ctrl+V then Ctrl+M to get the right symbol)

$ sed -i.bak 's/\^M//g' Genesis.txt 

a more general approach found on the internet is to get rid of all but the ASCII octal values quoted in the command:

$ tr -cd '\11\12\15\40-\176' Genesis.txt > Genesis_fixed.txt

EOF




Thursday, December 12, 2013

Vim indentation tips


Some Vim indentation tips to collect here mainly as a reminder. Note that the amount of spaces used for indentation is mainly governed by the variable shiftwidth.


  • Moving around (aka, prelude to action): 
    • H to top of screen, L to bottom, M to middle. Then use nG to go to line n, G alone to bottom of file, gg to top of file.
    • Go visual pressing v then move around to selct text. Once happy, you can copy (yy) or delete (dd) the selected text. 
  • Indent text (visual mode):
    • in command mode, press v then move cursor around (text will be highlighted), then press > to indent the highlighted text.
  • Indent text (markers):
    • position yourself then place a marker with ma, then move down to your block end and type >'a (a can be replaced with another valid character)
  • Indent text (fixed):
    • to indent current line type >>
    • to de-indent current line type <<
    • to indent 10 lines from the current one use 10>>
    • ... you get the gist ...
    • to indent lines from 10 to 20 type :10,20>
Some variables you can add to your .vimrc:

set shiftwidth=5    #Indent by 5 spaces when using >>, <<, etc.
set softtabstop=5   #Indent by 5 spaces when pressing
set autoindent      "Keep indentation from previous line

All of this is tested/verified for vim, not sure about vi.



Wednesday, September 11, 2013

D-Bus library appears to be incorrectly set up

Recently I add to install firefox on top of a bare bones SL6 VM (e.g. installed with the minimal package set) and upon launching the browser I got this error:

$ firefox 
process 12606: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/var/lib/dbus/machine-id": No such file or directory
See the manual page for dbus-uuidgen to correct this issue.
  D-Bus not built with -rdynamic so unable to print a backtrace
Aborted

turns out that the culprit is dbus which needs the service messagebus running but it has not been started by default, so issuing this makes the error go away:

# /etc/init.d/messagebus start

now Firefox will start as expectd.

Wednesday, January 2, 2013

Mobile browser user agents

Had a quick go at seeing what user agent is reported from different mobile devices and browser combinations:

Android (Gingerbread) stock browser:


134.171.xxx.xxx - - [02/Jan/2013:17:22:53 +0100] "GET /wdb/html/status_btn.gif HTTP/1.1" 200 1588 "http://archive.eso.org/wdb/wdb/eso/fors2/form" "Mozilla/5.0 (Linux; U; Android 2.3.3; en-us; GT-I9100 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"

Android Opera Mobile:

134.171.xxx.xxx - - [02/Jan/2013:17:21:38 +0100] "GET /wdb/wdb/eso/fors2/form HTTP/1.1" 200 28130 "-" "Opera/9.80 (X11; Linux zbov) Presto/2.11.355 Version/12.10"

Android Firefox:

134.171.xxx.xxx - - [02/Jan/2013:17:22:17 +0100] "GET /wdb/wdb/eso/fors2/form HTTP/1.1" 200 28130 "http://archive.eso.org/cms/eso-data/instrument-specific-query-forms.html" "Mozilla/5.0 (Android; Mobile; rv:17.0) Gecko/17.0 Firefox/17.0"

and for comparison, this is the stock iPhone4 browser:

134.171.xxx.xxx - - [02/Jan/2013:17:25:15 +0100] "GET /wdb/wdb/eso/fors2/form HTTP/1.1" 200 28130 "http://archive.eso.org/cms/eso-data/instrument-specific-query-forms.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10A523"

Friday, December 14, 2012

Getting a shell on Galaxy SII

First enable the USB debugging in (under Gingerbread, ICS or later may differ)

> Settings > Application > Development >

Then create this if using OpenSuSE (not required for Ubuntu 12.04)


# cat /etc/udev/rules.d/53-android.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"

note the vendor id is the one from Samsung (see http://developer.android.com/tools/device.html#VendorIds).

Now under OpenSuSE 11.x restart udev


# /etc/init.d/boot.udev restart

then plug the usb cable in the phone and as regular user you should see the device now



~/android-sdk-linux/platform-tools> adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached 
304D19AFD0235C8E device

and start the sehll

~/android-sdk-linux/platform-tools> adb -d shell
$ pwd
/

Wednesday, April 11, 2012

Middle Road Lodge

Hello

today I am adding a new feature to this blog: bookings overview for rooms in the Middle Road Lodge! You can see it on the right pane of this blog.

If you read this you probably know what this is about, else you don't need to know :-)

So, for those who are in the know, I hope you find it useful to plan/request a suitable lodging. Red events indicate bookings for the double guestroom, orange for the single one. You can click on any booking to see further details (press the escape key to undo), and also check out on the top right arrow: there is a drop down menu from which you can select separate calendar/booking for the two different available rooms, e.g. double (red) and single (orange).

I will keep these calendars updated from now on.

The Lodge Keeper





Thursday, January 5, 2012

Setting up Android development environment

So here are my notes on the subject (using a Linux platfrom).

First install the JDK from Oracle (I had to remove previous rpm from SUN RIP to achieve this):

# rpm -e jdk-1.6.0_30-fcs.i586
# rpm -ivh jdk-6u30-linux-i586.rpm

and make it default system wide:


# update-alternatives --config java

There are 2 alternatives which provide `java'.

  Selection    Alternative
-----------------------------------------------
          1    /usr/lib/jvm/jre-1.6.0-sun/bin/java
*+        2    /usr/lib/jvm/jre-1.6.0-openjdk/bin/java

Press enter to keep the default[*], or type selection number: 1
Using '/usr/lib/jvm/jre-1.6.0-sun/bin/java' to provide 'java'.
$ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)

Then install the current Android SDK, so that it ends up in  ~/android-sdk-linux and launch it with

$ ./android-sdk-linux/tools/android

Then check on all boxes from the API 14 (ICS) bundle and Tools folder, it will download a bunch of stuff.

Then from the Tools -> Manage AVD menu create a virtual device.

Now we need the Eclipse IDE, I downloaded eclipse-java-indigo-SR1-linux-gtk.tar.gz, just extract it to suitable location and run

$ ./eclipse/eclipse

then install the Google ADT plugin as per official docs.



Tuesday, January 3, 2012

Adding Amazon wishlist

So I have found instructions on how to add a widget to this blog which displays my Amazon wish-list. The reference site to create the Javascript snippet is

https://widgets.amazon.de/Amazon-Wishlist-Widget/

once you have that, go to the blog layout and add a widget (type html/javascript) to the desired position. Enter the snippet in the browser pop-up window. Done.

Friday, May 7, 2010

digging hard links

A couple of tips about hardlinks: to find all hard links in a specific namespace use something like this:

$ find -type f -links +1

this because hard links have, by definition, more than one link pointing to them, as you can see with ls or stat on one of them.

Another useful tip: to know about any hard link which is related to a specified file use something like:
$ find /home -xdev -samefile foo
this will print out all files which are hardlinked to foo. Remember that hard links have the same inode number which can be seen with
$ ls -li foo

once you know the inode number, you can also search for hard links with something like

$ find /home -xdev -inum 7465209
Have fun!

Thursday, January 14, 2010

How to run ChromeOS under VMware

Starting from this announcement

http://www.unixmen.com/news-today/706-chromium-os-zero-released-

I wanted the try out ChromeOS but under VMware and have a look at it. The first thing is to convert the downloaded raw image to VMWare disk image format:

$ qemu-img convert -f raw ChromeOS-Zero.img -O vmdk ChromeOS-Zero.vmdk

Then start VMware player and create a new virtual machine, but select "Custom". At some point during the process, it will ask you to select a disk. Choose to use an existing virtual disk, and point the installer tothe file created above.

This is the only trick you need to complete the virtual machine creation. Now to see what is all this ChromeOS fuss about ...

Friday, August 14, 2009

Yum and RPM notes for multiarch machines

When installing something on a stock 64bit installation, yum will by default install both x86_64 and i386 (if available) packages. This default behavior is often appearing when installing libraries and can be changed
by adding the following to /etc/yum.conf

multilib_policy=best

(default to all). In this way only the matching arch package will be installed.

If you don't want to make this global change, you can issue the yum command as follows to have the same outcome but for one time only:

yum install libtool-ltdl.x86_64

i.e. append the arch to the package name to avoid i386 package to be pulled along.

Querying the rpm database on x86_64 machines often shows duplicate packages, but that's normal in light of the above. You can change the default query format on the fly, e.g

rpm --qf '%{NAME}.%{ARCH}\n' -q glibc

or you can make it global by adding this to /etc/rpm/macros
%_query_all_fmt         %%{name}-%%{version}-%%{release}.%%{arch}
In this way the arch will be shown alongside other query parameters.

Sunday, July 26, 2009

Accessing the guest OS from the host using VirtualBox

To be able to access the guest OS via ssh fro the host, type the following on the host

$ VBoxManage setextradata Centos\ 5.3\ x86\ bis "VBoxInternal/Devices/pcnet/0/LUN#0/Config/SSH/HostPort" 3333
 $ VBoxManage setextradata Centos\ 5.3\ x86\ bis "VBoxInternal/Devices/pcnet/0/LUN#0/Config/SSH/GuestPort" 22
$ VBoxManage setextradata Centos\ 5.3\ x86\ bis "VBoxInternal/Devices/pcnet/0/LUN#0/Config/SSH/Protocol" TCP

(SSH is just a string, you can type anything really). Then you can login to the guest OS by typing this on the host:

$ ssh -p 2222 -X root@localhost

note the same principle applies to other services, example for httpd:

$ VBoxManage setextradata GuestName "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/HostPort" 8888
$ VBoxManage setextradata GuestName "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/GuestPort" 80
$ VBoxManage setextradata GuestName "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/Protocol" TCP

then you can point the host browser to http://localhost:8888. Note that you can’t use a host port lower than 1024 without running VirtualBox with escalated privileges.

To see settings use:

$ VBoxManage getextradata guestname enumerate

To clear a setting (by giving it a clear value) use:

$ VBoxManage setextradata "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort"

Virtual lab with VirtualBox

To get two virtual guests to talk to each other while also being able to reach out to rpm repos etc. (i.e.  to inernet), one needs to define two interfaces on the VirtualBox guest OS settings:

  • first interface (will be eth0) should use default NAT setting. This will provide Internet access.
  • second interface (will be eth1) should use 'Internal Network'. This will provide in-between guests connectivity.

When booting the guest (Centos in my case), eth0 will come up via DHCP, then configure eth1 with a static non routable IP address. However when bringing it up, it will override DNS and default GW as set by eth0, therefore breaking internet access. The fastest path recover is to simply restart eth0 (ifdown eth0/ifup eth0) which gets again the correct settings from the dhcp server.

Tuesday, June 9, 2009

Using IPod Nano on EeeUbuntu

The Nano is formatted with hfsplus (used under MacOSX earlier) hence when plugged under Ubuntu Linux is mounted read-only. To have it mounted read-write you need to plug it on Mac and then issue this command

$ diskutil disableJournal /Volumes/Somebody’s\ iPod/

this will remove the journal from the HFS+ filesystem, and now Linux will mount it read-write. Then use whichever application to manage your songs.

Wednesday, April 22, 2009

Speeding up firefox 3

In the about:config enable the setting network.dns.disableIPv6 (double click will suffice).
Then install the Flashblock Firefox extension to load the Flash stuff only when you want.
Additionally try to use the fastest SDD drive for the FF cache, instructions below:

  • Open a new tab and type about:config into the address bar.
  • Right-click anywhere in the lower part of the screen and choose new->integer.
  • Name the new setting ‘toolkit.storage.synchronous’
  • In the second popup, set the value to 0 (zero). This tells the browser not to wait while writing files.
  • Create a new string called ‘browser.cache.disk.parent_directory’
  • Set its value to ‘/dev/shm/firefox-yourusername’. This tells the browser to use a RAM disk instead of the SSD.
The above procedure placaes the cache in the RAM, however this means it will be lost when shutting down the computer.

update Xandros to Firefox 3

Looking to upgrade to firefox 3 under the original Xandros distribution, after some trial and error I came to find that Asus has actually published updates for Firefox 3 and associated stuff like Flash Player. To do it add this entry to the apt source file

deb http://update.eeepc.asus.com/1.6/ common main

(comment out the original entry). Now the following command will upgrade to Firefox 3 and Flash Player 10 (only partial output shown):

# apt-get update
# apt-get install firefox-upgrade

Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
adobe-flash-player firefox firefox-extension-default firefox-locale-de gtk2-engines libc6 libcairo2 libdatrie0 libglib2.0-0 libgtk2.0-0 libgtk2.0-bin libgtk2.0-common
libpango1.0-0 libpango1.0-common librsvg2-2 librsvg2-common libthai-data libthai0 locales tzdata
Suggested packages:
glibc-doc libc6-i686 ttf-kochi-gothic ttf-kochi-mincho ttf-thryomanes ttf-baekmuk ttf-arphic-gbsn00lp ttf-arphic-bsmi00lp ttf-arphic-gkai00mp ttf-arphic-bkai00mp
librsvg2-bin
Recommended packages:
libglib2.0-data x-ttcidfont-conf
The following NEW packages will be installed:
firefox-upgrade libdatrie0 libthai-data libthai0
The following packages will be upgraded:
adobe-flash-player firefox firefox-extension-default firefox-locale-de gtk2-engines libc6 libcairo2 libglib2.0-0 libgtk2.0-0 libgtk2.0-bin libgtk2.0-common
libpango1.0-0 libpango1.0-common librsvg2-2 librsvg2-common locales tzdata
17 upgraded, 4 newly installed, 0 to remove and 62 not upgraded.
Need to get 32.9MB of archives.
After unpacking 10.8MB of additional disk space will be used.

Friday, April 17, 2009

David and Goliath

Today I decided to try to use my Samsung HDTV as external monitor for my EeePC. Plugged the VGA cable on both end and then needed to start the Gnome Display setting GUI to trigger the detection of an external monitor. Once found it presented me a list of resolutions and I chose the highest one (1024 x 768, 4:3 format) available. Restarted X and done.

Interestingly, when replugged the HDTV a second time, I was offered yet a higher resolution for it, 1360 x 768, 16:9 format. Much better for movies, so I set this one instead and below are the two displays for comparison. Nice.

Friday, April 10, 2009

tuning the EeePC 901

installed eee-control on the EeePC 901 (eeebuntu 2) and all hardware is really nicely integrated now. Also installed cheese and webcam tested ok. So far I am impressed.

removing Mono from EeeUbuntu

I removed the Mono stuff from my eeeubuntu (because I can and I want to) with

# sudo apt-get remove --purge mono-common libmono0


this removes Banshee and F-Spot which I then replaced by other applications with

# sudo apt-get rhythmbox gthumb