Monday, 27 January 2014

Enable paste Ctrl+V in Dos Console Windows

  1. Create file and set extension to .ahk
  2. Open file by notepad
  3. Insert this code to file and save
  4.  #IfWinActive ahk_class ConsoleWindowClass  
     ^V::  
     SendInput {Raw}%clipboard%  
     return  
     #IfWinActive  
    
  5. Download, install AutoHotkey and run it
  6. Double click on your script (your file should be recognized by AutoHotkey by displaying AutoHotkey icon)
Information from howtogeek.com

What you should do, and what don't (future example here)

Save time by using
String.format (Object object, StringBuffer buffer, FieldPosition field)(

You shouldn't do:
      public String generateDateString(long timeMilises) {  
           String dateString = "";  
           Calendar c = Calendar.getInstance();  
           c.setTimeInMillis(timeMilises);  

           dateString = ((c.get(Calendar.DAY_OF_MONTH) < 10) ? ("0" + c.get(Calendar.DAY_OF_MONTH))  
                     : (c.get(Calendar.DAY_OF_MONTH)))  
                     + "."  
                     + (((c.get(Calendar.MONTH) + 1) < 10) ? ("0" + (c.get(Calendar.MONTH) + 1))  
                               : (c.get(Calendar.MONTH) + 1)) + "." + c.get(Calendar.YEAR);  
           return dateString;  
      }  
You should do:
      public String generateDateString(long timeMilises) {  
           String dateString = "";  
           Calendar c = Calendar.getInstance();  
           c.setTimeInMillis(timeMilises);  
           
           dateString = String.format("%02d.%02d.%d", c.get(Calendar.DAY_OF_MONTH), c.get(Calendar.MONTH)+1, c.get(Calendar.YEAR));

           return dateString;  
      }  

Tuesday, 7 January 2014

Easy way to hide softinputmode softinputkeyboard example

Here is the code:
 public void hideKeyboard(Activity activity) {  
   activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);  
   InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);  
   View cur_focus = activity.getCurrentFocus();  
   if (cur_focus != null) {  
     inputMethodManager.hideSoftInputFromWindow(cur_focus.getWindowToken(), 0);  
   }  
 }  

Thursday, 2 January 2014

Run project as default by USB DEVICE instead EMULATOR - Intellij Android Studio


To make run your projects as default and don't waste time (I am talking about imported 50+ project at once) here is the solution.

Every imported project has own hidden .idea folder placed in root folder. There is something like workspace.xml file. Open it in example by notepad++ and click now CTRL+H(shortcut to replace).
Try replace:

from (whole text with quotes):
"TARGET_SELECTION_MODE" value=".+"
to:
"TARGET_SELECTION_MODE" value="USB_DEVICE"

".+" (quote dot plus quote)  in regex means select starting with quote, take anything till you get next quote

make sure you selected regular expression option in notepad search dialog

Now save file and try run your IDE with projects.

If you don't see your hidden .idea folder try search somewhere to turn it on, it's easy- link

PS. if you have problems with project, make sure you deleted all R files and rebuilded projects.