Friday, May 10, 2013

macosx & readable web pages in armenian

hi folks. everybody who has macosx installed on his/her 's apple boards faces the problem of font design of web pages in armenian. in my humble opinion the design is awful for reading and understanding the text. with this post you will be able to change it system wise.

system font for armenian language by default in macosx operating system is rendered using "Mshtakan" font. i think the default font isn't well designed in terms of readability than the font called "Arian AMU". here is the link were you can download the font pack. extract the downloaded zip file and install the fonts. after installation you will be able to see armenian pages which  include "Arian AMU" font in their css style. but i can tell you that these kind of web pages are few. for example google search does not include "Arian AMU" font and you will again see the armenian text rendered using "Mshtakan" font. so the solution is to change it permanently for the whole system. below you can find  the way to change it.

before doing instruction steps be sure that  font "Arian AMU" is installed !

Updated for OSX El Capitan

First you need to disable SIP (system integrity protection) for your system in order to be able to allow making changes in system files

How to turn off System Integrity Protection in El Capitan
  1. Click the  menu.
  2. Select Restart...
  3. Hold down command-R to boot into the Recovery System.
  4. Click the Utilities menu and select Terminal.
  5. Type
    csrutil disable
  6. Close the Terminal app.
  7. Click the  menu and select Restart....
When system has normally restarted , open Terminal and type following commands
  1. sudo plutil -convert xml1 /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework/Resources/DefaultFontFallbacks.plist
  2. sudo sed -i ".orig" 's/Mshtakan/Arian AMU/'  /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework/Resources/DefaultFontFallbacks.plist
  3. sudo plutil -convert binary1 /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework/Resources/DefaultFontFallbacks.plist
Now you need to turn  on the system integrity protection

How to turn on System Integrity Protection in El Capitan
  1. Click the  menu.
  2. Select Restart...
  3. Hold down command-R to boot into the Recovery System.
  4. Click the Utilities menu and select Terminal.
  5. Type csrutil enable
  6. Close the Terminal app.
  7. Click the  menu and select Restart....
p.s.

if you use firefox browser you do not need to change font system wise. you just need to install the fonts then open firefox , go to the preferences, under "Content" tab you will find section "Fonts & Colors", click "Advanced...", in the section "Fonts for:" check "Armenian", than change font to "Arian AMU" for the following sections "Serif:", "Sans-serif:" and "Monospace:".

bonus...
whoever prefers typing armenian in phonetic layout you can download it from here
extract archive and copy the files into the directory "/Library/Keyboard Layouts/"









Tuesday, March 26, 2013

remove primary ip address without removing secondary one[s]




today i have faced a problem of removing ip addresses using iproute.  
i add two ip addresses from the same subnet using following commands

# ip addr add 10.35.2.129/24 dev eth0
# ip addr add 10.35.2.130/24 dev eth0


to see result

# ip addr sh
1: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
   link/ether a4:ba:db:b7:fa:db brd ff:ff:ff:ff:ff:ff
   inet 10.35.2.129/24 scope global eth0
   inet 10.35.2.130/24 scope global secondary eth0


as you can see ip address 10.35.2.130 which was added after 10.35.2.129 is flagged as secondary.
iproute works fine when you try to remove secondary address.

# ip addr delete 10.35.2.130/24 dev eth0

the problem starts when i remove a primary address. iproute deletes all secondary addresses which are in the same subnet with primary address. 

here i find explanation of secondary address according to the documentation:

  "secondary --- this address is not used when selecting the default
  source address for outgoing packets. An IP address becomes
  secondary if another address within the same prefix (network)
  already exists. The first address within the prefix is primary and
  is the tag address for the group of all the secondary addresses.
  When the primary address is deleted all of the secondaries are
  purged too. See the examples for the actual functionality of these
  steps."

in the docs i found nothing related to promoting secondary ip addresses in case if primary address was deleted. if you don't find it, it doesn't mean that it doesn't exist...

good news !!!
starting from 2.6.16 linux kernel supports promoting secondary ip addresses. 

to enable it do following

# echo 1 > /proc/sys/net/ipv4/conf/all/promote_secondaries


Friday, March 8, 2013

samsung galaxy s3 mini - gtalk app crash resolving



note:
 all  tools used in this article can be downloaded in one archive from here. the archive does not include android sdk (adb tool). this will work for builds I8190XXALJL. it is european build. Android version 4.1.1


my dear wife bought samsung galaxy s3 mini for personal use about 2 month ago. the device itself is pretty well made. it's smaller than its parent one s3 and it feels comfortable  in hand,  well specially in female hands. after one week of use my wife told me that gtalk app was being crashed every time she got a message. at that time i thought resetting the device to the factory settings would be the solution to the problem, but i was wrong. so i started to dig in ...

after some time of investigation i found something useful in this forum . folk with nickname bala_gamer found the root cause of the crash. thanks to him.  the gtalk app crash was due to typo in dimens.xml file which was located in the package framework-res.apk.

