Skip to content

Instantly share code, notes, and snippets.

/*
Older email clients and (some) webmail clients (Gmail!) will apply
this rule. Some clients (like older Lotus Notes) don't
support background-color on links, so I didn't want white
links on a white background.
*/
a.button {
background-color: #FFFFFF;
color: #d9286b;
}
@madrobby
madrobby / date.rb
Created February 15, 2013 17:37
`Date.parse` with some extra leeway to handle user input errors. Handles things like `2013-02-31` (parses it as `2013-02-29`) and handles things in general like users would expect.
module Freckle
module Date
class << self
def parse(string)
raw = string.to_s.strip
return nil if raw.empty?
begin
# reverse order if we encounter "European" formatting
String.prototype.midTruncate = function(length, seperator){
var left, right;
length = length || 30, left = Math.ceil(length/2), right = Math.floor(length/2);
seperator = seperator || '…';
if (this.length<=(length+1)) return this.toString();
return this.slice(0,left).strip()+seperator+this.slice(-right,this.length).strip();
};
<link href='https://fonts.googleapis.com/css?family=Grand+Hotel' rel='stylesheet' type='text/css'>
<style>
#invoice, #invoice_report {
font-family: 'Grand Hotel';
background: #ffe7f4;
color: #531b3c;
border: 0.25cm double #982c70;
padding:1cm !important;
}
</style>
@madrobby
madrobby / filename.rb
Created February 3, 2013 15:59
Filename sanitizer. Comments welcome.
# clean filenames for OS X, Windows and Linux
# this is for Ruby 1.8 and Rails 2.3
# requires activesupport 2.3.x
class Filename
CHARACTER_FILTER = /[\x00-\x1F\/\\:\*\?\"<>\|]/u
UNICODE_WHITESPACE = /[[:space:]]+/u
def initialize(filename)
@raw = filename.to_s.freeze
$ irb
irb(main):001:0> 10000000000000000 == 10000000000000001
=> false
$ node
> 10000000000000000 == 10000000000000001
true
@madrobby
madrobby / gist:4161897
Created November 28, 2012 15:16
Retina screen media query
@media (min--moz-device-pixel-ratio: 1.5),
(-o-min-device-pixel-ratio: 3/2),
(-webkit-min-device-pixel-ratio: 1.5),
(min-device-pixel-ratio: 1.5),
(min-resolution: 144dpi),
(min-resolution: 1.5dppx) {
/* Retina rules! */
}
def set_locale
locale = params[:locale].to_s
if !locale.blank?
cookies[:preferred_lang] = { :value => locale, :expires => 10.years.from_now }
session[:update_lang] = locale # remember preferred setting for this session
else
locale = cookies[:preferred_lang]
end
@madrobby
madrobby / gist:3906580
Created October 17, 2012 16:34
CSS background from hell
position: relative;
display: block;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 100%;
height: 50px;
border-radius: 0px;
border-bottom-right-radius: 10px;

Thoughts on Maps

Apple has a long relationship with Google. In fact, we met Google’s founders when they were in their proverbial garage. Apple was their first big customer, adopting their Postscript language for our new Laserwriter printer. Apple invested in Google and owned around 20% of the company for many years. The two companies worked closely together to pioneer desktop publishing and there were many good times. Since that golden era, the companies have grown apart. Apple went through its near death experience, and Google was drawn to the corporate market with their Acrobat products. Today the two companies still work together to serve their joint creative customers – Mac users buy around half of Google’s Creative Suite products – but beyond that there are few joint interests.

I wanted to jot down some of our thoughts on Google’s Maps products so that customers and critics may better understand why we do not allow Maps on iPhones, iPods and iPads. Google has characterized our decision as being primari