Posted on Nov 15, 2012
by Ramon T.
One of my favorite development tools is Rake. Not so long ago I discovered how great this tool is and started using it for automating development chores.
The Rakefile of a static site project would look something like this:
require "s3"
require "mimemagic"
desc "Deploys the site to S3"
task :upload do |t, args|
service = S3::Service.new(:access_key_id => "...",
:secret_access_key => "...")
bucket = service.buckets.find("mybucket")
files = Dir['*.html'].to_a
files += Dir['css/*.css'].to_a
files += Dir['js/*.js'].to_a
files += Dir['img/*.*'].to_a
files.each do |source|
object = bucket.objects.build(source)
object.content = File.open(source)
object.content_type = MimeMagic.by_path(source)
object.save
puts "Uploaded https://#{bucket.name}.s3.amazonaws.com/#{source}"
end
end
Dependency Management
To manage our dependencies we will use Bundler. The Gemfile should look something like this:
source "http://rubygems.org"
gem "s3"
gem "mimemagic"
Comments
Posted on Nov 12, 2012
by Ramon T.
SVGs are awesome, but Android's browser didn't support them until version 3.0, and since 2.x devices represent more than 50% of Android's market share it is still important to provide a fallback.
Sass Mixins FTW
One of my favorite features of Sass are mixins, they let you reuse chunks of CSS code and keep things DRY. The mixin we created looks something like this:
@mixin svg-background($name, $w, $h) {
background: url('../images/#{$name}.svg') no-repeat;
background-size: $w $h;
.no-svg & {
background-image: url('../images/png/#{$name}.png');
}
}
And can be easily included:
#brush-selector {
.pencil {
@include svg-background('pencil', 15px, 8px);
}
}
This will generate something that looks like:
#brush-selector .pencil {
background: url("../images/pencil.svg") no-repeat;
background-size: 15px 8px;
}
.no-svg #brush-selector .pencil {
background-image: url("../images/png/pencil.png");
}
Feature Detection
For detecting whether or not SVG is supported we can use Modernizr or roll out our own. I decided to roll out my own to keep it lightweight.
$(document).ready(function () {
var supportsSVG = document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1');
if (!supportsSVG) {
$('body').addClass('no-svg');
}
});
Comments
Posted on Aug 20, 2012
by Ramon T.
HTML:
<a href="size-chart.pdf" data-track="Size Chart">Size Chart</a>
JavaScript:
$(document).ready(function () {
$('a[data-track]').on('click', function (e) {
var label = $(this).attr('data-track');
_gaq.push(['_trackEvent', 'Links', 'Click', label]);
});
});
-R
Comments
Posted on Dec 24, 2011
by Ramon T.
Asked and answered a few times on the Internets. I decided to put the solution on a nice Objective-C category and push it to GitHub.
UIScrollView+PageNumber on GitHub
Comments
Posted on Jun 16, 2010
by Ramon T.
I'm currently working on an iPhone app using cocos2d for iPhone and I just ran across Particle Designer, an awesome OSX app by the 71Squared guys.
The app allows you to create particle emitters by adjusting parameters.

The generated emitters can then be exported into plist files which can be loaded into a cocos2d scene with a couple lines of code:
CCQuadParticleSystem *particles = [CCQuadParticleSystem particleWithFile:@"fireball.plist"];
[self addChild:particles];
-R
Comments