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 / SortIntArray.java
Last active August 29, 2015 14:04
Sort array by number symbol, negative should all go left and positive should all go right
import java.util.Arrays;
/**
* Created by luog on 22/07/2014.
*/
public class SortIntArray {
private static int[] ia;
private static void initArray(String[] args) {
if (args.length > 0) {
@greenlaw110
greenlaw110 / Output
Created June 4, 2014 03:40
YieldExample output
T:\java>java YieldExample
I am Consumer : Consumed Item 0
I am Producer : Produced Item 0
I am Consumer : Consumed Item 1
I am Producer : Produced Item 1
I am Consumer : Consumed Item 2
I am Producer : Produced Item 2
I am Producer : Produced Item 3
I am Consumer : Consumed Item 3
I am Consumer : Consumed Item 4
@greenlaw110
greenlaw110 / layout.html
Created April 13, 2014 10:13
layout template with @inherited()
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>title</title>
<meta charset="UTF-8">
import com.pixolut.mrb.mas.tool.*;
import com.pixolut.mrb.mas.models.*;
import com.pixolut.mrb.mas.controllers.*;
import java.util.*;
import org.rythmengine.template.TemplateBase;
import java.io.*;
public class errors_prod_error_html__R_T_C__ extends org.rythmengine.template.TagBase {
@Override public java.lang.String __getName() {
@greenlaw110
greenlaw110 / Benchmark.java
Created October 27, 2013 10:28
arraylist-vs-linkedlist-vs-gaplist-vs-fasttable, the benchmark program extended from the one coming from http://www.programcreek.com/2013/03/arraylist-vs-linkedlist-vs-vector/
import java.util.*;
import java.util.regex.*;
import java.lang.reflect.*;
import java.text.*;
import java.net.*;
import java.io.*;
import javax.script.*;
import java.math.*;
import org.magicwerk.brownies.collections.*;
import javolution.util.*;
@greenlaw110
greenlaw110 / MappingSample.java
Created June 17, 2013 03:08
Functional programming with Java-Tool
package com.greenlaw110.sample;
import com.greenlaw110.util.C;
import com.greenlaw110.util.IO;
import com.greenlaw110.util._;
import java.util.List;
public class MappingSample {
public static void main(String[] args) {
import java.util.*;
import org.rythmengine.template.TemplateBase;
import java.io.*;
public class gh148_main_html__R_T_C__ extends org.rythmengine.template.TagBase {
@Override public java.lang.String __getName() {
return "gh148_main_html__R_T_C__";
}
@greenlaw110
greenlaw110 / evalWithFel.java
Last active December 17, 2015 21:19
rythm dynamic expression evaluation
private Map<String, com.greenpineyu.fel.Expression> fels = new HashMap<String, Expression>();
private FelEngine fel = new FelEngineImpl();
private Expression getFel(String expr, Map<String, Object> context) {
StringBuilder sb = new StringBuilder(expr);
for (Object s : context.keySet()) {
Object o = context.get(s);
sb.append("|").append(s).append(":");
if (null == o) sb.append("null");
else sb.append(o.getClass());
@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>();
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...