Search This Blog

How to build Google Web Toolkit DevMode plugin for Firefox 17.0 on Mac OS X

  1. Install XCode if you do not have it. (XCode 3.2.6 is recommended for building this plugin, because the source code is configured to used Mac OS 10.5 sdk, which is included in XCode 3.2.6, but it is dropped by later version XCodes. However, the later version e.g. xcode 4.3, can also be used with a few modifications on the configuration.)
  2. Check out the source code:
        svn checkout http://google-web-toolkit.googlecode.com/svn/trunk/plugins gwt/plugins
        svn checkout http://google-web-toolkit.googlecode.com/svn/plugin-sdks/gecko-sdks/gecko-17.0.0 plugin-sdks/gecko-sdks/gecko-17.0.0
      
  3. If you have xcode 3.2.6 installed, you can try to build it:
    cd gwt/plugins/xpcom && make BROWSER=ff170
  4. If you have later xcode version, e.g. xcode 4.3, installed, the command above will fail with errors finding cstdio.h. To make it work, you need to
    1. modify plugins/config.mk,
      vi ../config.mk
      change
      BASECFLAGS= $(DEBUGCFLAGS) -O2 -fPIC $(INC) -D__mac -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk -std=c++11
      to
      BASECFLAGS= $(DEBUGCFLAGS) -O2 -fPIC $(INC) -D__mac -mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -std=c++11
    2. modify gwt/plugins/xpcom/Makefile,
      vi Makefile
      change
      DLLFLAGS += -bundle $(ALLARCHCFLAGS) -mmacosx-version-min=10.5  -isysroot /Developer/SDKs/MacOSX10.5.sdk
      to
      DLLFLAGS += -bundle $(ALLARCHCFLAGS) -mmacosx-version-min=10.7  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
  5. run
    make BROWSER=ff170
    (in gwt/plugins/xpcom directory.) to build.
  6. the result plugin file will be gwt/plugins/xpcom/prebuilt/wt-dev-plugin.xpi

Install XCode 3.2.6 on Mac OS X 10.7 Lion

I was trying to compile GWT DevMode Plugin for Firefox on Mac OS, found the source code is configured to use mac os 10.5 sdk, which is included in xcode 3.2.6 but dropped by the later versions of xcode. The follow steps are what I did to install xcode 3.2.6 on Mac OS X 10.7 Lion:
  1. Download XCode 3.2.6 from https://developer.apple.com/downloads. (You need to sign up and login.)
  2. Mount xcode_3.2.6_and_ios_sdk_4.3.dmg
  3. Open /Applications/Utilities/Terminal.app and run the following command:
    export COMMAND_LINE_INSTALL=1; open "/Volumes/Xcode and iOS SDK/Xcode and iOS SDK.mpkg"

GWT Developer's Plugin for Firefox 17

Update

The latest official google gwt devmode plugin for firefox has been updated to support Firefox 17. Upgrading to Firefox 17 should automatically update the gwt plugin as well.


See also

Ubuntu 12.04 Precise LTS: Install ModEvasive for Apache 2 web server

  1. sudo apt-get install libapache2-mod-evasive
  2. sudo mkdir /var/log/mod_evasive; sudo chown -R www-data:www-data /var/log/mod_evasive
  3. sudo vi /etc/apache2/mods-available/mod-evasive.conf
    <ifmodule mod_evasive20.c>
       DOSHashTableSize 3097
       DOSPageCount  2
       DOSSiteCount  50
       DOSPageInterval 1
       DOSSiteInterval  1
       DOSBlockingPeriod  10
       DOSLogDir   /var/log/mod_evasive
       DOSEmailNotify  EMAIL@DOMAIN.com
       DOSWhitelist   127.0.0.1
    </ifmodule>
  4. sudo a2enmod mod-evasive; sudo /etc/init.d/apache2 restart

