Skip to content

Instantly share code, notes, and snippets.

@hlashbrooke
hlashbrooke / analytics-wordpress.php
Created August 9, 2013 16:26
Segment.io WordPress plugin: Adding filter to identification traits
<?php
$identify = array(
'user_id' => $user->user_email,
'traits' => apply_filters( 'segment_identify_traits', array(
'username' => $user->user_login,
'email' => $user->user_email,
'name' => $user->display_name,
'firstName' => $user->user_firstname,
'lastName' => $user->user_lastname,
'url' => $user->user_url
@marti1125
marti1125 / gist:5042649
Created February 26, 2013 21:59
add buttons.
if (this.index >= w._cards.length-1) {
this.log("on last card, changing next button to submit");
w.changeNextButton(w.args.buttons.submitText, "btn-success");
w.saveAndContinueButton.removeClass("hide");
w.saveAndAddAnotherButton.removeClass("hide");
w._readyToSubmit = true;
w.trigger("readySubmit");
}
else {
@mv
mv / aws.sh
Created November 30, 2012 19:04
AWS Command Line Tools: using MacOS and brew
#!/bin/bash
#
# using ec2 tools
#
# Marcus Vinicius Fereira ferreira.mv[ at ].gmail.com
# 2011-11
###
### programs
@notxarb
notxarb / subnets.txt
Last active May 12, 2016 21:35
Pagodabox CIDR addresses
75.126.19.144/28
75.126.23.16/28
184.173.69.128/28
50.97.157.0/26
75.126.59.16/28
@wkw
wkw / jqm-config.mods.js
Created August 16, 2012 12:05
jQueryMobile and Backbone.js
// see: http://coenraets.org/blog/2012/03/using-backbone-js-with-jquery-mobile/
// for context.
// this modifies original code (above) to also watch for dialogs being hidden
$('div[data-role="page"],div[data-role="dialog"]').live('pagehide', function (event, ui) {
$(event.currentTarget).remove();
});
@solkennedy
solkennedy / ship-api-php-example.php
Created August 6, 2012 18:46
Ship API PHP Example
<?
// Upload image from the filesystem
$ch = curl_init();
$request = array('appkey'=>'YOUR_APPKEY_HERE', 'photo'=>'@/path/to/image.jpg');
curl_setopt($ch, CURLOPT_URL, 'https://snapi.sincerely.com/shiplib/upload');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
@dervalp
dervalp / Birthdate.js
Created January 9, 2012 19:55
Control for Birthdate with Date.js
//reference Date.js
if (!Utilities) var Utilities = {};
$.extend(Utilities,
{
Birthdate : function(lg) {
var Month = {
en : ["January","February","March","April","May","June","July","August","September","October","November","December"],
fr : ["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"]
}
<?php
function i18nPOStrings() {
$locale = str_replace('-', '_', get_instance()->config->item('language_ui')->locale);
//$default = str_replace('-', '_', get_instance()->config->item('language_ui_default')->locale);
$dir = APPPATH . 'language/locale/' . $locale . '/LC_MESSAGES/';
$files = glob($dir . '*.po');
foreach ($files as $file) {
$contents .= file_get_contents($file) or die('Could not read from file.');
@cgilchrist
cgilchrist / replace_text_with_url_param.js
Created February 15, 2011 00:11
Replace some text on your page with the value of a URL parameter
<script type="text/javascript">
var getUrlParams = function() {
var params = {}, hash;
var hashes = decodeURI(window.location.href).replace(/\+/g," ").slice(window.location.href.indexOf('?') + 1).split('&');
for (var i=0; i<hashes.length; i++) {
hash = hashes[i].split('=');
params[hash[0]] = hash[1];
}
return params;
};