Skip to content

Instantly share code, notes, and snippets.

View lassebunk's full-sized avatar

Lasse Bunk lassebunk

View GitHub Profile
@lassebunk
lassebunk / glyphish-convert.rb
Created May 11, 2016 14:20
Ruby script for converting Glyphish SVG files to PDF for vector usage in Xcode
#!/usr/bin/env ruby
require "fileutils"
indir, outdir = ARGV
unless indir && !indir.empty? && outdir && !outdir.empty?
puts "Usage: glyphish-convert.rb <indir> <outdir>"
exit
end
@lassebunk
lassebunk / sunspot_tasks.rake
Last active July 24, 2020 04:10
Reindex Sunspot Solr gracefully
# This task can be used reindex Solr without dropping your index first.
# This is ideal for production environments where a live, working index is critical.
#
# Put this in lib/tasks/sunspot_tasks.rake
namespace :sunspot do
task reindex_gracefully: :environment do
Dir.glob(Rails.root.join('app/models/**/*.rb')).each { |path| require path }
sunspot_models = Sunspot.searchable
@lassebunk
lassebunk / dragonfly_tasks.rake
Last active September 14, 2022 07:18
Migrate all Dragonfly images to Amazon S3 using rake task
# This will move all images and other Dragonfly assets from your local server file system to Amazon S3.
namespace :dragonfly do
task :migrate_to_s3 => :environment do
# Adjust this line to meet your needs:
{ Product => [:image_uid, :other_uid], Page => :image_uid }.each do |klass, col|
puts "Migrating #{klass.table_name}..."
Array(col).each do |col|
klass.where("#{col} != ''").find_each do |instance|
begin
@lassebunk
lassebunk / class.m
Last active January 3, 2016 04:39
Ruby vs. Objective-C
// Objective-C
- (NSMutableArray *)products {
if (_products == nil) {
_products = [[NSMutableArray alloc] init];
}
return _products;
}
@lassebunk
lassebunk / gist:7429427
Created November 12, 2013 11:30
Typhoeus segmentation fault after upgrading to OS X Mavericks
/Users/lassebunk/.rvm/gems/ruby-2.0.0-p0/gems/ethon-0.6.1/lib/ethon/multi/operations.rb:171: [BUG] Segmentation fault
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin13.0.0]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
the more detail of.
➜ ~ sudo rvm install 1.9.2
Password:
Fetching yaml-0.1.4.tar.gz to /Users/lassebunk/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/lassebunk/.rvm/src
Configuring yaml in /Users/lassebunk/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/lassebunk/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/lassebunk/.rvm/usr
gcc-4.2: error trying to exec '/usr/bin/i686-apple-darwin11-gcc-4.2.1': execvp: No such file or directory
Installing Ruby from source to: /Users/lassebunk/.rvm/rubies/ruby-1.9.2-p318, this may take a while depending on your cpu(s)...
Invalid gemspec in [/Library/Ruby/Gems/1.8/specifications/authlogic-3.1.0.gemspec]: invalid date format in specification: "2011-10-19 00:00:00.000000000Z"
Invalid gemspec in [/Library/Ruby/Gems/1.8/specifications/coffee-rails-3.1.0.gemspec]: invalid date format in specification: "2011-08-31 00:00:00.000000000Z"
Invalid gemspec in [/Library/Ruby/Gems/1.8/specifications/execjs-1.2.4.gemspec]: invalid date format in specification: "2011-08-03 00:00:00.000000000Z"
Invalid gemspec in [/Library/Ruby/Gems/1.8/specifications/jquery-rails-1.0.19.gemspec]: invalid date format in specification: "2011-11-26 00:00:00.000000000Z"
Invalid gemspec in [/Library/Ruby/Gems/1.8/specifications/jquery-rails-2.0.1.gemspec]: invalid date format in specification: "2012-02-28 00:00:00.000000000Z"
Invalid gemspec in [/Library/Ruby/Gems/1.8/specifications/json-1.5.4.gemspec]: invalid date format in specification: "2011-08-31 00:00:00.000000000Z"
Invalid gemspec in [/Library/Ruby/Gems/1.8/specifications/libv8-3.3.10.4-x86_64-darwin-11.ge