Skip to content

Instantly share code, notes, and snippets.

View michiels's full-sized avatar

Michiel Sikkes michiels

View GitHub Profile
# First configure your models to use Amazon s3 as storage option and setup the associated S3 config.
# Then add the classes your want to migrate in the klasses array below.
# Then run rake paperclip_migration:migrate_to_s3
# Should work but this is untested and may need some tweaking - but it did the job for me.
namespace :paperclip_migration do
desc "migrate files from filesystem to s3"
task :migrate_to_s3 => :environment do
klasses = [:product] # Replace with your real model names. If anyone wants to this could be picked up from args or from configuration.
klasses.each do |klass_key|
@michiels
michiels / kissmetrics_javascript_twitter_hooks.html
Created June 4, 2011 08:48
Hooking into the Twitter responses for Kissmetrics
<script type="text/javascript">
twttr.events.bind('follow', function(event) {
_kmq.push(['record', 'Follow on Twitter']);
});
</script>
<script type="text/javascript">
twttr.events.bind('tweet', function(event) {
_kmq.push(['record', 'Tweeted the post']);
});
@michiels
michiels / track_facebook_comments_in_kissmetrics.html
Created June 8, 2011 19:02
Tracking Facebook comments in Kissmetrics
<script type="text/javascript">
FB.Event.subscribe('comment.create', function(response) {
_kmq.push(['record', 'Comments on a post with Facebook Comments']);
});
</script>
@michiels
michiels / time_based_property.html
Created June 15, 2011 07:40
Time-based property experiment example
<script type="text/javascript">
_kmq.push(['record', "Viewed Blogpost", {"Displaying share buttons on bottom of single post": "true"}]);
</script>
@michiels
michiels / kioskfolio-embed-code.html
Created July 20, 2011 10:00
Kioskfolio Badge example
<script
src="http://insights.kioskfolio.com/theme_forest_items/[themeforst template id]/badge.js"
data-ref="michiels"
id="kioskfolio-item-badge">
</script>
@michiels
michiels / attributes-default.rb
Created December 9, 2011 20:28
passenger-nginx default recipe
default[:ree][:version] = "1.8.7-2011.03"
default[:nginx][:version] = "1.1.10"
default[:passenger][:version] = "3.0.11"
case platform
when "debian","ubuntu"
set[:nginx][:dir] = "/etc/nginx"
set[:nginx][:log_dir] = "/var/log/nginx"
set[:nginx][:user] = "www-data"
set[:nginx][:binary] = "/usr/sbin/nginx"
module GroundControl
class BuilderTest < Test::Unit::TestCase
def setup
if File.exists?(File.expand_path("builds/cool_rails_project"))
FileUtils.rm_r(File.expand_path("builds/cool_rails_project"))
end
@builder = Builder.new("cool_rails_project", {"git" => "test/repositories/dot_git_rails"}
def test_build_creates_workspace_directories
@builder.build
assert File.exists?(File.expand_path("builds/cool_rails_project")), "Expected directory builds/cool_rails_project to exist."
end
module GroundControl
class Builder
def new(project_name, config)
@workspace = File.expand_path(File.join("builds", project_name))
end
def build
FileUtils.mkdir_p(@workspace)
end
end
def test_build_clones_the_repository
@builder.build
assert File.exists?(File.expand_path("builds/cool_rails_project/README")), "Expected builds/cool_rails_project/README to exist after git clone"
end