Skip to content

Instantly share code, notes, and snippets.

View bdalziel's full-sized avatar

Ben Dalziel bdalziel

View GitHub Profile
@bdalziel
bdalziel / DoNotTryAndBeTooCleverWithinAnIteratorObject.php
Created July 25, 2011 20:42
Within an object implementing Iterator, be careful when using foreach($this as $foo) as opposed to foreach($this->items as $foo). If you're traversing a tree based on iteration in two directions through recursion, you can easily interfere with the interna
<?php
require_once 'SimpleIteratorNodeClasses.php';
class TryingToBeCleverNode extends SimpleNode {
public function getDepthOfDeepestChild () {
$max_depth = 'N/A';
var setupEllipsis = function(container, itemIndex, itemCount, maxItemCount) {
// Make everything visible
var hidden = container.all('li.hidden');
hidden.removeClass('hidden');
var ellipsis = container.all('li.ellipsis');
ellipsis.removeClass('ellipsis');
// Get the bounding box data for the selected item
var activePage = container.one('li.pageNum-'+itemIndex);
@bdalziel
bdalziel / gist:1235357
Created September 22, 2011 17:06
Ben's .emacs File
(add-to-list 'load-path "~/elisp")
(require 'php-mode)
(setq-default indent-tabs-mode nil);
(setq default-tab-width 4);
(setq c-basic-offset 4);
@bdalziel
bdalziel / gist:1235362
Created September 22, 2011 17:08
Ben's .bash_profile file
alias gobb='cd ~/dev/bbsites/trunk/;'
alias goww='cd ~/dev/bbsites/trunk/wonderwall/;'
alias gowwl='cd ~/dev/bbsites/trunk/wwlatino/;'
alias goglo='cd ~/dev/bbsites/trunk/glo/;'
alias gocom='cd ~/dev/bbsites/trunk/common/;'
alias gonfl='cd ~/dev/nfl/trunk/;'
alias gosly='cd ~/dev/sly/trunk/;'
alias gost='cd ~/dev/slytrunk/trunk/;'
$tag = "a tag to contain a list of cacheId";
$cacheId = "some key to cache";
if ( ! $keys = $this->_cache->load( $tag ) ) {
$keys = array( $cacheId );
$this->_cache->save( $keys, $tag );
}
else if ( ! in_array( $cacheId, $keys ) ) {
$keys[] = $cacheId;
$this->_cache->save( $keys, $tag );
@bdalziel
bdalziel / gist:2293724
Created April 3, 2012 17:07
Work around for iOS iframe growth
html,
body,
#doc {
height: 100%; // Passes through the height of the parent iframe element
}
#doc {
// Magic to prevent iOS growing the iFrame to fit the content.
// This container will mimic the behavior of the iframe on a desktop browser
-webkit-overflow-scrolling:touch;
overflow-y: scroll;
@bdalziel
bdalziel / gist:2766645
Created May 22, 2012 04:44
styling fix
<style type="text/css">
input:not([type="image"]), textarea {
box-sizing: content-box;
}
</style>
@bdalziel
bdalziel / gist:3005482
Created June 27, 2012 17:16
Avoiding flicker on -webkit-overflow-scrolling: touch; content
li {
-webkit-backface-visibility: hidden;
-webkit-transform: translate3d(0,0,0);
}
@bdalziel
bdalziel / gist:3005501
Created June 27, 2012 17:19
Heavier handed flicker solution
ul * {
-webkit-backface-visibility: hidden;
-webkit-transform: translate3d(0,0,0);
}
@bdalziel
bdalziel / gist:3005518
Created June 27, 2012 17:22
Simple horizontal scroll with native feel and no flicker following transitions
#issues {
width: 100%;
max-width: 100%;
white-space: nowrap;
overflow: hidden;
overflow-x: scroll;
-webkit-overflow-scrolling:touch;
ul, li {