Skip to content

Instantly share code, notes, and snippets.

@pgchamberlin
pgchamberlin / gist:9619843
Last active August 29, 2015 13:57
Functional vs procedural loops in PHP
class someclass
{
private $items;
function filterItemsUsingForeach()
{
$criterion = 'somevalue';
$items = array();
foreach ($this->items as $item) {
if (method_exists($item, 'someMethod') && $item->someMethod() == $criterion) {
@pgchamberlin
pgchamberlin / gist:10633516
Created April 14, 2014 09:53
Jasmine data provider helper
//Data provider functionality in jasmine
//see http://blog.jphpsf.com/2012/08/30/drying-up-your-javascript-jasmine-tests
function using(name, values, func){
for (var i = 0, count = values.length; i < count; i++) {
if (Object.prototype.toString.call(values[i]) !== '[object Array]') {
values[i] = [values[i]];
}
func.apply(this, values[i]);
jasmine.currentEnv_.currentSpec.description += ' (with "' + name + '" using ' + values[i].join(', ') + ')';
}
@pgchamberlin
pgchamberlin / vim_browse
Last active August 29, 2015 14:02
Vim command to open file in Chrome
# Open the current file in Chrome in OSX from Vim
# Add this to ~/.vimrc
# Usage: `:Browse`
command Browse execute "!/usr/bin/open -a \"/Applications/Google Chrome.app\"" expand('%:p')
@pgchamberlin
pgchamberlin / ilabcode2_1.py
Created June 30, 2014 14:18
Dev on AWS: Lab 2.1 code
import boto
from boto.s3.key import Key
class Ilabcode:
def create_bucket(self, s3_client, bucket_name, region):
pass
def put_object(self, s3_client, bucket_name, source_file_name, object_key):
pass
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Hungry Kid!</title>
<style type="text/css">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Drag and Drop</title>
<style type="text/css">
body {
margin:15px;
padding:0;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Hungry Kid!</title>
<style type="text/css">
@pgchamberlin
pgchamberlin / nbspBetweenLastWords.php
Last active December 14, 2015 05:59
In response to @smashingmag's tweet: https://twitter.com/smashingmag/status/306416073408929792 an alternative method.
<?php
function nbspBetweenLastWords( $text, $minWords = 3 ) {
if (substr_count($text, ' ') >= $minWords - 1) {
return substr_replace($text, '&nbsp;', strrpos($text, ' '), 1);
}
return $text;
}
@pgchamberlin
pgchamberlin / chintz-tooling.md
Last active April 19, 2017 22:03
Chintz: tooling for technology agnostic design systems

Chintz: tooling for technology agnostic design systems

I've been developing a system called Chintz for working with technology-agnostic design systems and pattern libraries. The idea is that you should be able to create web components in a library, and that they can then be directly used in websites built in any language or framework.

Technology agnosticism

If you've been following the hotness then you'll know that everything is written in JSX these days so get over it, but if you've also been around a while you might have noticed that new hot things come and go. New things are often great improvements, but however great they are they tend to be usurped sooner or later by something even better.

Brad Frost's post Managing technology-agnostic design systems describes a systematic solution. The idea is to have a design tier of components, which are converted for each flavour of tech

@pgchamberlin
pgchamberlin / mapcamp2017.md
Created October 7, 2017 08:53
Notes from Map Camp 2017

Maps

Liam Maxwell

  • Gov must move silos -> platforms
  • Introduction of open standards and data
  • Coding in the open means sharing
  • Common standards means common tools
  • Outcome based teams
  • Change needs spend controls
  • Square of despair: procurement, security, legacy, capability