Posts

Showing posts from March, 2013

Shortcut Keys for android emulator/avd

There are few shortcut codes/keys which will help you when you are debugging with android emulator. Main Keyboard Shortcuts 1. Home            -   Home Button Of Keyboard 2. F2                 -   Left Softkey / Menu / Settings button (or Page up) 3. Shift + F2      -   Right Softkey / Star button (or Page down) 4. Esc                -   Back Button 5. F3                 -   Call/ dial Button 6. F4                 -   Hang up / end call button 7. F5                 -  Search Button Other Device Keys 1. Ctrl+F5         -  Volume up (or + on numeric keyboard with Num Lock off) 2. Ctrl+F6        -   Volume down (or + on numeric keyboard with Num Lock off) 3. F7                -   Power Button 4. Ctrl+F3        -   Camera Button 5. Ctrl+F11      -   Switch layout orientation portrait/landscape backwards 6. Ctrl+F12      -   Switch layout orientation portrait/landscape forwards 7. F8                -   Toggle cell network 8. F9                -   Toggle cod

How to kill an Android activity?

 How to kill an Android activity when leaving it so that it cannot be accessed from the back button? All you need to do is call finish() method in Activity class like following code snippets. Intent intent = new Intent ( this , NextActivity . class ); startActivity ( intent ); finish ();

Basic structure of AsyncTask Class

private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {     protected Long doInBackground(URL... urls) {         while (true) {             // Do some work             publishProgress((int) ((i / (float) count) * 100));         }        return result;     }     protected void onProgressUpdate(Integer... progress) {         setProgressPercent(progress[0]);     }     protected void onPostExecute(Long result) {         showDialog(“Result is “ + result);     } } To execute, new DownloadFilesTask (). execute ( url1 , url2 , url3 ); To read more about async task refer android developer guide.

Check whether an app on debug mode.

Here is a simple method to check whether an app is on debug mode or not. This will be useful to check to enable Strict Mode or to disable Strict Mode. public static boolean isDebugMode(Context context) {               PackageManager pm = context.getPackageManager(); try {              ApplicationInfo info = pm.getApplicationInfo p (context.getPackageName(), 0);               return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; } catch (NameNotFoundException e) { }              return true; } And to enable Strict Mode, StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectAll() .penaltyLog() .penaltyDialog() .build()); The above code will detect all types of network and disk I/O. Very helpful for debugging.

How can I make wordpress to show images in articles on homepage?

By default post images not shown on home page by some themes. Showing images on articles in home page can be achieved by two ways. 1. You need to edit index.php of your theme. Remember you must edit currently activated theme. It is currently configured to only show a post excerpt. If you don’t supply an optional custom excerpt, WordPress will create one automatically by stripping out all formatting, markup and images from the first 55 words of your post. Replace the_excerpt() with the_content(). You can easily find the_excerpt() by clicking CTRL + F and typing the_excerpt() , find it replace. And save by clicking the update button. 2. Write a custom excerpt in the Excerpt field, under the post edit box. It can be as short, or as long, as you wish and can include images.

There was a problem saving your changes. Please try again later.

There was a problem saving your changes. Please try again later. When I try to save settings of my facebook app. I got the above error. It occurred when I try to save Secure Canvas URL field. And then I used port number of 443 with my url. For example if my Secure Canvas URL is  https://dl.dropbox.com/u/38102629/index.html?  I added port number and my canvas url is  https://dl.dropbox.com :443 /u/38102629/index.html? And error went away.

Fatal: LoadModule: error loading module 'mod_sql_mysql.c'

I tried to install proftpd in webmin and I broke ftp in zpanel. I got following error message when I run proftpd command. root@Ubuntu12:~# proftpd Ubuntu12 proftpd[1400]: Fatal: LoadModule: error loading module 'mod_sql_mysql.c': Operation not permitted on line 38 of '/etc/zpanel/configs/proftpd/proftpd-mysql.conf' And I searched everywhere but I couldn't find anything. But following command make my error vanish .  apt-get install proftpd-mod-mysql If it asked what mode, choose 'stand-alone'. root@Ubuntu12:~# proftpd And it must be running.

Check whether model is loaded or not.

Following function will check whether model is loaded in codeigniter. Pass the model name as argument to the following function. function is_model_loaded ( $model ) { $ci =& get_instance (); $load_arr = ( array ) $ci -> load ; $mod_arr = array (); foreach ( $load_arr as $key => $value ) { if ( substr ( trim ( $key ), 2 , 50 ) == "_ci_models" ) $mod_arr = $value ; } //print_r($mod_arr);die; if ( in_array ( $model , $mod_arr )) return TRUE ; return FALSE ; }