Skip to content

Instantly share code, notes, and snippets.

View jasonrhodes's full-sized avatar

Jason Rhodes jasonrhodes

View GitHub Profile
@jasonrhodes
jasonrhodes / testFilesToDelete.php
Created January 4, 2013 16:18
Learning how to mock objects in PHPUnit
<?php
public function setUp()
{
$s3 = $this->getMock("AmazonS3", array("if_bucket_exists"));
$s3->expects($this->once())
->method('if_bucket_exists')
->with($this->equalTo(true));
}
@jasonrhodes
jasonrhodes / mapreducemapreduce.php
Created January 7, 2013 21:08
MOAR MAP REDUCE
<?php
$conversionSets = array(
"100" => array(
array(
"conversions" => 22
),
array(
"conversions" => 8
)
<?php
function sum($a, $b)
{
return $a + $b;
}
function myfunc($input)
{
@jasonrhodes
jasonrhodes / lets-build-a-newshub.md
Last active December 11, 2015 03:29
Draft blog post: We knew we needed a site to bring together all the news, but what should it look like and how should it work?

Let's Build a News Hub!

  • 2011, just started in the office of comm
  • Lauren talked about "the Hub", an RSS firehose of every news item in the JHU universe, and "Johns Hopkins Today", a marketing-driven story telling news site.
  • The two began to merge into one project
  • Dave, then Glenn, then "agile"
  • Realization: this is way more than a website
  • Early drawings
  • Manufacturing metaphor!
  • Structured content pitch?
@jasonrhodes
jasonrhodes / GoogleSearchResultSet.php
Last active December 11, 2015 14:08
Parses an XML Google Search result payload and provides a more human readable API for accessing the attributes.
<?php
class GoogleSearchResultSet
{
/**
* Google XML return documentation found at:
* https://developers.google.com/search-appliance/documentation/46/xml_reference
*
*/
protected $unprocessed = array();
@jasonrhodes
jasonrhodes / search.twig
Created January 23, 2013 19:59
A Twig view to display Google search results (powered by a Google Search Appliance)
<h1>Search</h1>
{% include "partials/search-form.twig" %}
{% if results is defined %}
{% if results.rCount is not defined or results.rCount < 1 %}
<p class="no-results">No results returned for '<strong>{{ query }}</strong>'.</p>
@jasonrhodes
jasonrhodes / searchRoute.php
Last active December 11, 2015 14:08
A Slim PHP route to define and handle a Google search
<?php
$router->set("/search", function () use ($router) {
$results = array();
$perPage = 10;
$paginationInfo = array();
if (isset($_GET["q"])) {
$page = (isset($_GET["page"]) && $_GET["page"] > 1) ? $_GET["page"] : 1;
@jasonrhodes
jasonrhodes / yo-dawg-i-herd-you-like-content.md
Last active December 11, 2015 22:29
Lessons from hypermedia applied to the future of structured content management. Easy.

How will the robot refrigerators put our smashed and structured content back together again?

At Johns Hopkins, we're about to embark on a content strategy adventure led by Ahava Leibtag and her posse at Aha Media Group. Our team has been thinking a lot about content over the past year as we designed and built our news aggregation thingy that we call the Hub. I'm excited to work with Ahava in part because she's passionate about structured content, and as I think about structuring everything on jhu.edu, I start to wonder what we do with it once it's smashed into tiny structured pieces.

This process of breaking big blobs of content into smaller chunks has been on our minds a lot, because at the center of our Hub is an ever-growing database of lovingly smashed-apart content fields (sometimes called "structured content" when people are being extra polite) and a RESTful API to deliver that content to whoever might be interested. Our latest work on that API has us thinking about how to make it more hypermedia-dr

@jasonrhodes
jasonrhodes / theres-a-cache-for-that.md
Created February 15, 2013 20:17
Caching via dependency injection, why APC is great, why you have to cache your API requests, and how it makes your database fast like lightning.

Cache Cache Cache (and cache)

@jasonrhodes
jasonrhodes / why-baltimore.md
Last active December 13, 2015 20:09
A very rough stream of consciousness of my thoughts about Baltimore, tech communities, and how we want different things sometimes.

A few hours ago, I tweeted a few times about the CreateBaltimore event happening today. I said:

I love Baltimore. But reading through some notes from @CreateBaltimore, I wonder if I belong in the tech community here, or understand it. 12:40 PM

and then

For me, the only answer to "Why Baltimore?" is "Because we live here." 12:42 PM

Before I go on, let me clarify -- I don't dislike CreateBaltimore or the Baltimore Tech community. The event sounds positive and I think there's a ton of great stuff going on in our city. I'm incredibly impressed by people like Mike Brenner, Jonathan Julian, and others who give a ton of themselves to push that community forward, providing opportunities for people to get involved, and being incredible resources. So don't let anyone refer to me as "the guy