Search This Blog

How to download official ROM updates for your LG mobile phone

  1. Find your LG mobile phone's Model and Serial Number. e.g. My phone model is P690F and its S/N is 123ABCD123456(it is labeled under battery).
  2. Type the following address in your web browser's url field:
    http://csmg.lgmobile.com:9002/svc/popup/model_check.jsp?model=[model]&esn=[serial_number]
    replace the [model] and [serial_number] with your LG phone's model and serial number.
  3. Type return to load the page. It should returns a string. You need to view the page source:
    • On Firefox: Tools -> Web Developer -> Page Source (Ctrl+U or Command+U)
    • On Safari: Right click blank area in the page, select View Source in the context menu
    • On IE: View -> Source
  4. Find the number inside <ESN></ESN> tag
  5. Type the following address in your web browser's url field:
    http://csmg.lgmobile.com:9002/csmg/b2c/client/auth_model_check2.jsp?esn=[esn_number]
    substitute the [esn_number] with the ESN number we get from last step.
  6. Load the page (it is a blank page in web browser), you need to view page source, you can then see the ROM update url inside <sw_url></sw_url> tag.

See also

海外在线看CCTV-5

wasu.cn

Mac OS X: share your internet connection wirelessly

There is no WIFI available in my office. The internet connection of my Mac is via Ethernet. I want to share my internet connection to my android phone so that it can download apps. The following instructions shows how I share the (Ethernet) internet connection of my Mac to my mobile phone via wireless/WIFI.
  1. Open System Preferences and select Sharing
  2. Select Internet Sharing, set "Share your connection from Ethernet", "To computers using Wi-Fi", then click Wi-Fi Options... button
  3. In the Wi-Fi options window, set the Network Name, Security and Password, then click OK button:

  4. Tick Internet Sharing, in the confirm window click Start button:
  5. Now the WiFi hotspot is running, you should see the green light and Internet Sharing: On

Trouble shooting

  • The client computer/mobile phone will fail to connect to the WIFI network (fail to request IP address from the network) if the your Mac has Firewall turned on and it is configured to blocking all incoming connections (It will of course block the DHCP requests from the WIFI clients). To Resolve it, you need to untick the Block all incoming connections option:
    1. Open System Preferences then Security & Privacy


    2. click Firewall Options... button:

    3. Untick Block all incoming connections

Android: Save your apk files from Google Play Store

  • Method 1: Use SaveAPK + OI File Manager
    1. Install OI File Explorer from Google Play Store
    2. Install SaveAPK from Google Play Store
    3. Run SaveAPK and select the application(apk) you want to save, then select the directory to store the apk (on SD card)
  • Method 2: Use Astro File Manager
    1. Install Astro File Manager from Google Play Store
    2. Start Astro File Manager then select Application Backup, backup the applications and the apk files will be store in backups/ directory on SD card.

Android: WIFI Proxy without root

