This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bind (fn, context, params) { | |
return function callable () { | |
fn.apply(context, [...params, ...arguments]) | |
} | |
} | |
/* | |
function foo (a,b,c) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.dup = function (n) { | |
var arr = [] | |
for(var i=1;i<=n;i++) { | |
arr = arr.concat(this) | |
} | |
return arr | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function showCountDown () { | |
var nextdate = new Date(2017, 9, 24, 10) | |
var curDate = new Date() | |
var seconds, minutes, hours | |
seconds = Math.floor((nextdate - curDate) / 1000) | |
minutes = Math.floor(seconds / 60 ) | |
seconds = seconds % 60 | |
hours = Math.floor(minutes/60) | |
minutes = minutes % 60; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const compose = (...fns) => (arg) => fns.reduce((composed, f) => f(composed), arg) | |
const oneSecond = () => 1000 | |
const getCurrentTime = () => new Date() | |
const clear = () => { console.clear() } | |
const log = (message) => { console.log(message) } | |
const serializeClockTime = date => ({ | |
hours: date.getHours(), | |
minutes: date.getMinutes(), | |
seconds: date.getSeconds() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function skipLeadingZeros (string) { | |
var str = '' | |
var start = 0 | |
var end = string.length | |
while(start < end && string[start] === '0'){ | |
start ++ | |
} | |
while(start < end){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Logic : first create list of all players and then remove loosers from that. Using a hash it can be done in O(n) time. | |
no_of_inputs = 2 ** gets.chomp.to_i - 1 | |
player_list = Hash.new | |
inputs = []; | |
1.upto(no_of_inputs) do | |
player1,player2 = gets.split(" ") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var greet = function(callback) { | |
var todaysGreeting = "Hello, "; | |
callback(todaysGreeting); | |
} | |
var Greeter = function(name) { | |
this.name = name; | |
this.sa; | |
this.sal = function(sa){ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*************** FormValidatorMixin ******************/ | |
var FormValidationMixin = { | |
regex: function(type){ | |
var regex = "" | |
var type = type.toUpperCase() | |
switch(type){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SetPasswordForm = React.createClass({ | |
mixins: [FormValidationMixin], | |
getInitialState: function(){ | |
return { password: '' , confirm_password: '', errors: [] } | |
}, | |
submitForm: function(e){ | |
var password = this.state.password | |
var confirm_password = this.state.confirm_password |