Skip to content

Instantly share code, notes, and snippets.

@nola
nola / constructor.js
Created January 31, 2014 00:41
Objects parent > child > grandchild constructor
var parent = {
get: function fn(){
return this.val;
},
val:42
}
var child = Object.create(parent);
child.val = 3.14;
@nola
nola / basic-tween-object.js
Created January 30, 2014 15:17
Logs out a property of the object 'obj'
var obj = {opacity:0};
TweenLite.to(obj, 2, {opacity:0.5, onUpdate:report});
function report() {
console.log(obj.opacity);
}
@nola
nola / objectConstructor.js
Last active January 3, 2016 06:49
creating the constructor then adding new objects via the constructor
// object constructor:
function Person(job, married) {
this.job = job;
this.married = married;
}
//function that logs info to console
function logger(x){
console.log(x)
}
@nola
nola / forloop.js
Last active January 3, 2016 06:48
for loop: outputs property name and value
var nyc = {
fullName: "New York City",
mayor: "Michael Bloomberg",
population: 8000000,
boroughs: 5
};
//This loop will output ALL the properties of this object
for(var i in nyc){
<div id="output"></div>
@nola
nola / address2.js
Last active January 3, 2016 05:59
//create an object
var friends = {};
//add people to it
friends.bill = { //observe this declaration as bill is an object of friends
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ['One Microsoft Way','Redmond','WA','98052']
};
@nola
nola / index.html
Created January 13, 2014 21:17
A Pen by Cyril Celestine.
<button>update</button>
<input type="text" value="10" /> <br />
<label></label>
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@nola
nola / extension-example.js
Last active January 2, 2016 03:49
jquery extension example. Notice the use of chaining the styles together
// creates a function that will add a 2px blue border around each div with the class "blue"
$.fn.blueBorder = function(){
this.each(function(){
$(this).css("border","solid blue 2px");
});
return this;
};
//creates a function that will turn the text color blue of each div
$.fn.blueText = function(){
// this targets Google Chrome and Opera 18+
var isChromium = window.chrome;
if(isChrome === true) {
// is chromium based browser
} else {
// not chromium based browser
}
//To target if the browser is Google Chrome, use this:
var isChromium = window.chrome,