Skip to content

Instantly share code, notes, and snippets.

View aruld's full-sized avatar
🎯
Focusing

Arul Dhesiaseelan aruld

🎯
Focusing
View GitHub Profile
View SakilaResource.java
@Path("/sakila")
public class SakilaResource {
@Context
private SearchContext searchContext;
List<Actor> actors = new ArrayList<Actor>();
List<Film> films = new ArrayList<Film>();
List<Rental> rentals = new ArrayList<Rental>();
View SakilaSearchTest.java
public class SakilaSearchTest {
static Server server;
@BeforeClass
public static void setUp() {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(SakilaResource.class);
sf.getInInterceptors().add(new LoggingInInterceptor());
sf.getOutInterceptors().add(new LoggingOutInterceptor());
View GoingParallelInJava
package oscon.java.parallel;
import extra166y.Ops;
import extra166y.ParallelArray;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class GoingParallelInJava {
@aruld
aruld / SCPActionTest
Created August 12, 2011 05:18
SCPAction example
View SCPActionTest
Factory factory = Factory.makeInstance();
EngineHelper helper = factory.makeEngineHelper();
FlowChart flowChart = helper.makeFlowChart("SCP Action Example");
SCPActionFactory scpActionFactory = (SCPActionFactory) flowChart.makeFactory("SCPActionFactory");
SCPAction downloadFile = scpActionFactory.makeSCPAction("SCP Download");
downloadFile.setHost("arul-ubuntu");
downloadFile.setUsername(System.getProperty("user.name"));
downloadFile.setDownload(true);
downloadFile.setRemotePath("Downloads/jdk-1_5_0_22-linux-i586.bin");
downloadFile.setLocalPath("/tmp/");
@aruld
aruld / functiontest.dart
Created October 19, 2011 17:19
Dart Functions
View functiontest.dart
class FunctionTest {
FunctionTest(this.myFunc);
Function myFunc;
num run(num n) {
return myFunc(n);
}
}
main() {
var square = (aNumber) => aNumber * aNumber;
var result = new FunctionTest(square).run(5);
@aruld
aruld / printer.dart
Created October 19, 2011 17:22
Dart noSuchMethod construct
View printer.dart
class Printer {
Printer(this.address);
noSuchMethod(String name, List args) {
print("not implemented.");
}
var address;
}
main() {
var p = new Printer("10.0.0.5:1234");
@aruld
aruld / multiline.dart
Created October 19, 2011 17:26
Dart String interpolation and multi-line Strings
View multiline.dart
main() {
var user = 'John Doe';
var message = """
$user!
Welcome to Programming Dart!
""";
print(message);
}
@aruld
aruld / reification.dart
Created October 19, 2011 17:27
Dart Reified Generics
View reification.dart
main() {
print(new List<String>() is <Object>();//true
print(new List<Object>() is List<String>);//false
print(new List<String>() is List<int>);//false
print(new List<String>() is List);//true
print(new Map() is Map<String,String>);//true
}
@aruld
aruld / complex.dart
Created October 19, 2011 17:30
Dart operator overloading complex types
View complex.dart
class Complex {
Complex(this.re, this.im);
double re, im;
operator +(Complex other) {
return new Complex(re + other.re, im + other.im);
}
void Display( ) {
print('$re,$im');
}
}
@aruld
aruld / defaults.dart
Created October 19, 2011 17:31
Dart optional defaults
View defaults.dart
main() {
test(var a, [b = 54]) {
print(b);
}
test(10);
}