brite, a MVC Framework for jQuery

Maven: Copy the jar dependencies in a folder

June 3rd, 2011 by jeremychone | No Comments »
	  <!-- Clean & Copy .jar file to /bin/lib -->
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.4</version>
        <executions>
          <execution>
          	<phase>package</phase>
            <configuration>
              <tasks>
                <delete dir="bin/lib">
                </delete>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>	  

      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <outputDirectory>bin/lib</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- /Clean & Copy  .jar file to /bin/lib -->

Javascript: sort an array of json object by a property

May 30th, 2011 by jeremychone | No Comments »
// a is the array to be sorted
function(a,propName){
		return a.sort(sortByFunc);
		function sortByFunc(a, b) {
			if (typeof a === "undefined") return -1;
			if (typeof b === "undefined") return 1;

		    var x = a[propName];
		    var y = b[propName];
		    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
		}
}

iOS: WebKit Mobile Safari prevent bouncing/scrolling on touch move

May 28th, 2011 by jeremychone | No Comments »
$(function(){
   // WARNING: This seems to remove the 2 fingers scrolling on iOS WebKit
   $(document).bind("touchmove",function(event){
	event.preventDefault();
   });
});

Native application in HTML for iOS WebKit

postgresql: Set the default schema name (like using or use)

May 21st, 2011 by jeremychone | No Comments »
SET search_path TO myschema;

Java: C3P0 Maven (and hibernate c3p0 maven) and quick start

May 21st, 2011 by jeremychone | No Comments »
<dependency>
    <groupId>c3p0</groupId>
    <artifactId>c3p0</artifactId>
    <version>0.9.1.2</version>
</dependency>
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass( "org.postgresql.Driver" ); //loads the jdbc driver
cpds.setJdbcUrl( "jdbc:postgresql://localhost/testdb" );
cpds.setUser("swaldman");
cpds.setPassword("test-password");                                  

// the settings below are optional -- c3p0 can work with defaults
cpds.setMinPoolSize(5);
cpds.setAcquireIncrement(5);
cpds.setMaxPoolSize(20);

// The DataSource cpds is now a fully configured and usable pooled DataSource

...

Cleaning up on app shutdown

DataSources.destroy( cpds );

c3p0 Doc

For Hibernate, the maven dist is

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-c3p0</artifactId>
  <version>3.5.1-Final</version>
</dependency>

Java: slf4j log factory initialization

May 21st, 2011 by jeremychone | No Comments »
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger logger = LoggerFactory.getLogger(AnyClass.class);

HTML5: iOS like spinning wheel in HTML5/CSS3

May 20th, 2011 by jeremychone | No Comments »

iOS Spinning Wheel in HTML5/CSS
http://cubiq.org/spinning-wheel-on-webkit-for-iphone-ipod-touch

Phonegap: Install / Uninstall Notes / Instructions for Mac

May 15th, 2011 by jeremychone | No Comments »
This installer will only install items under your home folder (signified by ~)

Items that will be installed:
(1) Xcode global var in ~/Library/Preferences/com.apple.Xcode.plist (which will be listed under Xcode Preferences -> Source Trees)
(2) PhoneGap Xcode static library and static framework project under ~/Documents/PhoneGapLib
(3) Xcode 3 project template in ~/Library/Developer/Xcode/Project Templates/PhoneGap
(4) Xcode 4 project template in ~/Library/Application Support/Developer/Shared/Xcode/Templates/Project Templates/Application
(5) PhoneGap Xcode static framework under /Users/Shared/PhoneGap/Frameworks/PhoneGap.framework (may change in future updates)
(6) Symlink to the framework in (5) under ~/Library/Frameworks

To uninstall:
(1) Remove the PHONEGAPLIB value in Xcode Preferences -> Source Trees
(2) Delete the ~/Documents/PhoneGapLib folder
(3) Delete the ~/Library/Application Support/Developer/Shared/Xcode/Project Templates/PhoneGap folder
(4) Delete the "~/Library/Application Support/Developer/Shared/Xcode/Templates/Project Templates/Application/PhoneGap-based Application.xctemplate" folder
(5) Delete the /Users/Shared/PhoneGap/Frameworks/PhoneGap.framework folder
(6) Delete the ~/Library/Frameworks/PhoneGap.framework symlink

If creating a new app does not copy the www folder, it can be found here (on Mac)

/Users/Shared/PhoneGap/Frameworks/PhoneGap.framework

See Also

PhoneGap for iOS xCode4 with No Template Tutorial

PhoneGap iOS xCode4 Template version

Install Phonegap Plugins (i.e. ChildBrowser)

PhoneGap Plugins Compiles error, no file, solution

Linux: Resize (extend) a Logical Disk in a Xen from DOM0

May 14th, 2011 by jeremychone | 2 Comments »

Assuming you have set your xen VM (e.g. domu1) points to a logical volume.

from DOM0

Extending the domu1 logical volume to 40G

lvextend -L40G /dev/vg0/domu1

from domu1

Resize the Physical Disk

pvresize /dev/hda

Resize the desired LV

lvextend -L15G /dev/vg0u/store
// might want to unmount the volume first, but this works on ext3 on live disk
resize2fs /dev/vg0u/store

See also

LVM Guide

JavaScript: arguments to Array

April 28th, 2011 by jeremychone | No Comments »

The arguments variable is not a true array, so, to convert it to an array to pass them to another method, here it is.

function hello() {
    var args = Array.prototype.slice.call(arguments);
    myOtherFunction.apply(this,args);

}