part of dimens.xml
============
<dimen name="notification_large_icon_width">55.0dip</dimen>
<dimen name="notification_large_icon_height">64.0dip</dimen>

the value for both of them should have been 64.0dip.

file framework-res.apk is located  in the directory /system/framework/. to make changes in  dimens.xml  i have to download framework-res.apk from phone to my pc, extract it, make changes in dimens.xml, rebuild package and upload it back. i must have root privileges for uploading the file into the /system folder on the s3 mini, which means i have to root s3 mini.

so my todo list looked like this

  • root device
  • modify and upload framework-res.apk into the phone

1. root device (s3 mini)

the fact that samsung s3 mini does not support fastboot made me upset, but on the other hand i had never heard about alternative cross-platform open-source tool-suite to the "Odin". why cross-platform ? because i'm a linux user!!! the tool name is heimdall and it mostly used to flash roms on the devices which do not support fastboot. 

1.1 install heimdall

first i installed heimdall. you can find deb files in archive. open a shell terminal and cd to the directory you put the heimdall binaries and type following.


[/home/tmartiro/heimdall/]$  sudo dpkg -i heimdall_1.3.1_i386.deb
[/home/tmartiro/heimdall/]$  sudo dpkg -i heimdall-frontend_1.3.1_i386.deb

now we are ready to flash recovery image which you can also find in archive .

1.2 download mode

power off s3mini. after your phone is powered off put the s3mini to the "download mode" by pressing  VOLUME_DOWN + HOME + POWER buttons.

1.3 flashing image

in "download mode" connect phone to pc via usb cabel and type in the shell terminal. invoke commands using root user.


[/root/]# heimdall detect

you should get output like this "Device detected"

[/root/]# heimdall print-pit

it prints all partition tables . we are interested in the recover partition. so select recovery in the output until you find something like this

  --- Entry #20 ---
  Unused: No
  Partition Type: 2 (EXT4)
  Partition Identifier: 19
  Partition Flags: 5 (R)
  Unknown 1: 1
  Partition Block Size: 491520
  Partition Block Count: 32768
  Unknown 2: 0
  Unknown 3: 0
  Partition Name: Kernel2
  Filename: recovery.img

you need to find partition identifier for recovery partition to use in the next command. in my case the value of  partition identifier was 19. after partition table is printed the phone will boot into the system automatically. so before you will invoke next command , put your phone in "download mode" again , as i described above.

[/root/]#  heimdall flash --19 recovery-clockwork-6.0.2.7-golden.img

after flashing the image the phone will reboot automatically  using your preferred way of copying copy CWM-SuperSU-v0.87_.zip  in to the Download folder located on the phone.
my way of copy


[/home/tmartiro]$ adb push CWM-SuperSU-v0.87_.zip /sdcard/Download/

afterwards you need to reboot the phone into the recovery mode


[/home/tmartiro]$ adb reboot recovery

from the recovery menu select the "Install zip from sdcard" > "choose zip from sdcard" and point to the CWM-SuperSU-v0.87_.zip file. After install is complete hit "reboot to system" from the menu .

now we are root on the system... to make sure that you are root , type


[/home/tmartiro]$ adb shell
$ su -
# id

if you see  something like this uid=0(root) gid=0(root) then our abra-cadabra things with rooting was done.



2. modify framework-res.apk

download framework-res.apk file from phone


[/home/tmartiro]$  adb pull /system/framework/framework-res.apk

install the framework using apktool (you can find tool in archive too. it needs java and aapt. make sure that they are in the PATH)


[/home/tmartiro]$  apktool if framework-res.apk

decode it 
  
[/home/tmartiro]$  apktool d framework-res.apk

these commands will create directory "framework-res" in the directory where you run them. 
the dimens.xml is located in the framework-res/res/values/dimens.xml. open xml file with your favorite editor, change value of  "notification_large_icon_width" to  64.0dip and save.

in the other directory unzip framework-res.apk


[/tmp/frm/]$  unzip framework-res.apk

in the extracted directory you should find "AndroidManifest.xml" file and "META-INF" directory. copy into the folder created by apktool


[/tmp/frm/]$  cp -r  AndroidManifest.xml META-INF/ /home/tmartiro/framework-res/build/apk/

and build new framework-res.apk by invoking following command


[/home/tmartiro/]$  apktool b framework-res



2.1 copy process

new generated framework-res.apk is stored in the folder ./framework-res/dist/framework-res.apk
now it's time to copy file into the phone. I copied it first into the Download folder  where i had a permission to copy without having root privileges


[/home/tmartiro/]$  adb push framework-res/dist/framework-res.apk /sdcard/Download/

then we should connect to the phone shell


[/home/tmartiro/]$  adb shell

and become a root on the phone

$ su -

you will see root prompt like this

#

now copy file from Download folder to system folder
 
# cp /sdcard/Download/framework-res.apk /system/framework/framework-res.apk

