Pages

Friday 29 August 2014

My tiny contribution for a prosperous digital age

I got my first salary few days back. I could think of hundreds of ways to spend that money. But I wanted to do something else, something I've always wanted to do. I donated a tiny amount of my money to Wikipedia. I didn't stop there. I have contributed to open source earlier too, but only in the form of code. I felt that it is time for me to contribute monetarily. I made donations to Ubuntu foundation and Tor project. The amount of joy I got out of doing this was unfathomable and I am sure that nothing else would've made me more happy.




I have decided to spend a tiny percentage of my salary to donate for such organizations every month. I believe that donating as little as $2 each can shape a better and prosperous digital age. And I think people like me who are in their early 20s with absolutely no responsibility to bear should step up and do this too. Here is a list of organizations which could use your donations:

Wikimedia Foundation - Makers of Wikipedia and wikia. Providing free access to the sum of all human knowledge to every single person on the planet.

Ubuntu foundation - On a mission to make linux desktop reach the common man.

Tor project - Anonymity online.

GNU Project - Father of the concept of free software.

The Apache Software Foundation - There are no words to describe their contribution to free and open source software.

The document foundation - makers of Libreoffice.

NOTE: I will keep updating the list.

Wednesday 27 August 2014

Android L theme on Cyanogenmod 11

After Google announced that the new Material Design is going to be adopted on Android's next release, currently codenamed Android L; lot of us have wanted to try it. Unfortunately it (dev version) is available only for nexus 5 and 7.  Thankfully there is Android L theme by tung91 on google play which brings near Android L experience to other users.

You can try Android L or Android L Dark.
This is how it looks like on my nexus 4:








Decrease the size of navigation bar on Nexus

I feel that the default size of navigation bar is too huge and it occupies a lot of space on the screen. There is a simple way in which you can change the size of it if your phone is rooted.

Step1


Install Xposed Installer. Go to Framework and install neXus navbarz. Then select it and restart the device.

Step2


Open neXus navbarz. Go to navbar options and set navbar height! Restart the phone to see the change!




Tuesday 26 August 2014

Google Calendar sync fails after deleting stock calendar app in CM11

I installed CM11 on my Nexus 4. After I installed Google Calendar, I thought deleting stock AOSP calendar app and few other depending apps wont hurt. Unfortunately Google calendar sync stopped working after that. "Calendars to display" was empty and "Calendars to sync" never completed loading. When I searched for solution for this online, people suggested to do a reset; which I didn't want to do. So I tried reinstalling the default AOSP calendar app. It fixed the problem!!!

Download the following apks and install them on your phone.

GoogleCalendarSyncAdapter.apk
SecCalendar.apk
SecCalendarProvider.apk

Update
Some people say that they face the following error while signing in.

"Couldn't sign in. There was a problem communicating with Google servers. Try again later"

After installing the above apks, if you open the calendar app directly you will get this error. You have to restart the phone to fix it.

Thursday 21 August 2014

Backspace doesn't work on vi in cygwin

Unfortunately I am forced to use windows at work. So I installed cygwin to run linux commands. While editing using my favourite editor vim; I realized that backspace doesn't work at all! However I found out a simple way to fix it. Add the following line to .vimrc or .virc

set backspace=indent,eol,start

Now backspace magically works!

Later I found out that this is not just in cygwin and is pretty common in unix based systems.

Monday 18 August 2014

Beauty of shopt

shopt is a builtin command which can be used to customize the way you interact with terminal is several ways. Some of them are:

Ignore typos in path while changing directory

Say you want to go to /home/alse/path and you type /home/alse/paht instead, the following command will intelligently take you to /home/alse/path

shopt -s cdspell

Make commands case insensitive in linux

To be frank I like case sensitiveness of commands in linux unlike in windows command prompt. It makes you more careful while writing scripts. However I know some people who would like case in-sensitiveness.
It is possible to do this using shopt command.

shopt -s  nocaseglob

Remove the need of 'cd' while changing directory

Tired of typing cd command before path? Try this

shopt -s autocd

Now you can simply type the path to go to that directory.

Store Multi-line commands in history

See this blog post http://lifepluslinux.blogspot.in/2014/08/storing-multi-line-commands-in-history.html