Ubuntu 12.04 Precise LTS: Install ModSecurity for Apache 2 web server

  1. Install ModSecurity:
     sudo apt-get install libxml2 libxml2-dev libxml2-utils libaprutil1 libaprutil1-dev libapache-mod-security
    If your Ubuntu is 64bit, you need to fix a bug:
    sudo ln -s /usr/lib/x86_64-linux-gnu/libxml2.so.2 /usr/lib/libxml2.so.2
  2. Configure ModSecurity:
    sudo mv /etc/modsecurity/modsecurity.conf-recommended /etc/modsecurity/modsecurity.conf; sudo vi /etc/modsecurity/modsecurity.conf
        
    Enable the rule engine:
    SecRuleEngine On
    Increase the request body size limit to 10Mb(Optional, only if your site accepts uploads):
    SecRequestBodyLimit 10000000
    SecRequestBodyInMemoryLimit 10000000
  3. Check the ModSecurity version:
    dpkg -s libapache-mod-security | grep Version
    The installed ModSecurity version is:
    Version: 2.6.3-1ubuntu0.2
  4. Install OWASP ModSecurity Core Rule Set:
    1. Download the rule set(version 2.2.5 because the latest version requires ModSecurity 2.7.0+):
      wget https://github.com/SpiderLabs/owasp-modsecurity-crs/tarball/v2.2.5 -O /tmp/owasp.tar.gz
    2. Extract the package:
      cd /tmp; tar -zxvf owasp.tar.gz; rm owasp.tar.gz
    3. Copy the directory to /etc/modsecurity, and set the permissions:
      sudo mv SpiderLabs-owasp-modsecurity-crs-5c28b52/ /etc/modsecurity/owasp-crs
      sudo chmod -R 644 /etc/modsecurity/owasp-crs
    4. Link the rules to /etc/modsecruity/owasp-crs/activated_rules directory:
      sudo mv /etc/modsecurity/owasp-crs/modsecurity_crs_10_setup.conf.example /etc/modsecurity/owasp-crs/modsecurity_crs_10_setup.conf
      cd /etc/modsecurity/owasp-crs/activated_rules/
      sudo ln -s ../modsecurity_crs_10_setup.conf
      for f in $(ls ../base_rules/); do sudo ln -s ../base_rules/$f; done
      for f in $(ls ../optional_rules/); do sudo ln -s ../optional_rules/$f; done
    5. Modify /etc/apache2/mods-available/mod-security.conf to include the rules:
      sudo vi /etc/apache2/mods-available/mod-security.conf
      Add the following line:
      Include "/etc/modsecurity/owasp-crs/activated_rules/*.conf"
    6. Enable headers module:
      sudo a2enmod headers
      This to fix the following error:
      Syntax error on line 29 of /etc/apache2/conf.d/modsecurity/optional_rules/modsecurity_crs_49_header_tagging.conf:
      Invalid command 'RequestHeader', perhaps misspelled or defined by a module not included in the server configuration
      Action 'configtest' failed.
      The Apache error log may have more information.
         ...fail!
      when restarting apache2.
  5. Enable ModSecurity module and restart apache2:
    sudo a2enmod mod-security; sudo /etc/init.d/apache2 restart

See also

Mac OS: ssh tunnel issue 'bind: Cannot assign requested address'

I was trying to make a ssh tunnel using the following command:
ssh -L 127.0.0.1:8000:remotehost.mycompany.com:3128 wilson@gateway.mycompany.com -f -N
It gives an error: "bind: Cannot assign requested address"
Check the System Preferences -> Security & Privacy, found Firewall is On and in Firewall Options, Blocking all incoming connections was ticked. Deselect it and retry the ssh command, it works fine.

Mac OS: commands to find my computer's ip address

ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'

Get the pid of a command running background

sleep 100 &
echo $!
Note: $! holds the pid of the command.

Run SSH Tunnel in background

I. start the tunnel in background

