Skip to content

Instantly share code, notes, and snippets.

View Avinash-Bhat's full-sized avatar

Avinash Ananth Narayan R Avinash-Bhat

View GitHub Profile
@Avinash-Bhat
Avinash-Bhat / custom_rules.xml
Last active April 18, 2016 13:37
[DEPRECATED] Automatic versioning in Android using Ant and Git
<?xml version="1.0" encoding="UTF-8"?>
<project name="application-custom">
<macrodef name="git" taskname="@{taskname}">
<attribute name="command" />
<attribute name="dir" default="" />
<attribute name="property" default="" />
<attribute name="taskname" default="" />
<attribute name="failonerror" default="on" />
<element name="args" optional="true" />
@Avinash-Bhat
Avinash-Bhat / factory.js
Last active December 13, 2015 18:08
Object.create vs (evil) eval for creating an object of different types according to the arguments received.
function createObject (clazz, args) {
var o;
if (Object.create) {
o = Object.create(clazz)
clazz.constructor.apply(xx, args);
} else {
// screwed! nothing other than evil-eval :-(
o = eval("new " + clazz.constructor.name + "(" + args + ")");
}
}
@Avinash-Bhat
Avinash-Bhat / qr-pure-js.js
Created December 6, 2012 13:12
showing url as a QR code
(function() {
function cssAsNum(width){
return Number(width.replace("px",""))
}
var body,img;
body = document.body;
img = document.createElement("img");
img.style.userSelect = "none";
img.style.position = "fixed";
img.style.zIndex = 999999;
@Avinash-Bhat
Avinash-Bhat / jquery.ui.widget-(partial).js
Created November 5, 2012 19:08
fix for problematic bug in jquery ui 1.9.1 (ticket#8775)
$.widget.bridge = function( name, object ) {
var fullName = object.prototype.widgetFullName || name;
$.fn[ name ] = function( options ) {
var isMethodCall = typeof options === "string",
args = slice.call( arguments, 1 ),
returnValue = this;
// allow multiple hashes to be passed on init
options = !isMethodCall && args.length ?
$.widget.extend.apply( null, [ options ].concat(args) ) :
@Avinash-Bhat
Avinash-Bhat / Benchmark.coffee
Created August 22, 2012 14:48
Simple Benchmark class for minor performance testing.
_avg = (items) ->
sum = 0
sum += item for item in items
sum / items.length
class Benchmark
constructor: (@functions,@maxSampling) ->
@check()
check: () ->