Skip to content

Instantly share code, notes, and snippets.

@silentmatt
silentmatt / graycode.js
Created June 26, 2009 17:10
JavaScript functions to convert to/from binary-reflected Gray codes
Number.toGrayCode = function(n) {
if (n < 0) {
throw new RangeError("cannot convert negative numbers to gray code");
}
return n ^ (n >>> 1);
};
Number.fromGrayCode = function(gn) {
if (gn < 0) {
throw new RangeError("gray code numbers cannot be negative");
@paulirish
paulirish / README.md
Created January 4, 2010 02:38
imagesLoaded() jquery plugin
//** Vertical Rhythm **//
// By Chris Eppstein, with adjustments by Eric Meyer
// The IE font ratio is a fact of life. Deal with it.
!ie_font_ratio = 16px / 100%
// The base line height is the basic unit of line hightness.
!base_line_height ||= 18px
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active May 16, 2024 16:51
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- Disable automatic DNS prefetching.
@jacine
jacine / template.php
Created May 19, 2011 03:19
HTML5 Drupal 7 Tweaks
<?php
/**
* Implements hook_html_head_alter().
* - Simplify the meta charset element.
*/
function THEMENAME_html_head_alter(&$head_elements) {
$head_elements['system_meta_content_type']['#attributes'] = array(
'charset' => 'utf-8',
);
/*
* Property prefix hacks
*/
/* IE6 only - any combination of these characters */
_ - £ ¬ ¦
/* IE6/7 only - any combination of these characters */
@jacine
jacine / template.php
Created August 17, 2011 19:15
Using hook_html_head_alter() to add or modify <head> contents.
<?php
/**
* Implements hook_html_head_alter().
*
* The purpose of this alter function is to modify the contents of the $head
* variable which prints in html.tpl.php. This variable is created in
* template_process_html() using the function drupal_get_html_head(). Here we
* add 2 <meta> tags, 1 <link> tag and simplify the <meta charset />.
*/
@jacine
jacine / template.php
Created August 23, 2011 01:34
Add ARIA roles to blocks
<?php
/**
* Implements template_preprocess_block().
*/
function THEME_preprocess_block(&$vars) {
$roles = array(
'complementary' => array(
'aggregator',
'help',
@necolas
necolas / README.md
Last active March 28, 2024 20:34
Experimenting with component-based HTML/CSS naming and patterns

NOTE I now use the conventions detailed in the SUIT framework

Template Components

Used to provide structural templates.

Pattern

t-template-name