Posts

    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.



    Friday, 23 May 2014

    Password protect files on fly using crypt-editor


    I always wanted an editor which can help me edit text securely with password protection using which I can easily create, save, edit files on fly. I am sure that there are some editors which can do it. However I felt that instead of an editor, it is better to have an interface which will allow me to edit files using my favorite editor while password protecting it. So I wrote a script called crypt-editor which uses gpg/mcrypt to encrypt and decrypt files enabling users to edit files using any editor.


    Fork me on Github

    Usage

    Say you want to create/open a file using gedit:
    crypt-editor gedit [filename]
    You will be asked to enter the passphrase. Then gpg/mcrypt decrypts the file (if already exists) and opens it with gedit. On closing the file gpg/mcrypt encrypts it back and deletes the decrypted file.
    If you do not specify the editor, the file is opened in vi editor (my favorite so it is default :P)
    crypt-editor [filename]
    Complete option list of crypt-editor:
    crypt-editor -help
    crypt-editor [filename]
    crypt-editor [editor] [filename]
    crypt-editor [-k key] [filename]
    crypt-editor [-k key] [editor] [filename]
    
    To create new file with mcrypt instead of gpg use -m option
    crypt-editor -m [filename]
    
    
    Examples:
    crypt-editor passwords
    crypt-editor gedit passwords
    crypt-editor -k pa$$word passwords
    crypt-editor -k pa$$word gvim passwords


    Installation

    Setting up crypt-editor is simple and straight forward.
    git clone https://github.com/alseambusher/crypt-editor
    cp crypt-editor/crypt-editor /usr/bin
    
    If you want to use mcrypt instead of gpg, you have to install mcrypt.
    apt-get install mcrypt

    Say Thanks to birthday wishes on Facebook automatically

    One of the main reasons why people turn into computer geeks is because they are lazy :P Yesterday was my birthday. Again, thanks for all the wishes :) However I was lazy to manually thank each and every post on my Facebook wall. So I wrote a simple python script using Facebook graph API to say thanks to each of them. I didn't stop there. I am aware that many people think that thanking people manually is something that has always been very tiring. So I searched for all the simpler alternatives available to do this task and found that there was a Facebook app called "Say Thank You". It is simple and neat. However, it requires people to give access to post, like, get friend list..etc. Well, that is a mini privacy invasion :P. So it is a not a good alternative. Also in future Facebook might think that it is doing something against their policies..blah blah blah and bring it down. So not a permanent solution either.
    Hence I decided to rewrite the script I had written in python to javascript to make it accessible online. Well, here it is:

    http://alseambusher.github.io/say-thanks/

    For this you will need to get the access token. Getting access token is simple:

    • Go to developers.facebook.com.
    • Under Tools in the menu, go to Graph explorer.
    • Click on Get Access Token if access token isn't there already.

    Note that as this runs completely on the client side, users can safely use it without giving access to anybody (Although it requires you to give access token, it is not stored anywhere. See source ). And access tokens expire after sometime.


    Sunday, 27 April 2014

    Enable Tree View in Ubuntu 14.04

    I updated to ubuntu 14.04 recently. I was very disappointed when I came to know that the awesome "tree view" was not available in nautilus. I searched online to find if there was any way to get it back. Most suggested to switch to older version of nautilus, which is simply absurd. So I decided to figure out a way myself and I did.
    To switch to tree view first install dconf-editor.

    sudo apt-get install dconf-editor


    Then open dconf-editor. Go to org -> gnome -> nautilus -> list-view and check use-tree-view.

     Now your list view is tree view.