Skip to content

Instantly share code, notes, and snippets.

View abrjagad's full-sized avatar

Abraham Jagadeesh abrjagad

View GitHub Profile
@abrjagad
abrjagad / Date.js
Last active August 29, 2015 14:05
Jquery Date
var d, h, m, s,
ms = $newDate - $currentDate;
s = Math.floor(ms / 1000);
m = Math.floor(s / 60);
s = s % 60;
h = Math.floor(m / 60);
m = m % 60;
d = Math.floor(h / 24);
h = h % 24;
@abrjagad
abrjagad / Javascript Object.js
Last active August 29, 2015 14:11
Javascript Object
//http://javascriptissexy.com/javascript-objects-in-detail/
//everything in javascript is objects.
//except number, strings & boolean
//objects are key/value pairs
//anything ends with () is a function
//in that way; new Object() is also a function
//and it has methods like create()
// and hasOwnProperty()
function getFunc() {
var a = 7;
return function(b) {
alert(a+b);
}
}
var f = getFunc();
f(5);
//12
var a = 1;
function b() {
a = 10;
return;
function a() {}
}
b();
alert(a);
//Using the code above, the browser will alert "1".
@abrjagad
abrjagad / Inside Function declaration.js
Last active August 29, 2015 14:15
how "this" keyword behaves
function c(){
return this;
}
c() //prints window
var obj = {
a:1,
b:2
}
var player, playButton = document.getElementById("play-button"),youttubeplayer = [];
/* this function gets called when API is ready to use*/
function onYouTubePlayerAPIReady() {
/* create the global player from the specific iframe (#video)*/
if (typeof(youtubeVideo) !== "undefined") {
player = new YT.Player('video', {
videoId: youtubeVideo,
playerVars: {
wmode: "opaque"
},
<style>
.line-behind {
position: relative;
text-align: center;
&:after {
content: "";
height: 3px;
display: block;
position: absolute;
left: 0;
@abrjagad
abrjagad / auto resize iframe.js
Last active August 29, 2015 14:16
adjust the width and height of iframe
function autoResize(id) {
var newheight;
var newwidth;
var id = document.getElementById(id);
newheight = id.contentWindow.document.body.scrollHeight;
newwidth = id.contentWindow.document.body.scrollWidth;
id.height = newheight + "px";
@abrjagad
abrjagad / Grunt configuration
Last active August 29, 2015 14:16
Grunt configuration
node -v // check node
npm update -g npm //update npm
npm install -g grunt-cli //install grunt command line
//existing project
npm install
grunt
//new project
@abrjagad
abrjagad / ruby
Last active August 29, 2015 14:16
Ruby & gem setup
http://rubyinstaller.org/downloads/
// ruby and devkit - download from here
ruby -v // check version
//devkit instalation
//extract the zip archive anywhere
// in cmd - go that location
// and run these two commands