Skip to content

Instantly share code, notes, and snippets.

if (typeof Object.create !== 'function') {
Object.create = function (o) {
function F() {}
F.prototype = o;
return new F();
};
}
newObject = Object.create(oldObject);
// deeper into the pie
var pie_stuff = pie.items;
var pie_sectors = pie_stuff[1];
var sector1 = pie_sectors[0];
// within some DOM element, I attached .hover() and added,
sector1.animate({scale: [1, 1, this.cx, this.cy]}, 500, "bounce").attr({"fill": off_color});
// consider this simple function
var calc_total = function(a,b,c) {
return (this + a + b + c);
}
calc_total.call(1,2,3,4,5); // result is 10. 1 is treated as this, and 2,3,4 as a,b,c. 5 is ignored.
var calc_total2 = function(a,b,c) {
return (this + a + b + c);
var koolcharts = {};
// maybe you have a buncha functions
koolcharts.fn = {};
// let's add a draw function
koolcharts.fn.draw = function() {
alert("I'm too young to draw");
};
<!DOCTYPE html>
<html>
<head>
<title>Dojo - Hello World!</title>
<link href="dojo1.5/dojo/resources/dojo.css">
<script src="dojo1.5/dojo/dojo.js" type="text/javascript"></script>
</head>
<body>
<div id="hello">Hello Dojo!</div>
// A simple generic server for local testing
// point to local node libraries folder
require.paths.push('/usr/local/lib/node/');
var static = require('node-static');
var myfolder = 'dojo'; // change this if needed
var port = 8123; // change this if needed
<!DOCTYPE html>
<html>
<head>
<title>Dojo - Namespaces!</title>
<link href="dojo1.5/dojo/resources/dojo.css">
<script src="dojo1.5/dojo/dojo.js" type="text/javascript"></script>
</head>
<body>
<div id="hello">Hello Dojo!</div>
dojo.provide("kenny.calculator");
kenny.calculator.sum = function(x,y) {
return x+y;
}
server: http://localhost:9123
load:
- myproject/js/external/jquery-1.3.2.js
- myproject/js/internal/myapp.js
- jstd/myapp/*.js
public class SumTwo
{
public static void main(String[] args)
{
int a = 4;
int b = 5;
int result = a + b;
System.out.println(result);