Skip to content

Instantly share code, notes, and snippets.

Sri srirangan

Block or report user

Report or block srirangan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am srirangan on github.
  • I am sri19 (https://keybase.io/sri19) on keybase.
  • I have a public key ASBA4jE2007AhvAb7If04gJsZ3sVz9HhSv6_y36GgBx1Bgo

To claim this, I am signing this object:

View gist:41b1ee6556321ea2e706
evina.on("some-event", function (context) {
console.log("some event happened")
});
evina.trigger("some-event", {hello: "world"});
evina.off("some-event");
View gist:f7e05ed1f14d5e7249a2
<script src="evina.min.js"></script>
@srirangan
srirangan / gist:1519452
Created Dec 25, 2011
Functional Programming in JavaScript - 9
View gist:1519452
<div id="redBox1" class="redBox"></div>
<div id="redBox2" class="redBox"></div>
<div id="redBox3" class="redBox"></div>
<div id="greenBox1" class="greenBox"></div>
<div id="greenBox2" class="greenBox"></div>
<div id="greenBox3" class="greenBox"></div>
<script>
(function () {
@srirangan
srirangan / gist:1519451
Created Dec 25, 2011
Functional Programming in JavaScript - 8
View gist:1519451
const CIRCLE = "circle";
const SQUARE = "square";
const RECTANGLE = "rectangle";
var getAreaFunction = function (shape) {
return function () {
switch (shape) {
case CIRCLE:
return Math.PI * arguments[0] * arguments[0];
break;
@srirangan
srirangan / gist:1519450
Created Dec 25, 2011
Functional Programming in JavaScript - 7
View gist:1519450
const CIRCLE = "circle";
const SQUARE = "square";
const RECTANGLE = "rectangle";
var getAreaFunction = function (shape) {
return function () {
switch (shape) {
case CIRCLE:
return Math.PI * arguments[0] * arguments[0];
break;
@srirangan
srirangan / gist:1519449
Created Dec 25, 2011
Functional Programming in JavaScript - 6
View gist:1519449
var forEach = function (list, action) {
for (var i = 0; i < list.length; i++) {
action(list[i]);
}
};
var reduce = function (combine, base, list) {
forEach(list, function (item) {
base = combine(base, item);
});
@srirangan
srirangan / gist:1519448
Created Dec 25, 2011
Functional Programming in JavaScript - 5
View gist:1519448
var forEach = function (list, action) {
for (var i = 0; i < list.length; i++) {
action(list[i]);
}
};
var map = function (mappingFunction, list) {
var result = [];
forEach(list, function (item) {
result.push(mappingFunction(item));
@srirangan
srirangan / gist:1519447
Created Dec 25, 2011
Functional Programming in JavaScript - 4
View gist:1519447
var forEach = function (list, action) {
for (var i = 0; i < list.length; i++) {
action(list[i]);
}
};
var logItem = function (item) {
console.log(item);
};
@srirangan
srirangan / gist:1519445
Created Dec 25, 2011
Functional Programming in JavaScript - 3
View gist:1519445
(function (name) {
console.log(name + " functions can be auto-executed on definition")
})("Anonymous");
console.log("JavaScript provides functional scoping instead of block scoping");
(function () {
if (true) {
var x = true;
console.log("Is 'x' available inside the block? " + x);
}
You can’t perform that action at this time.