Posts

Essential adb Command Examples

Copy file to your Android device from your computer adb push    - copy file/dir to device example: adb push c:\mygame.apk /sdcard Copy file from your Android device to your computer adb pull    - copy file/dir from device example: adb pull /sdcard/mymovie.avi c:\downloads Install app from your computer to your Android device adb install [-r] [-s] - push this package file to the device and install it                                  ('-r' means reinstall the app, keeping its data)                                  ('-s' means install on SD card instead of internal storage) example: adb install c:\mygame.apk Uninstall an app from your Android device adb uninstall [-k] - remove this app package from the device                                  ('-k' means keep the data and cache directories) example: adb uninstall com.example.mygame

Breaking Up With Ubuntu

Image
After using exclusively for more than seven years, I'm breaking up with Ubuntu. I got a new laptop, turned it on, got rid of Windows, installed Ubuntu and fast forward a week I'm still struggling to set up the video driver and audio driver. My clients are tired of waiting for my computer to get fixed, emails have started to pile up, and at this moment I remember the statistics of Linxu being popular among college students only. I've listed several bugs here which have been haunting me, but none of these is the reason for giving up on Ubuntu. Every software has some bug and, with time they will get fixed along with welcoming new ones. I'm giving up on Ubuntu because of the change in vision of Canonical. They are trying to do everything that any other big companies are doing, Ubuntu one, Ubunt Phone, Ubuntu tablet etc. This is fine, but you need to have a solid foundation beforehand you start experimenting with other products. Ubuntu on a desktop is not perfec

Logging Handler With Buffering And Uses Amazon SES For Python

This Python logging handler can be used to combine multiple log message in one email message and send the log email using Amazon SES . Boto is used to send email using Amazon SES. Email will be send once the buffer reaches the capacity you've specified. To force send the email before it reaches the buffer capacity you can shutdown the logger by calling its shutdown method.You can simultaneously keep logging in file or other places by adding more handler.

Fake SMTP Server For Development

Image
This fake SMTP server comes handy when you have to do development which requires sending hundreds of email. This will act as an SMTP server but doesn't relay emails but saves them in a file in predefined location and also display the emails in the GUI itself as they comes. This is cross compatible Java jar file and can be launched easily by typing: java -jar fakeSMTP.jar after downloading it from this website.

Fix Bad Distorted Audio And Sound In Geanymotion

Image
Geanymotion is a great product. As soon as I knew about this, I've been using this for my Android development. One problem bothering me was the audio and sound coming from Geanymotion was totally bad and distorted. Not only that any sound playing in my computer would get distorted for few seconds when sound was playing in Geanymotion. Turns out Geanymotion was using Alsa instead of PulseAudio. To fix this: Open VirtualBox. Yes not Geanymotion. You'll see list of all the Android devices you've created from Geanymotion here. Click on the Android device you want to fix and click settings. Go to Audio tab in settings. In Host Audio Driver change from Alsa to PulseAudio. Press OK to close the settings. Repeat this process for all Android devices. Now run your Android device normally from Geanymotion and you should hear problem free perfect audio.

Skype doesn't start

On Ubuntu 13.04 my Skype refused to start. Maybe something went wrong while trying to install driver for ATI Radeon 7730m graphics card. So the first thing to do to troubleshoot is to try, to run Skype from terminal. Open terminal and type skype and press enter. If you get the following error: skype: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory Then run the following command in terminal again and this should fix Skype not starting problem. sudo apt-get install --reinstall libgl1-mesa-glx:i386

Slice Bitmap Image In Android

With this simple function you can slice one bitmap image and return array with the sliced images. Just pass in the bitmap you want to slice and number of rows and columns you want it sliced into. public static ArrayList GetSplittedBitmap(Bitmap picture, int numRow, int numColumn){ ArrayList imgs = new ArrayList (); int pieceHeight = picture.getHeight()/numRow; int pieceWidth = picture.getWidth()/numColumn; for(int i=0; i for(int j=0; j imgs.add(Bitmap.createBitmap(picture,j*pieceWidth,i*pieceHeight,pieceWidth,pieceHeight)); } } return imgs; }

Number System Conversion

Convert numbers between decimal, binary, octal, hexadecimal or any other number within base 2 and 36.

Interview Question

Problem: For a given pyramid find out the largest possible sum of numbers while travelling down from the top. ======================================================================== EXAMPLE 1: 1 2 3 4 5 6 The possible routes going down on this pyramid would be 1+2+4 1+2+5 1+3+5 1+3+6 ANS: 10 ======================================================================== EXAMPLE 2: 1 2 3 4 5 6 7 8 9 1 The possible routes going down on this pyramid would be 1+2+4+7 1+2+4+8 1+2+5+8 1+2+5+9 1+3+5+8 1+3+5+9 1+3+6+9 1+3+6+1 ANS: 19 Solution in Python: #!/usr/bin/env python # -*- coding: utf-8 -*- def findMaxHeight(items,pyramidHeight):     '''     This def returns the greatest path.     Logic:  From second last line for each element find if its left or right child is greatest.             Replace that element with sum of that element and the greatest child.             In the end

The dark side of catch all

Image
I use my own domain for email service which uses Google Apps For Your Domain . I had almost 0% spam in my mailbox. For this I used variety of approaches like: Mailinator: I've been using Mailinator from a very long time for signing up for any non important website. After webmaster became aware of popularity of mailinator they began blocking Mailinator and its affiliated domain for signup. After that I setup my own mx record to work with Mailinator . You can also use anything@extra.roshankarki.com.np and check your email at anything.mailinator.com . If you haven't realized yet anything, can be literally anything. The only problem with this method is you can't use this with more personal website. The + trick:  The beauty of Gmail is that you can add anything in your email address username part by adding +. So whenever you've to signup for websites you can use email address like username+newwebsite@gmail.com . If you start receiving spam on  this email address you can

Cool CSS tricks

CSS to turn everything in website upside down: body { -webkit-transform: rotate(180deg); transform: rotate(180deg); } CSS to blur everything in website for every 30 seconds body { -webkit-animation: blur 30s infinite; } CSS to spin everything in website body { -webkit-animation: spin 5s linear infinite; animation: spin 5s linear infinite; } CSS to flip all images of website img { -webkit-transform: rotate(180deg); transform: rotate(180deg); } CSS to change font of everything of website to Comic Sans  body, p, body p, body div p { font-family: 'Comic Sans MS', cursive !important; } CSS to spin all images of website  img { -webkit-animation: spin 1s linear infinite; animation: spin 1s linear infinite; } CSS to hide second paragraph of a website p:nth-child(2) { display:none !important; } CSS to change cursor of website to wait permanently  html { cursor:wait !important; } CSS to hide the cur

Earthquake alert in SMS or Email

Image
Not everyone can afford Earthquake alarm. But something is always better than nothing. Even if you don't have earthquake alarm you can use this method to get quick SMS/email alert after an earthquake comes. Go to  https://sslearthquake.usgs.gov/ens/ and you'll be greeted like this. Here sign up for the service after which you can configure your alert, i.e. choose which location you like to receive alert for and what magnitude of earthquake. From now on right an earthquake you'll receive an email. In the screenshot above you can see that I got SMS after an earthquake of more than 5.0 in magnitude for my country Nepal. To receive SMS, in the email form use +977yourmobilenumber@sms.ncell.com.np, if you're Ncell user from Nepal. For Nepal Telecom user go to nearest shop and buy yourself a SIM card with better service i.e. Ncell.