and fix the permissions


# chmod 644 /system/framework/framework-res.apk

exit from phone terminal. now you should reboot the phone into the recovery mode


[/home/tmartiro/]$ adb reboot recovery

from recovery menu go to "wipe cache partition" and wipe cache. then go to "advanced" > "wipe dalvik cache" and wipe it as well. after caches are wiped go to "reboot system now".


the system will reboot with new generated framework. congrats!

p.s.
if something goes wrong during boot, you can connect to phone shell and restore the original framework-res.apk see section 2.1

p.s.s

in the archive file you will find already generated framework-res.apk by me. ( "framework_patch/framework-res/dist/framework-res.apk")

p.s.s.s

in order to debug the process of boot


[/home/tmartiro/]$ adb logcat


Friday, October 26, 2012

how to make skype 4 tray icon visible in ubuntu 12.10


i think many of ubuntu/unity users experienced the problem of skype icon visibility in the notification panel. today i will show you how to make visible the skype icon.

by default ubuntu/unity project allows several applications to be visible in the notification panel.  if you want to get the list of that applications which are defined in the "white list" try to execute the following command in the terminal.

gsettings get com.canonical.Unity.Panel systray-whitelist

you should get something like this:

['JavaEmbeddedFrame', 'Wine', 'Update-notifier']

these are the application names which are allowed to be visible in the notification panel. 
so to solve the problem with skype icon we should inject skype application name to this list. don't hurry to close opened terminal window and type this command

gsettings set com.canonical.Unity.Panel systray-whitelist "['JavaEmbeddedFrame', 'Wine', 'Update-notifier', 'Skype']"

after that quit  skype application if it was running and start it again. boom... you should see the icon.


Tuesday, September 11, 2012

colorguide: making-of



who  knows me as a developer? nobody! i'm mechanical engineer who, by chance, got involved in information technology field and stayed there till now )


before this i had some experience in developing some small tools to solve daily routine problems at work place. i don't know exactly definition of the word developer, but i know one thing - i want to write useful stuff for everybody and it should be free. so the question is: what would be more useful than a tool solving any daily  problem that anybody can face? 


several months ago i got a call from my wife. she told me whether there was any kind of application for her phone (android base) which would allow her detect a color and find its matching colors. hmmm.. i told her that i would research in google play store and would call her back. the research process was over without any success to find  application with such functionality on the board. and than i thought that could be my chance to contribute to the world with something useful. 


i started the project called "colorguide" without having any experience in developing android apps under my belt. it is not  professional application yet, but i find it is small tool which helps you buy, for e.g., right colored scarf for your girlfriend which will suit her coat =) the application detects the color and suggests the matched color in real time. i used the color5k algorithm to calculate matching colors. 

colorguide logo




you can check it out from google play store.








i am open for suggestions. feel free to mail me: tmartiro at gmail dot com.

p.s.
thanks to my friends and especially to my wife for supporting and motivating me.


Friday, February 17, 2012

udp/tcp connection using pure bash


hi guys, today i am going to show you how we can open tcp or udp connection to a server using pure bash technique. let us assume that the server ip address is 192.168.0.1 and the service which we are going to connect to is web server. it binds 80 port on server. at first we should open file descriptor that will point to the remote server and port.


here is the technique of  descriptor opening by using only bash. 


exec 456<>/dev/tcp/192.168.0.1/80


now we have 456 file descriptor which is associated with server 192.168.0.1 port 80. transfering data using this file descriptor is similar to writing data into the file :) 


echo "GET / HTTP 1.0" >&456


in this example i used  tcp protocol for communication. if you want to open a connection using  udp protocol just point a file descriptor to  udp device like this


exec 786<>/dev/udp/192.168.0.1/686



that all folks.

Sunday, November 20, 2011

no screen, no nohup..


most of the it guys, me included, always face the situation like starting to delete or rsync some data in a ssh session, they realize that their isp is not so trusty or they have to go offline halfway through.

i would do the following actions in this situation 
  •  cancel the process
  •  run it using nohup, or run it in virtual terminal using screen

what will you do if the building three procedure of the rsync takes 4 hours and after 3 hours you catch yourself on a idea that you've forgotten to run it using above mentioned methods. of course you can kill the process and rerun it but it will be time wasting.

when  i were reading the bash reference manual in the section "7.1 job control basics" i found out that you were able to do that. there is the command called disown which helps you to do that.

here is the quote from manual concerning it:


disown [-ar] [-h] [jobspec ...]
Without options, each jobspec is removed from the table of active jobs. If the -h option is given, the job is not removed from the table, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP. If jobspec is not present, and neither the -a nor -r option is supplied, the current job is used. If no jobspec is supplied, the -a option means to remove or mark all jobs; the -r option without a jobspec argument restricts operation to running jobs. 
you can pause it (ctrl+z), background it (bg), and then disown  it so it is protected from SIGHUP when you quit your ssh session. 

watch the screen cast as an example