Skip to content

Instantly share code, notes, and snippets.

View giltotherescue's full-sized avatar

Gil Hildebrand giltotherescue

View GitHub Profile
@giltotherescue
giltotherescue / percent-change.php
Created February 24, 2012 15:19
Calculate Percentage Change
<?
/**
Calculates the percentage change between two numbers.
Useful for showing how much traffic has changed from one time period to the next.
*/
$percentChange = function ($cur, $prev) {
@giltotherescue
giltotherescue / freebase.php
Created May 22, 2012 21:59
Search freebase
<?
$nouns = array(
'/film/film' =>
array(
'possessives' => array('directed_by', 'starring')
'adjectives' => array('genre')
),
'/music/album' => array(...)
);
<?
$url .= '{ "id": "' . $mid . '", "/music/album/artist": [{"mid" : [],"name" : null}], "/music/album/genre": [{}], "/music/album/release_date": null }';
if ($res = ApplicationHelper::rest(array('url' => $url))) {
if ($res->result) {
$body = json_decode($res->body);
$item = (array) $body->result;
foreach ($item['/music/album/artist'] as $p) {
$poss[] = array('type' => 'Artist', 'mid' => $p->mid[0], 'name' => $p->name);
<?
preg_match_all("#[\"|']http://the.squidoocdn.com/(.+[\.v[\d]+]?\.css)[\"|']#", file_get_contents($argv[1]), $css);
print_r($css);
preg_match_all("#[\"|']http://the.squidoocdn.com/(.+[\.v[\d]+]?\.js)[\"|']#", file_get_contents($argv[1]), $js);
print_r($js);
@giltotherescue
giltotherescue / hullagraph.php
Created January 28, 2013 19:18
Replace line 448 and below with this code if you want to rename the Source and Original stacks based on the title of the parent postcard.
<?
} else if ($node['parent']->getProperty('type') == 'meta') {
if (in_array($node['parent']->getProperty('parent'), array('Source', 'Original'))) {
$parent_mod = Module::getModuleById($node['adjective']->getProperty('title'));
$new_stack['title'] = escapeForDisplay($parent_mod->lens_module_title);
}
$new_stack['url'] = implode('/', array(
'stacks',
strtolower($this->getNoun(true, $node['parent']->getProperty('parent'))),
urlencode(strtolower($node['parent']->getProperty('title'))),
$orig = Portfolio::findOrFail(Input::get('copy_portfolio'));
$portfolio = $orig->replicate();
$portfolio->title = Input::get('title');
$portfolio->push();
foreach ($orig->authors as $a)
{
$portfolio->authors()->attach($a);
}
if ($portfolio = DB::transaction(function() {
$orig = Portfolio::findOrFail(Input::get('copy_portfolio'));
$orig->load('authors', 'audiences', 'editorComment', 'uploads');
$portfolio = $orig->replicate();
$portfolio->title = Input::get('title');
$portfolio->push();
foreach ($orig->authors as $a)
<?
/*
==== Custom Google Drive Wrapper ====
By: Gil Hildebrand (https://github.com/giltotherescue)
Google Drive authentication setup instructions:
https://developers.google.com/api-client-library/php/auth/service-accounts
function whitelist($parent, $whitelist = null) {
global $drive, $shared_folder;
if (!$whitelist) {
$whitelist = array($parent);
}
$search = $drive->search("'$parent' in parents");
foreach ($search->files as $file) {
@giltotherescue
giltotherescue / casting_notices.php
Created December 2, 2015 19:56
explanation text
<div class="panel panel-default" style="float: right; width: 45%">
<div class="panel-heading">Unavailable</div>
<div class="panel-body">
<ul style="font-size:12px;color:#666666;list-style:disc;">
<li>Means you match the criteria for this character, and are interested in being booked for it, but you are unavailable for the shooting date(s).</li>
<li>You may be notified if the shooting date(s) for this character change.</li>
<li>Will NOT exclude you from any other casting requests.</li>
<li>Will NOT mark your calendar as UNAVAILABLE.</li>
<li>You WILL still receive casting notifications for other jobs on the date(s) above.</li>
</ul>