Skip to content

Instantly share code, notes, and snippets.

View aruld's full-sized avatar
🎯
Focusing

Arul Dhesiaseelan aruld

🎯
Focusing
View GitHub Profile
@aruld
aruld / foobar.dart
Created October 19, 2011 18:26
My first Dart script
class foobar {
foo() {
return '00';
}
bar() {
return 7;
}
}
main() {
@aruld
aruld / typecheck.dart
Created October 19, 2011 18:27
Type checking sample
main() {
var lst = new List<num>(2);
lst[0] = 2;
lst[1] = 'two';
for (var e in lst) {
print(e);
}
}
@aruld
aruld / foreachmap.dart
Created October 19, 2011 18:29
Dart forEach() on a Map
main() {
Map<String, int> map = {
'one': 1,
'two': 2,
'twelve': 12};
void iterateMapEntry(key, value) {
map[key] = value;
print('$key:$value');//string interpolation in action
}
@aruld
aruld / foreachlistset.dart
Created October 19, 2011 18:30
Dart forEach() on a List/Set
main() {
List<String> list = new List<String>();
list.add('one');
list.add('two');
list.add('twelve');
list.forEach((element) => print(element));
Set<String> set = Set.from(list);
set.forEach((element) => print(element));
}
@aruld
aruld / foreachearlyexit.dart
Created October 19, 2011 18:32
Dart forEach() early exit
main() {
var aMap = const {'a':4,'b':5,'c':6,'d':7};
aMap.getKeys().some((var key) {
print('$key');
if (key == 'b') {
return true; // early exit
}
});
print('See?, no "c" nor "d"');
}
@aruld
aruld / Version.java
Created October 21, 2011 04:24
Version.java.template
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
@aruld
aruld / Version.java
Created October 21, 2011 05:10
Version.java.template
//Line # 68-75 https://gist.github.com/1303091
/**
* In case you were wondering this method is called by java -version.
* Sad that it prints to stderr; would be nicer if default printed on
* stdout.
*/
public static void print() {
print(System.err);
}
@aruld
aruld / gist:1904116
Created February 24, 2012 22:10
Jersey 2.0 JSON Pojo Mapper sample
import org.glassfish.jersey.media.json.JsonJacksonModule;
import org.glassfish.jersey.server.Application;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.TestProperties;
import org.glassfish.jersey.test.spi.TestContainer;
import org.junit.Test;
import javax.ws.rs.core.MediaType;
@aruld
aruld / InvokeWebServiceTrigger.java
Created April 17, 2012 19:46
Invoking Flux Web Service Trigger using Jersey Java API
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import com.sun.jersey.api.client.filter.LoggingFilter;
import com.sun.jersey.multipart.FormDataBodyPart;
import com.sun.jersey.multipart.FormDataMultiPart;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
@aruld
aruld / ScheduleFluxWorkflow.java
Created April 17, 2012 20:14
Scheduling Flux workflow using Jersey Java API
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import com.sun.jersey.api.client.filter.LoggingFilter;
import com.sun.jersey.multipart.FormDataBodyPart;
import com.sun.jersey.multipart.FormDataMultiPart;
import com.sun.jersey.multipart.file.FileDataBodyPart;
import javax.ws.rs.core.MediaType;