Skip to content

Instantly share code, notes, and snippets.

View joshtronic's full-sized avatar
🪦
Most forks are graves, not gardens

Josh Sherman joshtronic

🪦
Most forks are graves, not gardens
View GitHub Profile
#!/bin/bash
#
# Adobe Air Installer for Ubuntu 64-bit Systems
#
# Pretty sure the name says it all, but if not, here's some more detail. Adobe
# Air is currently only supported on 32-bit Linux systems. Because of this you
# have to jump through some hoops to get it running. Specifically, you need to
# install 32-bit libraries to satisfy the dependencies of Adobe Air. This
# particular script makes it as easy as running a single script.
#
/**
* JJ Slider (jQuery Slideshow) Plug-In
*
* http://github.com/joshtronic/jquery.jjslider
*
* Author: Josh Sherman <josh@crowdsavings.com>
* Copyright (c) 2010 Gravity Boulevard, LLC
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
@joshtronic
joshtronic / gist:1015843
Created June 9, 2011 01:31
Convert SVG XML into PNG
<?php
// Note, $xml is supposed to be SVG XML data
$image = new Imagick();
$image->readImageBlob($xml);
$image->setImageFormat('png24');
header('Content-type: image/png');
ob_clean();
@joshtronic
joshtronic / gist:8640234
Last active January 4, 2016 15:19
Checks your unread message count on your Gmail account from the command line using OSX Keychain Access to store the credentials securely.
export KEYCHAIN_ITEM='email' && curl -u `security find-generic-password -s ${KEYCHAIN_ITEM} | grep 'acct' | cut -c 19- | tr -d '"' | tr -d '\n'`:`security find-generic-password -w -s ${KEYCHAIN_ITEM}` --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "$2\n" if /<(email)>(.*)<\/\1>/;' | wc -l | tr -d ' '
$('[data-plugin]').each(function(element)
{
switch ($(element).data('plugin'))
{
case 'tagsInput':
$(element).tagsInput({ width: 'auto' });
break;
}
});
<?php
$conditions = array('conditions' => array('revision_id' => $recipe_revision->record['id']));
$cache_key = 'RECIPE-' . $recipe_revision->record['id'] . '-';
$recipe_ingredient = new RecipeIngredient($conditions, $cache_key . 'INGREDIENTS');
$recipe_direction = new RecipeDirection($conditions, $cache_key . 'DIRECTIONS');
// Checks that all of the fields are present and not null
if (isset($_POST['username'], $_POST['email'], $_POST['password'])
&& !String::isEmpty($_POST['username'], $_POST['email'], $_POST['password']))
{
// Checks that the username is the correct format
if (strlen($_POST['username']) > 32)
{
$message = 'Usernames may not be more than 32 characters.';
}
elseif (!preg_match('/^[a-z0-9-]+$/i', $_POST['username']))
<?php
class user_create extends AnonymousModule
{
protected $post = array(
'username' => array(
'length:>:32' => 'Usernames may not be more than 32 characters.',
'regex:/[^a-z0-9-]+/i' => 'Usernames may only contain alphanumeric characters or dashes.',
'regex:/^(-.+|.+-)$/' => 'Usernames may not start or end with a dash.',
'regex:/-{2,}/' => 'Usernames may not have two or more dashes in a row.',
<?php
if (isset($_SERVER['HTTP_USER_AGENT'])
&& !String::isEmpty($_SERVER['HTTP_USER_AGENT'])
&& !preg_match('/(Baidu|Gigabot|Googlebot|libwww-perl|lwp-trivial|msnbot|SiteUptime|Slurp|WordPress|ZIBB|ZyBorg)/i', $_SERVER['HTTP_USER_AGENT']))
{
exit('EOF');
session_start();
}
@joshtronic
joshtronic / gist:4228026
Created December 6, 2012 20:25
PICKLES Transactions
<?php
$transaction = new Transaction();
$model1 = new Model1();
$model1->record['foo'] = 'bar';
$model1->queue();
$transaction->queue($model1);