Skip to content

Instantly share code, notes, and snippets.

@ryanbattles
ryanbattles / mobi-css.css
Created January 9, 2016 19:22
Custom CSS for Kindle Ebooks
html { text-rendering: optimizeLegibility !important; font-family: georgia, serif; }
h1, h2, h3 { -webkit-hyphens: none !important; font-family: Helvetica, sans-serif; }
h1 { page-break-before: always !important; }
h1, h2, h3, h4, h5, h6 { page-break-after: avoid !important; }
/* p + p { margin:0; text-indent:1.5em; } */
p {
margin-top:1.4em;
margin-bottom:1.4em;
text-align:left;
@ryanbattles
ryanbattles / referral-tracking-for-app.js
Created November 16, 2015 16:56
Sets referral cookies to Intercom.io
window.intercomSettings = {
...
"harpoon_referrer" : $.cookie('harpoon_referrer'),
"utm_source" : $.cookie('utm_source'),
"utm_medium" : $.cookie('utm_medium'),
"utm_term" : $.cookie('utm_term'),
"utm_content" : $.cookie('utm_content'),
"utm_campaign" : $.cookie('utm_campaign')
};
@ryanbattles
ryanbattles / referrer-tracking.js
Created November 16, 2015 16:51
Tracking Referrers
/* --------------------------------------------------
:: Track Referrers
-------------------------------------------------- */
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
@ryanbattles
ryanbattles / gist:5842427
Created June 22, 2013 20:18
Changing the location of the OS X Screenshots
defaults write com.apple.screencapture location ~/Screenshots
killall SystemUIServer
@ryanbattles
ryanbattles / gist:5842394
Created June 22, 2013 20:04
Changing the screenshot format on OS X
defaults write com.apple.screencapture type image_format
killall SystemUIServer
@ryanbattles
ryanbattles / gist:5705281
Last active December 18, 2015 01:39
Statamic .htaccess
RewriteEngine On
# secure site files
RewriteRule ^(_app) - [F,L]
RewriteRule ^(_config) - [F,L]
RewriteRule ^(_content) - [F,L]
RewriteRule ^(.*).yml$ - [F,L]
RewriteRule ^(.*).yaml$ - [F,L]
RewriteRule ^(.*).html$ - [F,L]
RewriteRule ^(.*/)?\.git+ - [F,L]
@ryanbattles
ryanbattles / gist:5662760
Last active December 17, 2015 19:49
Forum-subscriptions template fancybox code
<script type="text/javascript">// <![CDATA[
if (/forum-subscriptions/.test(self.location.href)){window.location = "/forums"}
// ]]></script>
{exp:forum_subscribe:forum_single forum_id="{segment_3}"}
<h2>{forum_name}</h2>
{if subscribed}
<strong>SUBSCRIBED</strong> - <a href="{forum_subscribe_url}">Click to Unsubscribe</a>
{if:else}
<strong>NOT SUBSCRIBED</strong> - <a href="{forum_subscribe_url}">Click to Subscribe</a>
{/if}
<h4><strong><a title="{forum_name}" href="{path:viewforum}">{forum_name}</a></strong></h4>
{if logged_in} <a class="fancybox-forum" href="/resources/forum-subscriptions/&lt;?php $tokens = explode('/', '{path:viewforum}'); echo $tokens[sizeof($tokens)-2]; ?&gt;"><small>Manage Subscription</small></a> {/if} {if forum_description}
<p class="fm-description">{forum_description}</p>
{/if}
@ryanbattles
ryanbattles / RSS Feed
Created January 24, 2012 01:39
RSS Feed
{!--
1. THE CHANNEL AND FIELD NAMES NEED TO BE CHECKED FOR ACCURACY
2. THE DYNAMIC LINK PATHS NEED TO BE CHECKED FOR ACCURACY
--}
{exp:rss:feed channel="news"}
<?xml version="1.0" encoding="{encoding}"?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
@ryanbattles
ryanbattles / Download site as .zip
Created December 17, 2011 19:36
Download site as .zip
<!--http://stackoverflow.com/questions/1334613/how-to-recursively-zip-a-directory-in-php-->
<?php
function Zip($source, $destination)
{
if (!extension_loaded('zip') || !file_exists($source)) {
return false;
}
$zip = new ZipArchive();