To open a SSH tunnel (port forwarding) in background, the following options for ssh command will be used:
  • -L [bind_address:]port:host:hostport
    • Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.  This works by allocating a socket to listen to port on the local side, optionally bound to the specified bind_address.  Whenever a connection is made to this port, the connection is forwarded over the secure channel, and a connection is made to host port hostport from the remote machine.
  • -N
    • Do not execute a remote command.  This is useful for just forwarding ports (protocol version 2 only).
  • -f 
    • Requests ssh to go to background just before command execution.

Suppose I want to access the intranet site at work from home, and I have ssh access to the gateway host at work.

ssh -L 127.0.0.1:8000:intranet.mycompany.com:80 wilson@gateway.mycompany.com -f -N
The command above will start the tunnel (and the ssh process is running)in background.

II. kill the ssh process running in background

To kill the ssh process running in background, we can run ps aux to find the pid but that is not an elegant solution. ssh has -M -S and -O options to control the ssh process. It is ideal for this purpose.
  • -M 
    • Places the ssh client into "master" mode for connection sharing.
  • -S ctl_path 
    •  Specifies the location of a control socket for connection sharing, or the string ``none'' to disable connection sharing. Refer to the description of ControlPath and ControlMaster in ssh_config(5) for details.
  • -O ctl_cmd 
    • Control an active connection multiplexing master process. When the -O option is specified, the ctl_cmd argument is interpreted and passed to the master process. Valid commands are: ``check'' (check that the master process is running), ``forward'' (request forwardings without command execution) and ``exit'' (request the master to exit).

# starts the tunnel
ssh -L 127.0.0.1:8000:intranet.mycompany.com:80 -f -N -M -S ~/.ssh-tunnel.gateway.mycompany.com wilson@gateway.mycompany.com

# checks the ssh process (pid)
ssh -S ~/.ssh-tunnel.gateway.mycompany.com -O check wilson@gateway.mycompany.com

# exits the ssh process (stops the tunnel)
ssh -S ~/.ssh-tunnel.gateway.mycompany.com -O exit wilson@gateway.mycompany.com

III. A example shell script

The following shell script (Tested on Mac OS X) starts the ssh tunnel in background, then open the intranet web site, when the browser application is closed, it stops the ssh tunnel.
#!/bin/bash

GATEWAY_HOST=gateway.mycompany.com

GATEWAY_USER=wilson

REMOTE_HOST=172.23.33.10

REMOTE_PORT=80

LOCAL_HOST=$(ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}')

LOCAL_PORT=8000

SSH_CTRL_PATH=~/.ssh-tunnel-${GATEWAY_HOST}

ssh -L ${LOCAL_HOST}:${LOCAL_PORT}:${REMOTE_HOST}:${REMOTE_PORT} ${GATEWAY_USER}@${GATEWAY_HOST} -N -f -M -S ${SSH_CTRL_PATH}

open -W http://${LOCAL_HOST}:${LOCAL_PORT}/

ssh -S ${SSH_CTRL_PATH} -O exit ${GATEWAY_USER}@${GATEWAY_HOST}

See also

Java: convert between List and Array

I. List to Array

List<String> list = new ArrayList<String>(Arrays.asList(new String[]{"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus"})); 
// NOTE: the following line can be 
// String[] array = list.toArray(new String[0]);
String[] array = list.toArray(new String[list.size()]);

II.Array to List

String[] array = new String[]{"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus"};
List<String> list = Arrays.asList(array);

III. A complete example

package arc;

import java.util.Arrays;
import java.util.List;

public class Test {

 public static void main(String[] args) {
  String[] array = new String[] { "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus" };
  for (String a : array) {
   System.out.println(a);
  }
  
  List<String> list = toList(array);
  System.out.println(list);
  
  array = toArray(list);
  for (String a : array) {
   System.out.println(a);
  }
 }

 public static String[] toArray(List<String> list) {
  return list.toArray(new String[0]);
 }

 public static List<String> toList(String[] array) {
  return Arrays.asList(array);
 }

}

NOTE

list.toArray(new String[0]) is ok because the method will create a new array with the actual size of the list and returns it.