shopt -s lithist

Mail warn

If set, and a file that Bash is checking for mail has been accessed since the last time it was checked, the message "The mail in mailfile has been read" is displayed.

shopt -s mailwarn

SIGHUP by default

Bash will send SIGHUP to all jobs when an interactive login shell exits.

shopt -s huponexit


Storing Multi-line commands in history using shopt

It is hard to reuse multi-line commands as the newlines are replaced by semicolon and the many line command is converted to a single line. For example:

for i in $( ls *.txt)
do
pwd
echo $i
cp $i /bin
done

After executing it, when you press up button to reuse it, the command becomes:

for i in $( ls *.txt); do pwd; echo $i; cp $i /bin; done

Forget about reusing, I cant even understand what it does when so many things are stuffed in one line!
I found a way using which it is possible to retain the newlines in history using shopt.

shopt -s lithist

Now when you press up button you will see the command in multiple lines! win!

If you want this to be enabled by default add "shopt -s lithist" at the end of file ~/.bashrc


UPDATE
Also multi-line commands are screwed up when you add comments. For example

for i in $(ls)
do
echo "a"
#echo $i
done

becomes for i in $(ls); do echo "a" done (note that there is no semicolon after echo "a". Hence it takes echo "a" done as one command). Hence you will end up scratching your head to figure out what went wrong :P




Can't safely remove USB drive. Device busy!

We have seen cases where we are not allowed to safely remove or eject USB drive because of the fact that some process is using resources on the drive. The easy way to get out of this is to kill the process which is doing this. For example if the problem is the result of stalled file copying (say, using nautilus) then killall nautilus should do the trick. However it happens that sometimes it is not possible to figure out which process is accessing the USB drive. So how do we find the rogue process(es)?

fuser to the rescue!

fuser -k -15 -m  /dev/sdb1

The above command will kill all the processes accessing your device! Replace /dev/sdb1 with the device file corresponding to your USB device.

Now try ejecting/ safely removing. It will mostly work! 

Monday 11 August 2014

Dry-run package installation without installing them

Sometimes we might want to perform a 'dry-run' of package installations without actually installing them in order to prevent unwanted changes from happening. It is very much possible and is highly recommended specially while installing packages from untrusted sources. So do this before installing anything:

$ apt-get install --dry-run [package]

If you have a debian (.deb) package already and would like to see what changes it is going to make, do this:

$ dpkg --dry-run -i package.deb

This will definitely save you someday!

Friday 8 August 2014

Send exe files through gmail using steganography

Mails used to be the easiest way to spread malware. So obviously Gmail doesn't allow users to attach windows executables (.exe) to mails in order to protect it's users from screwing up their windows machines. However, we may have to send .exe files which are not malware via mail. Before, you could've just renamed the extension from .exe to something else or made a zip/rar archive and gmail would simply allow you to attach it. Sadly, it doesn't work anymore as gmail started reading file headers of attachments and started reading files inside zip/rar archives.

So I figured out a simple way to do this using steganography. The idea here is to embed the exe file inside any image and attach it to the mail. Gmail will think that it is just an image and will be oblivious to the fact that there is an exe file hidden inside that. Later the other user can simply extract the exe file from the image and use it .

Usage

Download mailexe (Don't forget to make it executable).

Sending


$ ./mailexe -e  [exe file] [image file]

A file called image.png will be created. This image file has exe file hidden in it. Send this via gmail.

Receiving


$ ./mailexe -d [original image] [duplicate image]

A file called output.exe will be created. This is exe file which had to be sent!!!!! Congrats!


How it works?

Sending

Step1

Convert the image and the executable to base64 and save it in a file

$ base64 [image file] > temp
$ base64 [exe file] >> temp

Step2

Decode base64 file and save it as image

$ base64 -d temp > image.png

Step3

Send image.png and the original image file via gmail

Receiving

Step 1 

Download both the images and convert both of them to base64 and extract that base64 part of exe file.

$ base64 [original image] >original
$ base64 [duplicate image] >duplicate
$ diff -ed original duplicate >diffed
$ tail -n +2 diffed |head -n -1 >exe.64

Step2

Now convert extracted base64 to exe

$ base64 -d exe.64 > output.exe

Now you can simply run the exe file.