On some Android 2.3.X phones(e.g. my Acer Liquid Metal S120, WIFI proxy settings are missed in WIFI settings. The work around are below:
  • Use Opera Browser
    • Install from Google Play, or if you dont have internet connection you can download the apk from http://ftp.opera.com/pub/opera/android/mobile/1200/ on another computer, transfer to your phone and installed it
    • Open the Opera browser app, in the URL field, type opera:config, at this time the Preferences Editor should have opened in your screen.
    • Scroll down to proxy menu, in the HTTP Server and HTTPS Server, enter your proxy setting with the following format <Proxy IP>:<Port>. E.g. 192.168.1.1:3128
  • Install "HTTP proxy settings" app in Google play. (It may not work on some phones.)

Use google code prettify in blogger

  1. Login to blogger, "Template" -> "Edit HTML" -> "Proceed
  2. Copy the following code, and paste them right before </head>  in the template html:
    <link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript" src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></script>
    <script type="text/javascript" language="javascript" src="http://google-code-prettify.googlecode.com/svn/trunk/src/lang-css.js"></script>
    
  3. Replace <body> with <body onload="prettyPrint()">
  4. Now you can format your code use prettify, for example:
    <code class="prettyprint lang-js">
    <!-- your code here-->
    </code>
    

    or
    <pre class="prettyprint lang-js">
    <!-- your code here-->
    </pre>
    

SEE ALSO:

Upgrade Ubuntu 10.04 server to 12.04 LTS

According to Ubuntu 12.04 release notes, "It is generally recommended that users of Ubuntu 10.04 LTS wait until the first point release, due in July, before upgrading."

If you do want to wait until the 12.04.1 is released in July 2012, follow the following steps:
  1. Ensure you're up to date with latest updates for Ubuntu 10.04:
    sudo apt-get update
    sudo apt-get upgrade
    
  2. Install update-manager-core if it is not already installed:
    sudo apt-get install update-manager-core
    
  3. Edit /etc/update-manager/release-upgrades and set Prompt=lts:
    [DEFAULT]
    Prompt=lts
    
  4. Launch the upgrade tool, and follow the on-screen instructions:
    sudo do-release-upgrade -d
    

NOTE:

At the end of the upgrade process you will be required to restart the server in order to boot into the new kernel. If you do not have access to the console of the system you are upgrading, you may need to edit /boot/grub/menu.lst and change the default boot kernel to the newly installed 12.04 kernel. If this step is not performed your server may attempt to boot into the 10.04 LTS kernel and will hang.

Ubuntu 12.04 (Gnome 3): enable system proxy in terminal

  • To enable the proxy:
    gsettings set org.gnome.system.proxy.socks host 'proxy.yourcompany.com'
    gsettings set org.gnome.system.proxy.socks port 3128
    gsettings set org.gnome.system.proxy mode 'manual'
    
  • To disable the proxy:
    gsettings set org.gnome.system.proxy mode 'none'
    


See also

Linux: Extract archive files in various formats

File ExtensionRequired UtilityCommand to extractCommand to install the required utility
.tartartar -xvf file.tarsudo apt-get install tar
.tar.gz
.tgz
tar gunziptar -zxvf file.tar.gz
tar -zxvf file.tgz
sudo apt-get install tar gzip
.tar.bz2
.tbz2
tar bunzip2tar -jxvf file.tar.bz2
tar -jxvf file.tbz2
sudo apt-get install tar bzip2
.tar.xztar unxztar -Jxvf file.tar.xzsudo apt-get install tar xz-utils
.rarunrarunrar -x file.rarsudo apt-get install unrar
.zipunzipunzip file.zipsudo apt-get install unzip
.gzgunzipgunzip file.gzsudo apt-get install gzip
.bz2bunzip2bunzip2 file.bz2sudo apt-get install bzip2
.Zuncompressuncompress file.Zsudo apt-get install gzip
.7z7z7z -x file.7zsudo apt-get install p7zip

Add digg button into blogger post

  1. Login to blogger dashboard
  2. Select "Template" then click "Edit HTML"
  3. Click "Proceed"
  4. Tick "Expand Widget Templates"
  5. Search for "<data:post.body/>", replace it with the following code:
    <p>
    <!-- DIGG -->
    <div style='float:right; margin-left:10px;'>
    <script type='text/javascript'>
    digg_url = '<data:post.url/>';
    </script>
    <script src='http://digg.com/tools/diggthis.js' type='text/javascript'/>
    </div>
    <data:post.body/>
    </p>
    

SEE ALSO:

Free VOIP softphone supports G729 codec for windows

add ADSENSE to blogger post by modifying the template


  1. Login to your adsense account, create the AD unit and copy the code
  2. Convert the code into safe HTML code (paste the code below and click convert):
  3. Login to blogger, select the blog you want to edit, select "Template", then click the "Edit HTML" button:
  4. Click "Proceed":

  5. Tick "Expand Widget Templates":
  6. Ctrl + F (or Command + F on Mac OS X) to search for
    <data:post.body/>
    
  7. Right above that line, paste below code:
    <b:if cond="data:blog.pageType == &quot;item&quot;">
    <div style='float: left; padding: 0px 8px 8px 0px;'>
    
     CONVERTED ADSENSE CODE FROM STEP 2
    
    </div>
    </b:if>
    <data:post.body/>
    
  8. Save the template.

SEE ALSO:

Javascript: convert HTML special characters

HTML special characters

  • & (ampersand) becomes &amp
  • " (double quote) becomes &quot when ENT_NOQUOTES is not set.
  • ' (single quote) becomes '&#039 only when ENT_QUOTES is set.
  • < (less than) becomes &lt
  • > (greater than) becomes &gt
  • # (hash) becomes &#035


Javascript function to convert HTML special characters

function converHtml(s) {
  var e = document.createElement("div");
  e.innerText = e.textContent = s;
  return e.innerHTML.replace(/"/g, "&quot;").replace(/#/,'&#035').replace(/'/,'&#039');
}

See also

Convert HTML code to safe string by converting the special characters


Input:



Output:

Shell script: for loop through file names with spaces

  • Use find:
    find . -print0 | while read -d $'\0' f
    do
      cat "$f"
    done
    
  • Use IFS:
    #!/bin/bash
    IFS_BAKCUP=$IFS
    
    IFS=$(echo -en "\n\b")
    
    # $1 is the directory contains the files
    for f in $(ls $1)
    do
      echo "$f"
    done
    
    IFS=$IFS_BACKUP
    
  • Use Array:

See also

Extract .xz file on Ubuntu Linux

  • Install xz-utils:
    sudo apt-get install xz-utils
    
  • Extract .xz file:
    unxz file.xz
    
  • Extract .tar.xz file:
    tar -Jxvf file.tar.xz
    

See also

Compile and install wget on Mac OS X

  1. Make sure you have Xcode installed
  2. Download the wget source code: http://ftp.gnu.org/pub/gnu/wget/wget-1.12.tar.gz
  3. Compile and install:
    tar xzvf wget-1.12.tar.gz
    cd wget-1.12
    ./configure
    make
    sudo make install
    

Note:

I tried only version wget-1.12. The later version of the source code may not be so easy to compile.

git: share repository with a group

  • When init the repository, you can:
    git init --shared=group
    
  • On an existing repository, you can:
    git config core.sharedRepository group
    



See also

Java: execute a command in a separate process










See also

git: check a particular user's commits



git log --author=wilson


See also




A bite of China 舌尖上的中国 [5] 厨房的秘密



A bite of China
A documentary about fine food in China.



A bite of China 舌尖上的中国 [4] 时间的味道



A bite of China
A documentary about fine food in China.



Telstra LG Optimus Spirit P690F V10F Chinese ROM

  • Official Web Page
  • Purchase unlock code from ebay
  • How to flash V10F_00.kdz ROM(China Chinese/English)
    1. You need a Windows PC (Windows XP sp3 or Windows 7 32/64 bit)
    2. Download the V10F_00.kdz ROM(China Chinese/English)
    3. Download and install Windows USB driver
    4. Download and install Software Update utility
    5. Download and extract KDZ_FW_UPD_EN.7z
    6. Configure your phone: Settings -> Applications -> Development, Tick USB Debugging
    7. Connect your phone to the Windows PC using USB cable and wait until all the drivers are installed automatically
    8. Connect the phone but DO NOT turn on USB storage
    9. Run KDZ_FW_UPD.exe as Administrator
    10. Set Type: 3GQCT           Phone Mode: DIAG
    11. Select the V10F_00.kdz file
    12. Press Lauch Software Update to start and wait (for 6~10 minutes) until you see --FINISHED-- line. (In the meantime, your phone gets into Emergency mode.)
    13. The phone should reboot itself. For me, it failed to reboot, it hangs in the LG splash logo then reboots again infinitely. To fix it, turn off the phone and then press and hold the Power + Volume Down + Home buttons. Wait till you see the droid with the progress bar under it then release the buttons.

LG P690 Official ROM updates (.kdz)

See also

A bite of China 舌尖上的中国 [3] 转化的灵感



A bite of China
A documentary about fine food in China.



A bite of China 舌尖上的中国 [2] 主食的故事



A bite of China
A documentary about fine food in China.



A bite of China 舌尖上的中国 [1] 自然的馈赠

A bite of China

A documentary about fine food in China.

Java: Map allows multiple values


 public class Key {  
 }  
 public class Value {  
 }  
 public class MapExample {  
 private Map<Key, List<Value>> _map;  
  public MapExample {  
   _map = new HashMap<Key, List<Value>>();  
  }  
  public void addValue(Key key, Value value) {  
   List<Value> vs = _map.get(key);  
   if(vs==null){  
     vs = new ArrayList<Value>();  
     vs.add(value);  
     _map.put(key,vs);  
     return;  
   }  
   vs.add(value);  
  }  
  public List<Value> getValues(Key key) {  
   return _map.get(key);  
  }  
 }  

Java: How to count the number of ocurrences of an element in a Collection

Java 6 Collections has a static method: frequency(Collection<?> c, Object o):
int numOccurs = Collections.frequency(list, elem);



git statistics

  • Command 1:
    git log --pretty=format:%ae | gawk -- '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }'
    
  • Command 2:
    git log --pretty=format:%an | awk '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }' | sort -r
    
  • Command 3:
    git shortlog -sne
    
  • gitstats is script to generate full statistical html pages with charts. You can install it on Ubuntu Linux using the following command:
    sudo apt-get install gitstats
    To generate stats for a git repository:
    gitstats /path/to/repo.git /dst/
    



Create self-extractable archive installer on Linux/Unix

The solution is simple to explain: The self-extractable file are joint from an extractor shell script and an tar archive, which contains the actual contents to be extracted and installed into the system. The extractor script is a text file while the archive file is binary. They are joint together using cat to make the self-extractable archive. Thus, the self-extractable archive file should have the following parts:
  • Script part: The extractor shell script, extract.sh:
    #!/bin/bash
    
    #
    # the extractor script
    # 
    
    # create a temporary directory
    TMP_DIR=$(mktemp -d InstXXXXXX)
    
    
    # extract the archive
    ARCHIVE=`awk '/^__ARCHIVE_BEGIN__/ {print NR + 1; exit 0; }' $0`
    tail -n+$ARCHIVE $0 | tar xzvf -C $TMP_DIR
    
    ## Alternatively you can use sed
    #sed -e '1,/^__ARCHIVE_BEGIN__$/d' "$0" | tar xzvf -C $TMP_DIR
    
    CUR_DIR=$(pwd)
    
    # execute install.sh
    cd $TMP_DIR; $TMP_DIR/install.sh
    
    cd $CUR_DIR
    
    rm -rf $TMP_DIR
    
    exit 0
    
    __ARCHIVE_BEGIN__
    
  • Archive Part: The tar.gz archive contains the contents to install. Inside the archive, there should be an installer script, which is executed when extractor script has extracted the archive into a temporary directory. Therefore, the archive should contains below:
    • the installer script: install.sh:
      #!/bin/bash
      
      #
      # The installer script (example only, you should modify to adapt your needs.)
      # 
      
      CUR_DIR=$(pwd)
      SRC_DIR=$(cd $(dirname $0);pwd)
      DST_DIR=/usr/local/example
      
      sudo mkdir -p $DST_DIR
      cp -pr ./* $DST_DIR/
      
    • the actual content files
Also, we use a builder script: build.sh to create the self-extractable archive file.

  1. To start, we need to prepare thhe directory structure like below:
    ./archive
    ./archive/bin
    ./archive/doc
    ./archive/install.sh
    ./archive/lib
    ./build.sh
    ./extract.sh
    
    The archive directory is the directory contains the install.sh and the actual content files to install. The extract.sh file is extractor script.
  2. The build.sh script:
    #!/bin/bash
    
    #
    # The builder script
    #
    
    cd archive
    tar pczvf ../arc.tar.gz ./*
    cd ..
    cat extract.sh arc.tar.gz > install.bin
    rm arc.tar.gz
    chmod +x install.bin
    
  3. The final self-extractable installer: install.bin

See Also




Eclipse: org.apache.batik.dom.svg is missing

When installing eUML2, it complains about:
requires 'bundle org.apache.batik.dom.svg 1.6.0' but it could not be found
To solve the problem, you need to install GMF plugins.


ls: list only directories

  • Method 1:
    ls -d */
  • Method 2:
    ls -l | grep '^d'
  • Method 3:
    find . -type d -maxdepth 1 -mindepth 1



Casey Hayes

Detect OS in Java

public class Test {

    public static void main(String[] args) {
        System.out.println(System.getProperty("os.name"));
    }

}



Access private field via reflection in Java

public class A {

    private int i = 5;

}

public class B {

    public static void main(String[] args) {
        A a = new A();
        Field iField = a.getClass().getDeclaredField("i");
        iField.setAccessible(true);
        return iField.getInt(a);
    }

}



Suspend/Resume a process by sending SIGSTOP/SIGCONT signals

  • To suspend the process:
    kill -SIGSTOP 123
    
  • To resume the process:
    kill -SIGCONT 123
    

Note:

On some systems, you may need to use following commands:

  • To suspend the process:
    kill -STOP 123
    
  • To resume the process:
    kill -CONT 123
    
  • To list the available signals:
    kill -l
    



ps returns only the state code of a process

ps -o state -p <pid>



Linux/Unix process state codes

PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers
(header "STAT" or "S") will display to describe the state of a process.
D    Uninterruptible sleep (usually IO)
R    Running or runnable (on run queue)
S    Interruptible sleep (waiting for an event to complete)
T    Stopped, either by a job control signal or because it is being traced.
W    paging (not valid since the 2.6.xx kernel)
X    dead (should never be seen)
Z    Defunct ("zombie") process, terminated but not reaped by its parent.

For BSD formats and when the stat keyword is used, additional characters may
be displayed:
<    high-priority (not nice to other users)
N    low-priority (nice to other users)
L    has pages locked into memory (for real-time and custom IO)
s    is a session leader
l    is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+    is in the foreground process group



git shortlog on bare repository

git shortlog command on a bare repository hangs. You have to specify --bare option:
git --bare shortlog



tar preserve permissions

  • Create archive preserving permissions:
    tar pczvf arc.tar.gz arc/
    
  • Extract archive preserving permission:
    tar pxzvf arc.tar.gz
    



git: push rejected, non-fast-forward

Solution: 



Eclipse Egit: push git tags

  1. Right click the project root, Select Team -> Remote -> Push...
  2. Click Next> button
  3. Click Add All Tags Spec button, then click Finish button

See also




Ubuntu: script works in terminal fails in cron

Solution:
  • initialize the environment variables by sourcing /etc/bash.bashrc before executing your script.
    0 0 * * * source /etc/bash.bashrc; /path/to/yourscript.sh