Skip to content

Instantly share code, notes, and snippets.

View Manoj85's full-sized avatar
🎯
Focusing

Manoj Talagadadeevi Manoj85

🎯
Focusing
View GitHub Profile
# Example JRuby program to display the JVM's available locales
# and their number, currency, and date formats.
#
# Keith R. Bennett, @keithrbennett
require 'java'
java_import 'java.util.Locale'
java_import 'java.text.DateFormat'
java_import 'java.text.NumberFormat'
#!/bin/bash
# Note: this is ONLY a fix for https://github.com/npm/npm/issues/4719
# If you are having some OTHER issue, then DO NOT USE THIS SCRIPT.
# It won't help, and might cause other problems.
# You have been warned.
# Just to prove that you're not blindly copying and pasting, please
# remove these two lines before running:

build

Clone and build Node for analysis:

$ git clone https://github.com/joyent/node.git
$ cd node
$ export GYP_DEFINES="v8_enable_disassembler=1 v8_object_print=1"
$ ./configure
$ make -j4
// It is important to declare your variables.
(function() {
var foo = 'Hello, world!';
print(foo); //=> Hello, world!
})();
// Because if you don't, the become global variables.
(function() {

Real-World Functional Programming

May 28, 2014

This code is a companion to the APIcon presentation Real-World Functional Programming by @jearldouglas and @kelleyrobinson. The slides are available here.

In this code, we compare imperative and functional implementations of a withdraw function that might be used in a banking ATM.

Imperative transactions

var arr = [0,1,2,3,4,5,6,7,8,9];
/**
* Returns a circular range of an Array
* @param index {Number} starting position
* @param size {Number} size of the range
* @param [position] {Number} position of the range, negative values will return a range before the index
* @return {Array}
**/
Array.prototype.range = function(index, size, position){
@Manoj85
Manoj85 / FizzBuzz.js
Last active August 29, 2015 14:26 — forked from jaysonrowe/FizzBuzz.js
FizzBuzz JavaScript solution
for (var i=1; i <= 20; i++)
{
if (i % 15 == 0)
console.log("FizzBuzz");
else if (i % 3 == 0)
console.log("Fizz");
else if (i % 5 == 0)
console.log("Buzz");
else
console.log(i);