Thursday, April 12, 2018

VIM cheat sheet

Basic basics :)
i - start editing, current symbol
a - start editing, next symbol
Esc - stop editing
:w - write to disk
:w <filename> - write to specified file
:q - quit vim
:wq - write and quit

Extended basics
dd - remove line
dw - remove word
d10d - remove 10 lines
d10w - remove 10 words
d100d - I think you catch it
yy - copy line
pp - paste on next line

More useful things
:%s/<source text>/<replace with this>/g - search and replace all text occurances.
:g/^$/d - delete empty lines

Thursday, March 29, 2018

Android: Remote control or "Oh, help, my screen is broken!"

Essentaials:


  1. You should have USB Debugging enabled. There is no other way!
  2. It would be MUCH easier if you have MyPhoneExplorer installed on phone.

Making calls and getting messages.

Oh, no! Phone crashed "into garage" (C) ALF and I still need it, What to do?!

First things first:

If you had your phone connected to PC through MyPhoneExplorer, you can still send SMS and make calls, read messages and go on with your tiny happy life.

If you had phone connected to PC via USB, then you can use keyboard/screenshot feature of MyPhoneExplorer to interact with your phone via mouse and PC. 
/!\ NOTE: In my case it was in "view only mode", so I could not fully interact.

Another way to get things done

You can also drive your phone using bluetooth keyboard. It's not most uncommon thing.

ADB or Let's do a little hacking around

If your screen is broken it doesn't mean you can't control android. There is a fabulous tool called ADB.

First of all you'll need android SDK platform-tools.

As soon as you are sure you have adb.exe, connect your phone via USB (remember, USB debugging should be on, otherwise you should go and buy new screen directly).

Console stuff

Let's check we see our phone
C:\Android\SDK\platform-tools\> adb.exe devices
Which gives us serial 
DDB412GAVSD device

Note, that you should have only one device connected at a time.

Let's dive into console
\> adb.exe shell
gives
shell@X1234:/ $

Yes, this is our shell

Hence you got so far, I assume you know what you are doing. 

Run baby run

Now, let's imagine that we want to run an application. First we wan to know it's name.
Use package manager:
:/ $ pm list packages -f 
gives us full list of packages with path (-f)

woou, that's kinda long list, give it some grep
:/ $ pm list packages -f | grep whatsapp
gives us only whatsapp (assuming we wanted it).

Splendid, now let's run
:/ $ am start -n com.whatsapp/com.whatsapp.Main
/!\ NOTE: You can optionally specify flags with -f key.

This will suffice for a start.

VIM cheat sheet

Basic basics :) i - start editing, current symbol a - start editing, next symbol Esc - stop editing :w - write to disk :w <filename> -...