Skip to content

Instantly share code, notes, and snippets.

View samrayner's full-sized avatar

Sam Rayner samrayner

View GitHub Profile
- (void)displayError:(NSError *)error
{
[self displayAlertWithTitle:@"Error" message:[error description]];
}
- (void)displayAlertWithTitle:(NSString *)title message:(NSString *)message
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title
message:message
delegate:nil
#CSS
body:after {
position: absolute;
width: 0;
height: 0;
overflow: hidden;
visibility: hidden;
}
@media (max-width: 768px) {
class FluidVideos
@init: (container=null, $videos=null) ->
$videos ||= $("iframe[src*='vimeo.com'], iframe[src*='youtube.com']")
$videos.each ->
$(this)
.data('aspectRatio', this.height/this.width)
.removeAttr('height')
.removeAttr('width')
class Tableless
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :new_record
def initialize(attributes={})
self.new_record = attributes.blank?
attributes && attributes.each do |name, value|
.valign-outer {
&::before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -0.3em; //adjusts for spacing
}
.valign-inner {
@samrayner
samrayner / singleton.php
Created September 5, 2011 11:53
Singleton method
public static $instance;
public static function get_instance() {
$class = get_class(this);
if(!self::$instance)
self::$instance = new $class();
return self::$instance;
}
@samrayner
samrayner / splash.js
Created March 17, 2012 12:55
Serve splash images for iPhone/iPad models
(function () {
var width = 320; //default to non-retina iPhone
var height = 460;
if(navigator.platform === 'iPad') {
if(window.orientation === 90 || window.orientation === -90) {
width = 1024; //landscape
height = 748;
}
else {
@samrayner
samrayner / shownotes.scpt
Created August 28, 2012 10:47
Open link list for the 5by5 show currently playing in iTunes
tell application "System Events"
set itunesRunning to count of (every process whose name is "iTunes")
if itunesRunning is 0 then return
end tell
tell application "iTunes"
if player state is stopped then return
set shows to {{title:"Hypercritical", slug:"hypercritical"}, {title:"The Talk Show", slug:"talkshow"}, {title:"Build and Analyze", slug:"buildanalyze"}, {title:"After Dark", slug:"afterdark"}, {title:"The Pipeline", slug:"pipeline"}, {title:"5by5 Specials", slug:"specials"}, {title:"Back To Work", slug:"b2w"}, {title:"Mac Power Users", slug:"mpu"}, {title:"The Incomparable", slug:"incomparable"}, {title:"The Cocktail Napkin", slug:"tcn"}, {title:"Latest in Paleo", slug:"paleo"}, {title:"Critical Path", slug:"criticalpath"}, {title:"The Big Web Show", slug:"bigwebshow"}, {title:"Content Talks", slug:"contenttalks"}, {title:"Founders Talk", slug:"founderstalk"}, {title:"The Ihnatko Almanac", slug:"ia"}, {title:"Geek Friday", slug:"geekfriday"}, {title:"Internet Superhero", slug:"superhero"}, {title
@samrayner
samrayner / open-in-chrome.scpt
Created August 28, 2012 10:50
Open Safari tab in Google Chrome
tell application "Safari" to set currentURL to URL of current tab of window 1
tell application "Google Chrome"
activate
delay 0.2
if (exists window 1) and (URL of active tab of window 1 is "chrome://newtab/") then
tell window 1 to set URL of active tab to currentURL
else
open location currentURL
end if
end tell
@samrayner
samrayner / toggle-invisible.sh
Created August 28, 2012 10:45
Toggle invisible files in OS X
if [ `defaults read com.apple.finder AppleShowAllFiles` == 1 ]
then
defaults write com.apple.finder AppleShowAllFiles -bool false
else
defaults write com.apple.finder AppleShowAllFiles -bool true
fi
killall Finder