Skip to content

Instantly share code, notes, and snippets.

View alexmcpherson's full-sized avatar

Alex McPherson alexmcpherson

  • Colorado
View GitHub Profile
@alexmcpherson
alexmcpherson / index.html
Last active August 29, 2015 13:56
Basic HTML structure
<html>
<head>
<!-- Metadata -->
</head>
<body>
<!-- Content -->
</body>
</html>
@alexmcpherson
alexmcpherson / index.html
Last active August 29, 2015 13:56
Essential HTML tags
<!DOCTYPE html> <!-- What 'schema' to use for the 'XML'. This means HTML5 -->
<html>
<head>
<title>My Page</title><!-- Shows in the browser, important for SEO (apparently :-) -->
</head>
<body>
<div>I'm a div, basically a box. I'm super useful.</div>
<p>
This is a paragraph, good for long strings of text.
@alexmcpherson
alexmcpherson / main.css
Created February 24, 2014 23:22
Basic CSS example
p {
color: #000000;
font-size: 1.2px;
}
.important {
font-weight: bold;
}
#main {
@alexmcpherson
alexmcpherson / index.html
Last active August 29, 2015 13:56
More advanced selectors
<html>
<head></head>
<body>
<div>
<span>Bold!</span>
<span>Not bold...</span>
</div>
<ul>
@alexmcpherson
alexmcpherson / main.css
Last active August 29, 2015 13:56
Occurrences of properties on the Quickleft.com style sheet
298 color:
293 display:
205 width:
170 background-color:
129 margin-left:
127 padding:
119 font-size:
117 position:
117 height:
114 left:
@alexmcpherson
alexmcpherson / output
Created February 25, 2014 00:32
Ping main.css properties count
323 content:
295 background-color:
256 color:
235 margin-left:
222 width:
184 display:
177 background-image:
153 background-position:
115 line-height:
100 padding:
@alexmcpherson
alexmcpherson / constructor_scope.js
Created February 25, 2014 05:34
Prototype sample code
function Person(name) {
this.name = name;
}
Person.prototype.whoAmI = function() {
console.log(this.name);
}
var alex = new Person('alex');
@alexmcpherson
alexmcpherson / main.js
Created February 25, 2014 05:39
Functional scope in javascript
function scopeTest() {
var myVariable = 'Alex'; //var is important, declares it in this scope
console.log(myVariable);
}
scopeTest();
typeof myVariable === "undefined";
@alexmcpherson
alexmcpherson / main.js
Last active August 29, 2015 13:56
Raw XHR Sample
//executed from api.jquery.com
function reqListener () {
console.log(this.responseText);
}
var oReq = new XMLHttpRequest();
oReq.onload = reqListener;
oReq.open("get", "http://api.jquery.com/robots.txt", true);
oReq.send();
@alexmcpherson
alexmcpherson / main.js
Created June 4, 2014 22:53
Scrolling speed effect
var last = 0
var offsets = []
$('#content').css('transition', 'all .1s')
$(window).scroll(function(){
offsets.push(Math.abs(window.scrollY - last))
last = window.scrollY
})
setInterval(function() {
var total = 0