Skip to content

Instantly share code, notes, and snippets.

@nathansmith
nathansmith / data_icon.css
Created December 14, 2011 15:26
Terse Font Icons
a[data-icon]:before,
span[data-icon]:before {
font-family: 'Icon Font Here';
content: attr(data-icon);
}
/*
This would also work, but other web developers might
yell at you about "performance" which may/not matter:
@ry5n
ry5n / dry-with-sass-lists
Created December 12, 2011 01:49
Using Sass lists for DRY-er code
// Shared colors for buttons and alerts
//
// Use Sass lists to avoid writing out repeating patterns of Sass code.
//
// For example, the following avoids having to write out a selector and
// set of style rules for each alert type, when only class and
// variable names are different.
//
// Follows (and many thanks to) Nathan Weizenbaum (@nex3)’s comment at:
// http://groups.google.com/group/sass-lang/msg/987926ad9fe5ad43?
@nzakas
nzakas / namespace.js
Created December 6, 2011 19:14
A single global with a namespace method
//BSD Licensed
var YourGlobal = {
namespace: function(ns){
var parts = ns.split("."),
object = this,
i, len;
for (i=0, len=parts.length; i < len; i++) {
if (!object[parts[i]]) {
@deepakjois
deepakjois / generate-fiddle.sh
Created December 4, 2011 02:32
A convenient way to generate Github gists and link them to JSFiddle.
#!/bin/sh
# Usage: generate-fiddle <folder>
# Creates a folder and adds some files commonly used with JSFiddle
set -e
# Create folder
mkdir $1
cd $1
@mklabs
mklabs / bootstrap-plugins.txt
Created December 2, 2011 11:23
h5bp + twitter bootstrap integration
bootstrap-tooltip.js
bootstrap-popover.js
bootstrap-alert.js
bootstrap-button.js
bootstrap-carousel.js
bootstrap-collapse.js
bootstrap-dropdown.js
bootstrap-modal.js
bootstrap-scrollspy.js
bootstrap-tab.js
@nimbupani
nimbupani / index.html
Created December 2, 2011 05:00
Showing latest post on home page with Jekyll
---
layout: default
---
<div class="blog-index">
{% assign post = site.posts.first %}
{% assign content = post.content %}
{% include post_detail.html %}
</div>

JavaScript Class Syntax

Let's build a JavaScript class syntax from first principles. For the purpose of this exercise, let's assume that the purpose of the class syntax is to add much-needed sugar to common JavaScript idioms.

Let's start with how JavaScript "classes" work today:

// this is a constructor
Person = function() {
 this // `this` is a new instance of Person
@ryanflorence
ryanflorence / badjs.md
Created November 7, 2011 04:52
What leads to a poor JavaScript application?

What makes a bad JavaScript application?

We've all seen some horrible JavaScript. Name the top five things you see that lead to horrible JavaScript applications. Feel free to elaborate on each of your points.

I'll start, in no particular order:

  1. Poor organization in the file system
  2. Poor abstraction
  3. Seemingly endless indentation in nested callbacks / if / else if / etc.
@ezkl
ezkl / ezekiel_templin.rb
Created November 5, 2011 04:18
My Bio... in Ruby
class EzekielTemplin
def initialize
@birthdate = Date.parse('1983-06-29')
@birthplace = "Saegertown, PA"
@gender = "male"
end
def age
Date.today.year - @birthdate.year
end
@addyosmani
addyosmani / jquery.tinypubsub.js
Created October 27, 2011 10:10 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery 1.7
/*!
* jQuery Tiny Pub/Sub for jQuery 1.7 - v0.1 - 27/10/2011
* Based on @cowboy Ben Alman's REALLY tiny pub/sub.
* 1.7 specific updates by @addyosmani.
* Copyright maintained by @cowboy.
* Dual licensed under the MIT and GPL licenses.
*/
(function($){