Skip to content

Instantly share code, notes, and snippets.

View himynameisdave's full-sized avatar
✌️
livin' the dream...

Dave Lunny himynameisdave

✌️
livin' the dream...
View GitHub Profile
@himynameisdave
himynameisdave / manifest.json
Created July 5, 2015 16:57
awwe-new-tab - manifest.json
{
"manifest_version": 2,
"name": "Awwe",
"description": "Makes the new tab some cute pups!",
"version": "0.0.1",
"permissions": [
"storage"
],
"chrome_url_overrides": {
"newtab": "newtab.html"
@himynameisdave
himynameisdave / newtab.html
Last active August 29, 2015 14:24
awwe-new-tab - newtab.html
<html>
<head>
<title>Awwe Tab</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<main class="main">
<h1 class="greeting">HELLO WORLD!</h1>
</main>
<script type="text/javascript" src="script.js"></script>
@himynameisdave
himynameisdave / styles.css
Last active August 29, 2015 14:24
awwe-new-tab - styles.css
html,
body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
.main {
background-position: 50% 50%;
background-repeat: no-repeat;
@himynameisdave
himynameisdave / homework.js
Created July 14, 2015 15:27
Alex's JS homework
// QUESTION 1
var combineArgs = function( a, b ){
alert(a + b);
};
combineArgs("This question ", "is easy");
@himynameisdave
himynameisdave / script.js
Last active August 29, 2015 14:24
awwe-new-tab - pups.js
// array of cute pups!
var pups = [
"http://bit.ly/1JfFy1x",
"http://bit.ly/1I0JoPI",
"http://bit.ly/1gA0nhg",
"http://bit.ly/1HtUxEP",
"http://bit.ly/1M8w9ix"
];
// randomly selects a pup image url and returns the string with the "url" stuff attached
var bgPlz = function(){
@himynameisdave
himynameisdave / script.js
Last active August 29, 2015 14:24
awwe-new-tab - name.js
/// look in chrome.storage for an item "name"
chrome.storage.sync.get( 'name', function( val ){
// check if we have a name
if( !val.name ){
// get, set & store a new name
getSetAndStoreName();
}else{
// use the name found to set .greeting
document.querySelector(".greeting").innerHTML = "Hey there "+val.name+"!";
}
@himynameisdave
himynameisdave / manifest.json
Created July 15, 2015 01:25
awwe-new-tab - manifest.json + icon
{
"manifest_version": 2,
"name": "Awwe",
"description": "Makes the new tab some cute pups!",
"version": "0.0.1",
"permissions": [
"storage"
],
"chrome_url_overrides": {
"newtab": "newtab.html"
@himynameisdave
himynameisdave / ice-cream.js
Last active August 29, 2015 14:27
.bind(this) For Dummies [BROKEN]
//[BROKEN]
var IceCream = {
flavors: [ 'vanilla', 'chocolate', 'bubblegum' ],
newFlavor: 'banana',
addNewFlavor: function( ){
var safeToAdd = true;
// check if we've added it already
this.flavors.forEach(function(flavor){
if(flavor === this.newFlavor) // <- this throws an error
@himynameisdave
himynameisdave / ice-cream.js
Last active August 29, 2015 14:27
.bind() For Dummies [WORKS FINE BUT NOT IDEAL]
// [WORKS FINE BUT NOT IDEAL]
addNewFlavor: function( ){
var safeToAdd = true,
context = this;
// check if we've added it already
this.flavors.forEach(function(flavor){
if(flavor === context.newFlavor)
safeToAdd = false;
});
@himynameisdave
himynameisdave / ice-cream.js
Last active August 29, 2015 14:27
.bind() For Dummies [WORKING]
addNewFlavor: function( ){
var safeToAdd = true
// check if we've added it already
this.flavors.forEach(function(flavor){
if(flavor === this.newFlavor)
safeToAdd = false;
}.bind(this));
if(safeToAdd)
this.flavors.push(this.newFlavor);
}