Skip to content

Instantly share code, notes, and snippets.

View cerebrl's full-sized avatar

Justin Lowery cerebrl

View GitHub Profile
function showIt(elID) {
var el = document.getElementById(elID);
el.scrollIntoView(true);
}
@cerebrl
cerebrl / form-follows-function.md
Created July 15, 2013 02:07
The Source of "Form Follows Function"

The original text comes from "The Tall Office Building Artistically Considered" by Louis Sullivan. I've edited down the text considerably to reveal what I feel are the best parts.

All of these critics and theorists agree, however, positively, unequivocally, in this, that the tall office building should not, must not, be made a field for the display of architectural knowledge in the encyclopaedic sense; that too much learning in this instance is fully as dangerous, as obnoxious, as too little learning; that miscellany is abhorrent to their sense …

To this latter folly I would not refer were it not for the fact that nine out of every ten tall office buildings are designed in precisely this way, in effect not by the ignorant, but by the educated. It would seem indeed as though the "trained" architect, when facing this problem, were beset at every story, or at most, every third or fourth story, by the hyst

@cerebrl
cerebrl / vertical-rhythm.css
Created July 15, 2013 01:53
Vertical Rhythm for both 1.333em and 1.25em
/*****************************
Leading at 1.33em
*****************************/
h1 {
/* Total Height: 106.6666px */
font-size: 4em; /* 64 */
line-height: 1.3333em; /* 85.3312 */
padding-bottom: 0.3333em; /* 21.333312 */
}
@cerebrl
cerebrl / custom-list-styling.css
Created July 15, 2013 01:49
Custom List (ul/ol) Styling
ol {
counter-reset: numbering 0;
}
ol li:before {
counter-increment: numbering 1;
content: counter(numbering, decimal);
}
@cerebrl
cerebrl / slider-wo-js.html
Created July 15, 2013 01:47
Slider w/o JavaScript
<style>
#content-slider {
width: 650px;
overflow: hidden;
height: 300px;
}
#content-slider-inside {
list-style: none;
height: 320px; // these 3 lines
@cerebrl
cerebrl / uri-parsing.js
Created July 15, 2013 01:45
URI Parsing with JavaScript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@cerebrl
cerebrl / angular-objects.js
Created July 15, 2013 01:37
Angular Objects Types
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
};
});
//factory style, more involved but more sophisticated
@cerebrl
cerebrl / calc-age.js
Created July 15, 2013 01:34
Calculating Age
function getAge(dateString) {
var today = new Date();
var birthDate = new Date(dateString);
var age = today.getFullYear() - birthDate.getFullYear();
var m = today.getMonth() - birthDate.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
return age;
}
@cerebrl
cerebrl / attribute-selectors.css
Created July 15, 2013 01:30
CSS Attribute Selectors
/**************************
CSS 2.1 Attribute Selectors
**************************/
E[foo] /* Matches any E element with the "foo" attribute set (whatever the value). */
E[foo="warning"] /* Matches elements whose "foo" attribute value is exactly equal to "warning".*/
E[foo~="warning"] /* Matches elements whose "foo" attribute value is a list of space-separated values, one of which is exactly equal to "warning". */
/**************************
CSS 3 Attribute Selectors
@cerebrl
cerebrl / scope-linking.md
Created July 15, 2013 01:14
Angular Scope Linking in Directives

What do the little symbols for scope linking mean?

Well, say you have controller.js and view.html with the following code:

Your controller.js

$scope.name = 'world';

Your view.html