Skip to content

Instantly share code, notes, and snippets.

@tommoor
tommoor / gist:1193229
Created September 4, 2011 18:00
Temporary profiling solution for Codeigniter Mongo_db library
<?php
public function get($collection = "")
{
if (empty($collection))
{
show_error("In order to retreive documents from MongoDB, a collection name must be passed", 500);
}
if (isset($this->wheres['_id']) and ! ($this->wheres['_id'] instanceof MongoId))
@tommoor
tommoor / gist:3832472
Created October 4, 2012 09:20
Buffer info/configuration endpoint (WIP)
{
"services":{
"twitter":{
"name":"Twitter",
"character_limit":140,
"schedule_limit":288,
"icons":{
"16":"http:\/\/static.bufferapp.com\/images\/services\/twitter-16x16.png",
"32":"http:\/\/static.bufferapp.com\/images\/services\/twitter-32x32.png",
"64":"http:\/\/static.bufferapp.com\/images\/services\/twitter-64x64.png"
@tommoor
tommoor / gist:4357543
Created December 22, 2012 04:53
500 Server error in HelpScout API.
<?php
try {
$hs = ApiClient::getInstance();
$hs->setKey('REMOVED');
$customers = $hs->getCustomers(1, null, null, null, 'user@domain.com');
// found a single customer for this email address
if ($customers->getCount() == 1)
{
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
@tommoor
tommoor / Secure Buffer button.html
Last active December 11, 2015 03:48
Use the following snippet to create a secure Buffer button on HTTPS pages.
<a href="https://bufferapp.com/add" class="buffer-add-button" data-count="vertical">Buffer</a>
<script type="text/javascript" src="https://d389zggrogs7qo.cloudfront.net/js/button.js"></script>
@tommoor
tommoor / Git branches by activity
Created January 16, 2013 12:56
List git branches in reverse order of activity. An easy way to find and delete unused / old branches
for k in `git branch|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1`\\t$k;done|sort -r
@tommoor
tommoor / mongodb-persist.php
Last active December 11, 2015 10:29
MongoDB persist issue in latest drivers, as this is using the Mongo class rather than MongoClient persist should be ignored rather than throw an exception.
<?php
try {
$connection = new Mongo("mongodb://localhost:27017", array('persist' => 'foo'));
} catch (MongoConnectionException $e) {
print_r($e->getMessage());
}
@tommoor
tommoor / cached.php
Last active December 11, 2015 16:39
Wrapping cache methods in CI
<?php
protected function cached($key, $callback, $life)
{
$this->load->driver('cache', array('adapter' => 'memcached'));
if (!$response = $this->cache->get($key)) {
$response = $callback($this);
if ($response) {
@tommoor
tommoor / response.json
Last active December 12, 2015 05:58
Example PageMunch response v0.1
{
"url": "http:\/\/www.zvents.com\/palmetto_fl\/events\/show\/306476425-nuovo-brides-bridal-expo",
"type": "Event",
"schema": "http:\/\/schema.org\/Event",
"name": "Nuovo Bride's Bridal EXPO at Bradenton Area Convention Center in Palmetto, FL",
"description": "\n\nNuovo Bride's Bridal EXPO\n\n\n\nSunday, Mar 24 12:00p\nto\n4:00p\n\n\n\nBradenton Area Convention Center\nPalmetto,\nFL\n\n\nVisit with 100+ exhibitors, Stroll through cake galleries, Wedding flower galleries, Photography galleries and more! Sample cakes & menus and find your Dream dress. \n\nEnjoy a Runway Fashion Show with all the top local salons. \n\nRegister for giveaways and prizes! Every bride receives a Free Swag Bag. \n\nFree for Brides & Grooms when you register now!\n\n\n",
"image": "http:\/\/www.zvents.com\/dynamic_images\/5\/4\/2\/7\/28237245_184-50x184-50_5.jpg",
"startDate": "2013-03-24T16:00:00Z",
"location": {
"addressLocality": "Palmetto",
@tommoor
tommoor / vimeo.json
Last active December 12, 2015 06:59
PageMunch example response for Vimeo URL
{
"videoQuality": "HD",
"embedUrl": "http:\/\/vimeo.com\/moogaloop.swf?clip_id=58893010",
"duration": "PT00H04M45S",
"width": 720,
"height": 1280,
"playerType": "HTML5 Flash",
"encodingFormat": "MP4",
"uploadDate": "2013-02-04T15:08:24+00:00",
"author": {