How to turn on Android device without the power button

How to turn on Android device without the power button 

 

I broke the power button in my Android phone and I was keeping it alive by constantly charging it (so the battery won't die and I won't lose any data in my phone in case it get switched off).

 

But when I woke up today morning, I realized I forgot to connect my charger last night, and now my phone is gone forever :( But I wasn't ready to give up it so easily. So I looked for a way to "revive" this dead phone :D and luckily I found some resources which I tried (all of them) and here's what worked for me. 

 

First you need some charge on your phone. Connect it to a charger for a while.

 

Then you need to start your phone in the fast boot mode. This is easy. Just hold your volume down button (or up button? try.) and connect your usb cable while you're holding that volume button. Make sure you actually connect the other end of the cable to your computer as well. If it goes well, your phone should power up and should take you to the fast boot screen. Now its kinda powered on, yay!

 

Now keep it like that and come back to your computer. You need android platform tools. Head over to the following page and download them to your computer. Pick the right one for your OS.

 

https://developer.android.com/studio/releases/platform-tools

 

 Extract the files and copy it to somewhere in your computer. I kept these files in the following folder. 

 

/Users/nimeshkasrimal/Documents/adb/platform-tools

 

Now you need to add this path to your PATH system variable.

 

echo 'export PATH=$PATH:/Users/nimeshkasrimal/Documents/adb/platform-tools/' >> ~/.bash_profile

 

and then 


source ~/.bash_profile

 

to update your current terminal session with the new path. (If you're on Windows, this is a bit different, just Google it and you will find how to do this)

 

Alright, now you are ready. Just two commands away. 

 

Now if you run 

 

fastboot devices

 

It should list your phone in the command output. (If it doesn't show your phone, reconnect it the computer and run the command again.)

 

~/Documents/adb/platform-tools> fastboot devices
84RDU17815002927    fastboot

 

and now, all you need to do is, run the following command.

 

fastboot reboot

~/Documents/adb/platform-tools> fastboot reboot
Rebooting                                          OKAY [  0.022s]
Finished. Total time: 0.022s


This should reboot your phone and you're done! :) I hope this blog post will help someone. Please leave a comment and let me know if you have any problems, suggestions :)

Fix Composer Memory Error - PHP Fatal error: Allowed memory size of xx bytes exhausted



I got this error while installing a Laravel package today and got it fixed so easily.

The exact error was this:

PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors. 


To fix this, you can either increase the memory limit for php, or ignore the memory limit for this command at the time you run this. I opted for the second method as I wanted to do this just one time.

Just run the same command as below:

php -d memory_limit=-1 <composer-bin-path> require <package-name>
Ex:
php -d memory_limit=-1 /usr/local/bin/composer require kreait/laravel-firebase

You can find the path for composer by using the following command. which composer
vagrant@homestead:~/$ which composer
/usr/local/bin/composer


Hope this will help someone.

Fix - DBeaver SSH tunnel connections fail with invalid privatekey error

Invalid privatekey error in DBeaver

I tried to connect to a remote Postgresql server with DBeaver and got this error today. The error message said my private key was invalid. To check this further, I tried to login to the server using the terminal as usual and it worked. So I realized the issue must be in DBeaver, and not in my private key.
After a few google searches, I learned that DBeaver does not support new OpenSSH private keys format by default. So as a workaround, I had to convert my key file to old PEM format using the following command and use it with DBeaver.

This will work if you already generated the keys with new format and want to use them with DBeaver.

ssh-keygen -p -m PEM -f ~/.ssh/id_rsa
If you want to generate new keys, use the following.

ssh-keygen -t rsa -b 4096 -m PEM

That’s it. I hope this will help someone.

Install Python packages to the current directory using PIP in Ubuntu 18

distutils.errors.DistutilsOptionError: can't combine user with prefix, exec_prefix/home, or install_(plat)base

I wanted to test something today and had to write a simple python script which required a few python modules. So I installed them using pip, but there was a little problem. I don't like it when package managers install packages globally or system wide. I wanted them to be installed in the current local directory. There's an option to create virtual environments for Python, but this was a simple script and I didn't want to do that, I just wanted to have the modules installed locally.

PIP has a --target option to define the target location to install the modules. But for some reason, it was not working and kept giving me the following error. It seems PIP uses the user scheme by default to install and when I use --target, it throws an error.

distutils.errors.DistutilsOptionError: can't combine user with prefix, exec_prefix/home, or install_(plat)base

After searching for a while, I found a workaround and got it working. Here's how to do that.  PIP also has another option as --system, it actually disables the user scheme option. That was it. But this option was not listed in pip man page.

Anyway, the final command should look like this:

pip install --system --target <target-dir> <package-name>

Ex: pip install --system --target ./ pexpect

Hope this post will save someone's time :)

VIM - get back to edit mode after Ctrl + S freezes the screen.

VIM - get back to edit mode after Ctrl + S freezes the screen.


I'm used to press ctrl + s all the time that even when I'm using VIM to edit some codes, I press it and you know, it freezes everything and you can't do a thing afterwards.

It has always been a problem and the first time I actually had to google how to get back to vim, today it happened again, and I had my blog open in my browser. So I thought I should add it in my blog, so that I would never forget it ;)

Anyway, its so easy, to get back to VIM, just press Ctrl + q. Then everything will work normally.

If you are curious why it happens, then here's the reason for that. When you press Ctrl + s, your terminal sends a signal (XOFF) to pause the process which sends data to it. To continue the process, you need to send an XON signal back, and it can be done by pressing Ctrl + q.

I hope its clear and it will help someone. Please feel free to leave a comment and let me know if you think I need to correct anything :)