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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / gist:5306276
Created April 3, 2013 23:04
Knowledge sharing: [play-framework] Play! application using UTC - how to do it and how not to do i
THE CONTENT OF THIS GIST COMES FROM https://groups.google.com/forum/?fromgroups=#!topic/play-framework/Er46pB5t_OU
I would like to share my conclusions on how to set up a Play! application using MySQL to use UTC.
The idea is to have all date/time information stored in UTC and to only translate such information to specific timezones when displaying it to users (who have their own timezone settings).
This should be achieved regardless of the underlying operating system timezone, therefore allowing for deployment everywhere.
Date/time information items that should be in UTC include:
public class LoggingSecurityManager extends SecurityManager {
private AccessControlContext ctx;
private Properties properties = new Properties;
private Set missingProperties = new HashSet();
public LoggingSecurityManager() {
properties.add(
new FilePermission(System.get("java.io.tmpdir") + "/-", "read,write,delete"));
// maybe...
@greenlaw110
greenlaw110 / JavaBean.java
Created May 29, 2013 06:08
Rythm Dynamic Expression Evaluation
public class JavaBean {
private String id;
private int count;
private boolean enabled;
private Map<String, Object> attrs;
public JavaBean(String id, int count, boolean enabled) {
this.id = id;
this.count = count;
this.enabled = enabled;
attrs = new HashMap<String, Object>();