Skip to content

Instantly share code, notes, and snippets.

View jineeshjohn's full-sized avatar

Jineesh jineeshjohn

View GitHub Profile
@jineeshjohn
jineeshjohn / event_delegation.html
Created November 20, 2011 06:47
Event delegation sample
<style>
#mytable{
border-bottom:1px solid #000;
border-right:1px solid #000;
}
#mytable td{
border-top:1px solid #000;
border-left:1px solid #000;
padding:15px;
@jineeshjohn
jineeshjohn / gist:2044414
Last active December 5, 2018 18:59
Dynamic html table rows and column creation with jQuery
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<style>
table{
width:500px;
height:500px;
}
table td{
padding:10px;
margin:10px;
border:1px solid #ccc;
@jineeshjohn
jineeshjohn / gist:2555702
Created April 30, 2012 05:14
String Concat first and last , second and second last ... using JavaScript
function foo(str){
var len = str.length, i = 0,j = len, arr = [];
var i = 0,j = len-1,half = Math.floor( len/2 );
while( i<half ){
arr.push(str[i]+str[j]);
i++;
j--;
}
if( len%2 == 1)
@jineeshjohn
jineeshjohn / gist:2763092
Created May 21, 2012 16:18
Colors supported by all major browsers
<style>
div.white{ background-color:white;}
div.yellow{ background-color:yellow;}
div.red{ background-color:red;}
div.fuscia{ background-color:#f0f;}
div.silver{ background-color:silver;}
div.gray{ background-color:gray;}
div.olive{ background-color:olive;}
div.purple{ background-color:purple;}
div.maroon{ background-color:maroon;}
@jineeshjohn
jineeshjohn / gist:4482957
Created January 8, 2013 11:01
HTML5 default template
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Sample Document</title>
<script></script>
</head>
<body>
...
@jineeshjohn
jineeshjohn / gist:5098412
Created March 6, 2013 10:32
String into a javascript function call. Better way to create instance for dynamic class names
var Y = (function(){
return {
Car:function(model){
this.model = model;
this.applyBreak = function(){
alert("done break!!");
}
}
}
@jineeshjohn
jineeshjohn / gist:5141841
Created March 12, 2013 10:27
Configuration to gzip apache server.
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/css,text/javascript,application/javascript,application/x-javascript"
/>
@jineeshjohn
jineeshjohn / gist:5424891
Last active December 16, 2015 11:08
A sample to test the promise pattern
/**
1) doing things in sequence
$(btn).click(function(){
getTwitterHandle(function(){
getTweets(function(){
});
});
@jineeshjohn
jineeshjohn / gist:5917312
Created July 3, 2013 11:57
Defer method implementation to have async functionality
Function.prototype.defer = function(t,args){
var __method = this;
var timeout = t*1000;
window.setTimeout(function() {
return __method.call(__method, args);
}, timeout);
};
function foo(args){
console.log("ss:" , args.a);
@jineeshjohn
jineeshjohn / gist:6020639
Created July 17, 2013 13:40
Ant script to merge multiple files with a custom separator
<project default="theMerger" basedir=".">
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<target name="theloop">
<foreach target="theSeparator" param="theFile">
<path id="someId">
<fileset dir="${basedir}/dd" includes="**/*.js"/>
</path>
</foreach>
</target>