Skip to content

Instantly share code, notes, and snippets.

View nzakas's full-sized avatar
💭
GitHub time is limited currently. Please be patient.

Nicholas C. Zakas nzakas

💭
GitHub time is limited currently. Please be patient.
View GitHub Profile
@nzakas
nzakas / inlineblockheight.htm
Created July 11, 2012 20:27
I'm trying to set the height of an inline-block element to 100%. It needs to take up the entire height of its container, which cannot have a fixed height set on it.
<!DOCTYPE html>
<html>
<head>
<title>Inline Block 100% Height</title>
<style>
.ib {
display: inline-block;
background: red;
height: 100%;
vertical-align: top;
@nzakas
nzakas / noanon.md
Created June 8, 2012 21:19
Avoiding "new anonfn"

JSLint doesn't like using new function. This makes sense, because you're just creating a singleton, and so there's no point in using a constructor for that. If you have something like this:

var NowWithClosures = Backbone.Model.extend(new function(){
    var x = 1;
    this.initialize = function(){
        console.log('init');
    };
    this.AddOneToX = function(){
 x++;
@nzakas
nzakas / mjstoc.md
Created April 17, 2012 14:50
Maintainable JavaScript Table of Contents
  • Part 1 - Style Guide
    • Chapter 1 - Basic Formatting
    • Chapter 2 - Comments
    • Chapter 3 - Statements
    • Chapter 4 - Functions and Expressions
  • Part 2 - Programming Practices
    • Chapter 5 - Loose Coupling
    • Chapter 6 - Avoid Globals
    • Chapter 7 - Event Handling
  • Chapter 8 - Avoid Null Comparisons
@nzakas
nzakas / csslint-api.js
Created February 9, 2012 17:03
CSS Lint API
//include
var CSSLint = require("csslint").CSSLint;
/*
* Basic usage
* First argument is the CSS text.
* Second argument is the options object. Name is the ID of the rule (see wiki) set to
* either 1 for a warning or 2 for an error.
*/
var result = CSSLint.verify(".foo { }", { "compatible-vendor-prefixes": 1 }),
@nzakas
nzakas / button-issue.htm
Created February 7, 2012 23:47
Firefox buttons too large
<!DOCTYPE html>
<html>
<head>
<title>Button Issue</title>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?3.4.1/build/cssfonts/cssfonts-min.css&3.4.1/build/cssreset/cssreset-min.css">
<style>
p {
margin: 10px;
@nzakas
nzakas / gzip.xml
Created December 23, 2011 15:51
Ant target for gzipping multiple files
<target name="compress">
<!-- store filenames in a property delimited by ; -->
<pathconvert pathsep=";" property="compress.jsfiles">
<fileset dir="${build.dir}" includes="*.js"/>
</pathconvert>
<script language="javascript"><![CDATA[
importPackage(java.io);
@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]]) {
@nzakas
nzakas / gist:1367412
Created November 15, 2011 15:54
Npm debug Log
info it worked if it ends with ok
verbose cli [ 'node', '/usr/local/bin/npm', 'update', 'npm', '-g' ]
info using npm@1.0.10
info using node@v0.4.10
verbose config file /home/nicholas/.npmrc
verbose config file /usr/local/etc/npmrc
silly exec /usr/local/bin/node "/usr/local/lib/node_modules/npm/bin/npm-get-uid-gid.js" "nobody" 1000
silly output from getuid/gid {"uid":65534,"gid":1000}
silly output from getuid/gid
silly testEngine { name: 'csslint',
@nzakas
nzakas / stack.js
Created September 12, 2011 19:24
Stack implementation using ES6 proxies
/*
* Another ES6 Proxy experiment. This one creates a stack whose underlying
* implementation is an array. The proxy is used to filter out everything
* but "push", "pop", and "length" from the interface, making it a pure
* stack where you can't manipulate the contents.
*/
var Stack = (function(){
var stack = [],