Skip to content

Instantly share code, notes, and snippets.

View sharmaabhinav's full-sized avatar
😀
Working

ABHINAV SHARMA sharmaabhinav

😀
Working
  • Bangalore
View GitHub Profile
function bind (fn, context, params) {
return function callable () {
fn.apply(context, [...params, ...arguments])
}
}
/*
function foo (a,b,c) {
Array.prototype.dup = function (n) {
var arr = []
for(var i=1;i<=n;i++) {
arr = arr.concat(this)
}
return arr
}
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;
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()
function skipLeadingZeros (string) {
var str = ''
var start = 0
var end = string.length
while(start < end && string[start] === '0'){
start ++
}
while(start < end){
@sharmaabhinav
sharmaabhinav / race.rb
Created October 7, 2015 05:18
Solution to a hacker earth problem
# 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(" ")
var greet = function(callback) {
var todaysGreeting = "Hello, ";
callback(todaysGreeting);
}
var Greeter = function(name) {
this.name = name;
this.sa;
this.sal = function(sa){
/*************** FormValidatorMixin ******************/
var FormValidationMixin = {
regex: function(type){
var regex = ""
var type = type.toUpperCase()
switch(type){
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