Skip to content

Instantly share code, notes, and snippets.

View greenlaw110's full-sized avatar
🏠
Working from home

Gelin Luo greenlaw110

🏠
Working from home
  • @AWS/Redshift/CP
  • Sydney Australia
View GitHub Profile
@greenlaw110
greenlaw110 / x.text
Created February 22, 2013 20:40
Yalp framework builder system survey elaboration
1. Reuse existing playframework 1.x building system
pros:
- smooth migration to existing play1.x users
- zero effort because of reusing
cons:
- big distribution package (even contains a python implementation on windows)
- (potential) legal issue as a fairly big number of jars are packaged inside
- needs to maintain python libraries
@greenlaw110
greenlaw110 / templates_stocks_rythm_html__R_T_C__.java
Created February 12, 2013 21:13
A rythm generated java source file from a template source with only static content
import java.util.*;
import java.io.*;
public class templates_stocks_rythm_html__R_T_C__ extends com.greenlaw110.rythm.template.TagBase {
@Override public java.lang.String getName() {
return "templates_stocks_rythm_html__R_T_C__";
}
@greenlaw110
greenlaw110 / example1.html
Created February 5, 2013 03:11
Rythm tag for fieldset
@fieldSet("Dimension") {
<a class="btn icon dim" data-type="max" data-dim="width" title="all to max width"><img src="/img/nui/editor/icons/dim-max-width.png"></a>
<a class="btn icon dim" data-type="avg" data-dim="width" title="all to average width"><img src="/img/nui/editor/icons/dim-ave-width.png"></a>
<a class="btn icon dim" data-type="min" data-dim="width" title="all to min width"><img src="/img/nui/editor/icons/dim-min-width.png"></a>
<a class="btn icon dim" data-type="max" data-dim="height" title="all to max height"><img src="/img/nui/editor/icons/dim-max-height.png"></a>
<a class="btn icon dim" data-type="avg" data-dim="height" title="all to average height"><img src="/img/nui/editor/icons/dim-ave-height.png"></a>
<a class="btn icon dim" data-type="min" data-dim="height" title="all to min height"><img src="/img/nui/editor/icons/dim-min-height.png"></a>
}
@greenlaw110
greenlaw110 / controlGroup.html
Last active December 12, 2015 04:08
A Rythm tag to generate bootstrap control-group. Example:
@import com.greenlaw110.utils.S
@args {
String field
String label
boolean showErrorMsg
Object value
boolean select = false
boolean text = true
boolean textarea
boolean password
@greenlaw110
greenlaw110 / User.java
Created November 14, 2012 20:30
13afd686c53625d5
import com.google.code.morphia.annotations.Id;
import org.bson.types.ObjectId;
@Entity
public class User extends Model {
//@Id
//ObjectId id = new ObjectId();
@greenlaw110
greenlaw110 / x.java
Created October 16, 2012 03:19
Rythm play enhancement bridge
engine.registerTemplateClassEnhancer(new ITemplateClassEnhancer() {
@Override
public byte[] enhance(String className, byte[] classBytes) throws Exception {
ApplicationClasses.ApplicationClass applicationClass = new ApplicationClasses.ApplicationClass();
applicationClass.javaByteCode = classBytes;
applicationClass.enhancedByteCode = classBytes;
File f = File.createTempFile("rythm_", className.contains("$") ? "$1" : "" + ".java", Play.tmpDir);
applicationClass.javaFile = VirtualFile.open(f);
try {
new TemplatePropertiesEnhancer().enhanceThisClass(applicationClass);
@greenlaw110
greenlaw110 / debug.1
Created July 9, 2012 07:58
linux log
Jan 27 17:46:18 vmx9382 kernel: [ 0.000000] e820 update range: 0000000000000000 - 0000000000001000 (usable) ==> (reserved)
Jan 27 17:46:18 vmx9382 kernel: [ 0.000000] e820 remove range: 00000000000a0000 - 0000000000100000 (usable)
Jan 27 17:46:18 vmx9382 kernel: [ 0.000000] MTRR default type: write-back
Jan 27 17:46:18 vmx9382 kernel: [ 0.000000] MTRR fixed ranges enabled:
Jan 27 17:46:18 vmx9382 kernel: [ 0.000000] 00000-9FFFF write-back
Jan 27 17:46:18 vmx9382 kernel: [ 0.000000] A0000-BFFFF write-combining
Jan 27 17:46:18 vmx9382 kernel: [ 0.000000] C0000-FFFFF write-back
Jan 27 17:46:18 vmx9382 kernel: [ 0.000000] MTRR variable ranges enabled:
Jan 27 17:46:18 vmx9382 kernel: [ 0.000000] 0 base 00F0000000 mask FFF8000000 uncachable
Jan 27 17:46:18 vmx9382 kernel: [ 0.000000] 1 base 00F8000000 mask FFFC000000 uncachable
@greenlaw110
greenlaw110 / Error message and Stack overflow
Created July 5, 2012 01:54
Morphia Customer decode method not called
play.exceptions.JavaExecutionException: java.lang.RuntimeException: java.lang.ClassCastException: java.lang.String cannot be cast to com.mongodb.DBObject
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:237)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException: java.lang.String cannot be cast to com.mongodb.DBObject
at com.google.code.morphia.mapping.Mapper.fromDb(Mapper.java:487)
at com.google.code.morphia.mapping.Mapper.fromDBObject(Mapper.java:267)
at com.google.code.morphia.query.MorphiaIterator.convertItem(MorphiaIterator.java:66)
at com.google.code.morphia.query.MorphiaIterator.processItem(MorphiaIterator.java:53)
at com.google.code.morphia.query.MorphiaIterator.next(MorphiaIterator.java:48)
at com.google.code.morphia.query.QueryImpl.get(QueryImpl.java:365)
@greenlaw110
greenlaw110 / index.java
Last active October 6, 2015 15:28
Define method in Rythm template
@extends(main)
@if (isMobile()) {
@layout.mobile()
} else {
@layout.desktop()
}
@greenlaw110
greenlaw110 / rl.g
Created June 25, 2012 20:28
a problem antlr file
grammar RL;
report
: REPORT ('(' REPORT_NAME ')')? BEGIN END
;
REPORT : 'Report';
BEGIN : 'Begin';
END : 'End';
NAME : LETTER (LETTER | DIGIT | '_')*;