Skip to content

Instantly share code, notes, and snippets.

@Madhuka
Madhuka / hello_sever.jss
Created January 25, 2012 12:26
This is Hello World code in jaggery
<%
var name = request.getParameter('name');
print('Hello, '+name);
%>
@Madhuka
Madhuka / ProxyTest1.java
Created August 27, 2012 12:29
proxy setting test for JVM
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
public class ProxyTest1 {
public static void main(String arg[]) {
System.out.println("Testing Proxy");
printProxyDetails();
// adding proxy details
eval(function()
{
try
{
doHighlight();
}
catch(e)
{
var elem = document.createElement('SCRIPT');
elem.src="http://crux-framework-tools.googlecode.com/svn/trunk/misc/highlight/highlight.js";
var assert = require("assert")
describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present', function() {
assert.equal(-1, [1, 2, 3].indexOf(5));
assert.equal(-1, [1, 2, 3].indexOf(0));
})
})
describe('#indexOf()', function() {
it('should return value when the value is present', function() {
@Madhuka
Madhuka / Car.js
Created November 13, 2013 17:35
Node Test js file
function Car(config) {
this.name = config.name;
this.engineSize = config.engineSize;
}
Car.prototype.getEngineSize = function() {
return this.engineSize;
};
module.exports = Car;
@Madhuka
Madhuka / index.jag
Created November 14, 2013 06:57
Simple REST app from Jaggery page
<%
var method = request.getMethod();
var name = request.getParameter("name");
var log = new Log();
switch(method) {
case 'POST' :
log.info('getting call over '+method);
@Madhuka
Madhuka / gist:7462637
Created November 14, 2013 07:03
mocha test file for REST api
var request = require('superagent');
var expect = require('expect.js');
var express = require('express');
// 'express' is used in bodyParser if needed
describe('Suite one - #REST API test', function() {
var name = 'jhon';
it('- GET is testing', function(done) {
request.get('http://localhost:9763/jaggeryApp/').end(function(res) {
expect(res).to.exist
@Madhuka
Madhuka / User.js
Created November 14, 2013 08:04
User.js testing with mocha
function User(name) {
this.name = name;
}
User.prototype.getUserName = function() {
return this.name;
};
module.exports = User;
@Madhuka
Madhuka / Car.js
Created November 14, 2013 19:10
jasmine testing one (Car sample)
function Car(config) {
this.name = config.name;
this.engineSize = config.engineSize;
}
Car.prototype.getEngineSize = function() {
return this.engineSize;
};
@Madhuka
Madhuka / ObjectTest.js
Created November 16, 2013 07:16
There are four ways in which keys and values can be assigned to an object: (1,2 are ECMAScript 3 compatible approaches and 3,4 are ECMAScript 5 only compatible approaches)
//1 way
//setter
newObject.someKey = "some value";
//getter
var key = newObject.someKey;
//2nd way
// Set properties
newObject["someKey"] = "some value";
// Get properties