Skip to content

Instantly share code, notes, and snippets.

@vinodkd
vinodkd / about.md
Created August 10, 2011 05:04 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@vinodkd
vinodkd / RewardPoints.java
Created September 17, 2011 18:38
Proc to reward points
/**
* If applicable, deducts the rewards amount from the current price,
* rewards points on the booking and returns the charge amount for the user's card.
*/
public CCAmt doRewards(String pos, CCAmt currentCCAmt,
rewardsInfo rewardsInfo,
String PNR,
XFactor xFactor,
boolean isSpecialInventory,
Money sellRateForSpecialInventory
@vinodkd
vinodkd / gist:1319651
Created October 27, 2011 14:14
BNF-ish version of Jack's Syntax with some notes
stmt can have id, comment and fact attached
function can have same, but is a collection of stmts
program can have same, but is a collection of functions
built into the language def is a list creator
also built in is a hierarchical fact analyzer, ie, all facts
presented at a collection level are taken to represent reality
at that level. higher levels areexpected to have a "higher" understanding and therefore not applicable; similarly lower
list-of(XXX) := <list containing objects of type XXX>
@vinodkd
vinodkd / JackParser.ometa
Created October 27, 2011 14:23
Basic Jack Parser in OMeta
ometa JackParser {
id = string,
comment = string,
fact = string,
name = string,
operator = name,
arg = name | expr,
header = [id:id comment:comment fact:fact] -> { id:id, comment:comment, fact:fact},
@vinodkd
vinodkd / jack1.yaml
Created October 27, 2011 14:43
Yaml version of Jack AST
// yaml version of the same
- object: function
id:
comment:
fact: 'multiplies(x,y)'
name: multipliesTwo
expr:
- object: expr
id:
comment:
@vinodkd
vinodkd / gist:2017661
Created March 11, 2012 18:52
MaxProd
public static int maxProd(int[] input){
int max1 = max2 = max3 = java.lang.Integer.MIN_VALUE;
int min1 = min2 java.lang.Integer.MAX_VALUE;
for(int i=0; i<input.length;i++){
// recalc the new max3 numbers
int val= input[i];
if(val > max1){
max2 = max1; // dont lose the old max1
max1=val;
@vinodkd
vinodkd / gist:2017685
Created March 11, 2012 19:00
MaxProd.jak
public static int maxProd(int[] input){
int max1 = max2 = max3 = java.lang.Integer.MIN_VALUE;
int min1 = min2 java.lang.Integer.MAX_VALUE;
for(int i=0; i<input.length;i++){
int val= input[i];
range calcmax{
if(val > max1){
max2 = max1; // dont lose the old max1
@vinodkd
vinodkd / sqr_orig.groovy
Created March 1, 2013 06:29
groovy dsl original
Object.metaClass.of = { delegate[0](delegate[1](it))}
Object.metaClass.the = { clos -> [delegate[0], clos]}
show = [ {println it} ]
square_root = { Math.sqrt(it) }
please = {it}
please show the square_root of 100
//try1
println please.class.name
println please.delegate
println show
println show.class.name
println show.delegate
println please(show).delegate
println please(show).the(square_root)
please(show).the(square_root).of(100)
={it}([{println it}]).{clos -> [delegate[0],clos]}(square_root).{delegate[0](delegate[1](it))}(100)
=[{println it}].[delagate[0], square_root].[delegate[0](delegate[1](100))]
= [{println it}, square_root].[delegate[0](delegate[1](100))]
=println(square_root(100))