Java: get disk usage of a file or directory

  • Option 1:
    import java.io.File;
    
    public class FileUtil {
    
     public static long getDiskUsage(File f) {
      if (f.isFile()) {
       return f.length();
      } else {
       int total = 0;
       File[] fs = f.listFiles();
       if (fs != null) {
        for (int i = 0; i < fs.length; i++) {
         total += getDiskUsage(fs[i]);
        }
       }
       return total;
      }
    
     }
    
     public static void main(String[] args) {
      System.out.println(getDiskUsage(new File("/tmp/1.png")));
     }
    }
    
  • Option 2:
    import java.io.File;
    import java.io.FileFilter;
    
    public class DiskUsage implements FileFilter {
    
     private long _size = 0;
    
     public DiskUsage() {
    
     }
    
     @Override
     public boolean accept(File file) {
      if (file.isFile()) {
       _size += file.length();
      } else {
       file.listFiles(this);
      }
      return false;
     }
    
     public long getSize() {
      return _size;
     }
    
     public static void main(String[] args) {
      DiskUsage du = new DiskUsage();
      du.accept(new File("/tmp/1.png"));
      System.out.println(du.getSize());
     }
    }
    

Stock Android SIP client set up

Native SIP clients available on some 2.3/4.0 phones. To enable it:

  1. Settings -> Internet call settings
  2. Click Accounts, then click "Add account" button
    • User Name: 888XXXXXXX (Your VOIP account number given by you VOIP service provider)
    • Password: XXXXX (Your VOIP password)
    • Server: sip.pennytel.com (Your VSP's sip server)
    • Tick set as primary account
Now you should be able to make calls through your VOIP if WIFI is enabled. (VOIP via 3G is disabled.)

Mac OS: How to use Java 6 after installed Oracle Java 7

Append the following command to your ~/.bashrc file (if you are using bash:
export JAVA_HOME=`/usr/libexec/java_home -v 1.6`

See also

Re-enable Apple's Java 6 applet plugin after applying Apple's Java Mac OS X 2012-006 Update

  1. Open Terminal, located in the Utilities folder.Enter this command, then press the Return or Enter key:
    sudo mkdir -p /Library/Internet\ Plug-Ins/disabled
  2. Enter this command, then press the Return or Enter key:
    sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled
  3. Enter this command, then press the Return or Enter key:
    sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
  4. To re-enable Java SE 6 Web Start, enter this command, then press the Return or Enter key:
    sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws

To disable Java SE 6 Web Start opening

Enter this command, then press the Return or Enter key:
sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javaws /usr/bin/javaws
When prompted, enter your administrator password, then press the Return or Enter key.

To re-enable the Java 7 applet plug-in

Download and re-install the Oracle Java 7 JRE from this website: http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1637588.html.

Eclipse on Mac OS: Use specific Java VM instead of the platform default version

After apply Apple's Java Mac OS X 2012-006 Update, it remove java plugin for browsers therefore the java applet and webstart applications no longer work. I downloaded Java 7 from Oracle. However, I wants my Eclipse use Java 6: To specify the Java VM for eclipse, you can edit the file: /Applications/eclipse/Eclipse.app/Contents/Info.plist

<key>Eclipse</key>
    <array>
         <string>-vm</string><string>/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/java</string>
    ... ... ... ... ...
    </array>

Melbourne Home Visiting Doctors

http://www.mmds.com.au/home-visiting-doctor

When can I request a home visiting doctor?
Weekdays: From 4.00 pm to 8.00 am the next day (overnight)
Weekends: From 10.00 am Saturday until 8.00 am Monday
Public holidays: 24 hours
Please ring your own GP during surgery hours.
If your own GP is available after hours, we will contact him/her for you.
Booking a home visit is easy, either
1. Simply download our free mobile app, enter the patients details and submit the request. Save yourself the cost of a mobile call and possibly waiting on hold. One of our trained, friendly operators will call back quickly to confirm the request, or
2. Phone (03) 9429 5677. Your call will be triaged by our operator and request the following patient details:
  • Full name, date of birth and address for the doctor to attend
  • The patients regular GP. Please provide the clinics name and phone number. At the end of the consultation, a clinical record will be sent to your GP.

Special HTML codes for math symbols

Display Friendly Code Numerical Code Hex Code Description
&#8722; &#x2212; Minus Sign
+ + &#43; &#x2B; Plus Sign
± &plusmn; &#177; &#xB1; Plus or Minus Sign
× &times; &#215; &#xD7; Multiplication Sign
÷ &divide; &#247; &#xF7; Division Sign
% % &#37; &#x25; Percent Sign
&#137; &#x2030; Per Mille Sign (per thousand)
= = &#61; &#x3D; Equal Sign
&#8800; &#x2260; Not Equal To Sign
&#8776; &#x2248; Approximately Equal Sign
&#8801; &#x2261; Identical To Sign
< &lt; &#60; &#x3C; Less Than Sign
> &gt; &#62; &#x3E; Greater Than Sign
&#8804; &#x2264; Less Than or Equal To Sign
&#8805; &#x2265; Greater Than or Equal To Sign
&#8734; &#x221E; Infinity Sign
&#8539; &#x215B; One Eighth Fraction
¼ &frac14; &#188; &#xBC; One Quarter Fraction
&#8540; &#x215C; Three Eighths Fraction
½ &frac12; &#189; &#xBD; One Half Fraction
&#8541; &#x215D; Five Eighths Fraction
¾ &frac34; &#190; &#xBE; Three Quarters Fraction
&#8542; &#x215E; Seven Eighths Fraction
&#8747; &#x222B; Integral Sign
&#8706; &#x2202; Partial Differential Sign
&#8710; &#x2206; Increment Sign
&#8719; &#x220F; N-ary Product Sign
&#8721; &#x2211; N-ary Sum Sign
&#8730; &#x221A; Square Root Sign
&#8735; &#x221F; Right Angle Sign
&#8745; &#x2229; Intersection Sign
&#8729; &#x2219; Bullet Operator
ƒ &#131; &#x83; Function Sign
&#8260; &#x2044; Fraction Slash

六年级小学生王乐乐的感人情书

当我在5.12只想拉着你手跑的时候,我就晓得,我这辈子当不了英雄的哈。

因为我不像那个啥子小英雄林浩那样,在那么害怕的时候还能想着别人,而我,只晓得往外头跑,只拉了你。

你就要去北京了,成都比起北京来说,太小了,楼没得那么高,车没得那么多,人没得那么挤,但感情也没得那么深。

你走了,我没什么好送给你,河边也捡不到像心一样的石头,我没得网银,所以上不了淘宝去买,表姐一天就晓得打游戏,这个忙都不帮我。

你成了我最熟悉的 四川话说的最好的北京人了,至少你屋头的户口本上是这样的,至少你考试的分数线是这样。你就像凤凰一样飞了撒,我很难受,一个暑假都好难受,没精打采的。付胖子经常装着不认识我,指着我对别人说“那个人好奇怪耶,看起来好像一条狗。”

你走了,有些事情不会变的撒,我还是得去读书,去吃东西,我还是会去广福桥吃冒菜,还是得去读书,去吃东西。我还是会点两个人吃的量,虽然有点多,但总有一天会吃完,因为会习惯没有你,因为我会长大。

你走了,我也会变,我会练字,我就是我自己的手机毒霸,管好我自己,少做傻事情的哈。其实聪明人也可以很听话的,至少在没有长大以前。

问你能不能不跟到你爸爸切北京啊,“我不切,一个人在成都你养我”,“我养你啊”,哎,想到就心酸,等着吧。

好了,我不写了。你要好好的,要切煮饭了。成都天气也凉了,北京也一样吧。多穿衣服,多喝热水好了。我们就到这。

以后再遇到起:

好久不见。
你好吗?
我很好!



The life cycle of software development


http://www.projectcartoon.com/