Skip to content

Instantly share code, notes, and snippets.

Hello!
The available spaces this month filled up very quickly, so we started a waiting list.
If you can't attend after all, please cancel your registration. Follow the the link below:
https://www.eventbrite.com/mytickets/
If you can't figure out how to cancel your ticket, or you are so busy you have no time to do it, please email us and we'll cancel it for you.
Thank you!
@theophani
theophani / Placeholder workaround
Created January 10, 2011 10:43
shows and hides a label, used as placeholder text
// Relevant HTML and JS
<label for="searchbox" id="searchboxPlaceholder">Search</label>
<input type="text" name="Query" id="searchbox" />
<script>
(function(d){
var sb = d.getElementById('searchbox'),
ph = d.getElementById('searchboxPlaceholder');
var hide = function() {
ph.style.display = 'none';
var or = function or(a, b) {
return a || b;
};
var and = function and(a, b) {
return a && b;
};
var not = function not(a) {
return !a;
@theophani
theophani / gist:799476
Created January 27, 2011 22:54
copy of Google Maps v3 Shortcode
<?php
/*
Plugin Name: Google Maps v3 Shortcode
Plugin URI: http://gis.yohman.com
Description: This plugin allows you to add one or more maps to your page/post using shortcodes. Features include: multiple maps on the same page, specify location by address or lat/lon combo, add kml, show traffic, add your own custom image icon, set map size.
Version: 1.02
Author: yohda
Author URI: http://gis.yohman.com/
*/
@theophani
theophani / Grey arrow data uri
Created March 9, 2011 09:47
Grey arrow preceded by a space (#999, suitable for use with 12px font)
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAHCAIAAABV+fA3AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADJJREFUeNpi+I8KFi1aBGczMWCAxYsXQxhY5ODS2OUg0jjlYmNjmXBJYDcTIgEEAAEGAGysItsbwoS/AAAAAElFTkSuQmCC
To use as an arrow after a link:
a:after { content: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAHCAIAAABV+fA3AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADJJREFUeNpi+I8KFi1aBGczMWCAxYsXQxhY5ODS2OUg0jjlYmNjmXBJYDcTIgEEAAEGAGysItsbwoS/AAAAAElFTkSuQmCC'); }
About data URIs:
http://en.wikipedia.org/wiki/Data_URI_scheme
Awesome image to data URI converter:
http://www.abluestar.com/utilities/encode_base64/
@theophani
theophani / a.button.css
Created March 10, 2011 17:40
button with one sprite and no extra mark-up
/* the only mark-up is <a href="#" class="button">Click me!</a> */
a.button {
float: left; display: block; /* makes the width fit around the text */
padding: 0 0 0 1em; /* padding on the LEFT only */
line-height: 32px; /* the full height of the sprite */
background: url(/images/sprite.png) no-repeat left 0; /* position here assumes the edge is the true edge */
}
a.button:after {
display: inline-block; /* make it full height, yet inline */
@theophani
theophani / gist:868007
Created March 13, 2011 10:18
8 choose 2, including one couple
two couple scenario:
(4 choose 2) = 6
one couple and a non-couple scenario:
(4 choose 1) * (3 choose 2) * (2 choose 1) * (2 choose 1) = 48
choose one couple, choose two of remaining couples, and from each couple, choose 1 person
Possible configurations:
6 + 48 = 54
Q: i want to choose 4 people out of 4 couples. i want a group with at least 1 couple.
4 couples:
ab
cd
ef
gh
> > > selecting among the four couples is:
> > > (4 choose 1) = 4
@theophani
theophani / gencontentSupported.js
Created March 16, 2011 11:56
detect if generated content is supported by the browser
/*
Adapted from
https://github.com/KrofDrakula/Modernizr/commit/cdb322bdbdc7b62b4f0fcece08372e6194342f7d
*/
var gencontentSupported = function() {
var doc = document,
d = doc.createElement('div'),
p = doc.createElement('p'),
b = doc.body,
w,
@theophani
theophani / gist:1122508
Created August 3, 2011 12:22 — forked from remy/gist:804414
Simple CSS parser
function parseCSS(str) {
function trim(str) {
return (str||'').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
var i, j, k,
split = '}',
cur_key = '',
cur_key_split,
css = str.replace(/\t*/g, '').replace(/\s{2}/, ' ').replace(/[\n|\r]/g, ' ').replace(/\/\*.*?\*\//g, '').split(split),