Skip to content

Instantly share code, notes, and snippets.

View npras's full-sized avatar
😃
Coding all the time

Prasanna Natarajan npras

😃
Coding all the time
View GitHub Profile
@npras
npras / af2_original_submission.rb
Last active March 10, 2017 14:10
AF - Codility: Task2
def solution(a)
total = a.size
lindex = a.size-1
sorted = a.sort
min = total
combos = []
return 0 if a == sorted
(2..total).each do |pair_size|
@npras
npras / bindMethod.js
Last active February 22, 2017 12:54
Gist explaining method binding to outer scope
let myLib = (function(){
this.libName = 'in lib';
let obj = {
libName: 'in obj',
toCaps() {
return this.libName.toUpperCase();
}
};
@npras
npras / watcher.js
Created February 20, 2017 13:35
VueJS - Implementing Computed Property - Part Two
class Watcher {
constructor(vm, valueFn) {
this.vm = vm;
this.getter = valueFn;
this.value = this.get();
}
get() {
let value;
@npras
npras / vuejs-source.js
Created February 20, 2017 12:54
VueJS - Implementing Computed Property - Part One
const Watcher = require('./watcher');
const noop = function () {};
const sharedPropDef = {
enumerable: true,
configurable: true,
get: noop,
set: noop
};
@npras
npras / vue_experiment1.js
Created January 13, 2017 13:36
Reproduce Vue's data object proxy behaviour
// https://vuejs.org/v2/guide/instance.html
//
//
//function Vue(opts){
//for(var key in opts.data){
//this[key] = opts.data[key]
//}
//}
function Vue(opts){
this._data = opts.data;
class XMLBuilder
def initialize
@d = {}
end
def to_xml
@d
end
@npras
npras / js_fn_def_and_calling.js
Created March 17, 2016 07:47
javascript function definition and calling syntax
// this is function definition.
// you can make a function take zero or more arguments (also called as parameters)
// This Dog fn takes one argument: 'name'
function Dog(name){
return "hello, my name is: " + name;
}
// calling the Dog function
Dog('tommy'); // this will return "hello, my name is: tommy"