Skip to content

Instantly share code, notes, and snippets.

View bdalziel's full-sized avatar

Ben Dalziel bdalziel

View GitHub Profile
import Alamofire
import SwiftyJSON
extension Request {
public static func SwiftyJSONResponseSerializer(
options options: NSJSONReadingOptions = .AllowFragments)
-> ResponseSerializer<JSON, NSError>
{
return ResponseSerializer { _, _, data, error in
guard error == nil else { return .Failure(error!) }
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 / 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';