Skip to content

Instantly share code, notes, and snippets.

View dhilipsiva's full-sized avatar
🏠
Working from home

dhilipsiva dhilipsiva

🏠
Working from home
View GitHub Profile
@dhilipsiva
dhilipsiva / findPath.coffee
Last active August 29, 2015 14:27
Find path of a value in an object
findPath = (obj, query) ->
for k, v of obj
if typeof v is "object"
path = findPath v, query
return "#{k}.#{path}" if path
else if v is query
return k

Keybase proof

I hereby claim:

  • I am dhilipsiva on github.
  • I am dhilipsiva (https://keybase.io/dhilipsiva) on keybase.
  • I have a public key whose fingerprint is C089 E27F 91EB D68B 75F2 4144 2581 43B7 AA6E 4C40

To claim this, I am signing this object:

1. 2541865828329
2. 3541568428327
3. 2341999999914
@dhilipsiva
dhilipsiva / GoogleCloudStorageUtil.py
Created December 9, 2014 08:54
A Google Cloud Storage utility - To upload a file, get a file and get a signed URL to post from browser.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2014 dhilipsiva <dhilipsiva@gmail.com>
#
# Distributed under terms of the MIT license.
"""
Requirements:
from itertools import product
nums = [1, 3, 5, 7, 9, 11, 13, 15]
expected_num = 30
nums_to_add = 5
for combination in product(nums, repeat=nums_to_add):
print combination, " = ", sum(combination)
@dhilipsiva
dhilipsiva / smoothScrollTo.coffee
Last active August 29, 2015 14:04
A smooth scroll to script
window.smoothScrollTo = (target_id, duration=1000) ->
step = ->
factor = (Date.now() - start) / duration # get interpolation factor
if factor >= 1
clearInterval timer # stop animation
factor = 1 # clip to max 1.0
y = factor * delta + offset
window.scrollBy 0, y - window.pageYOffset
target = document.getElementById(target_id).offsetTop
offset = window.pageYOffset
@dhilipsiva
dhilipsiva / unicoins-auto-miner.js
Last active August 29, 2015 13:57
StackOverflow Unicoins Auto Miner
/*
github.com/dhilipsiva
A Simple JavaScript file to AUTO-MINE StackOverflow unicoins:
INSTRCTIONS:
0. goto stackoverflow.com
1. Open your console.
2. Copy this code.
3. Paste this into cosole
@dhilipsiva
dhilipsiva / variable-scope.js
Created January 17, 2014 10:21
I could not access the required variable in the block as shown. I don't understand why.
define("appkit/controllers/me", ["appkit/utils/uploader", "exports"],
function (__dependency1__, __exports__) {
"use strict";
var Uploader = __dependency1__["default"];
var MeController;
MeController = Em.ObjectController.extend({
username: null,
actions: {
uploadProfilePic: function ($el) {
/*
@dhilipsiva
dhilipsiva / binet-fibonacci.js
Created December 4, 2013 06:57
Binet's Fibonacci
/*
* fibbonacci.js
* Copyright (C) 2013 dhilipsiva <dhilipsiva@gmail.com>
*
* Distributed under terms of the MIT license.
*/
function isDigit(val) {
/*
* Find if given value is a digit or not.
#!/bin/sh
# Dropbox setup on a headless Ubuntu Server
# Script written by Jesse B. Hannah (http://jbhannah.net) <jesse@jbhannah.net>
# Based on http://wiki.dropbox.com/TipsAndTricks/UbuntuServerInstall
###
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell