This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Image < ActiveRecord::Base | |
before_create, :set_width_and_height | |
has_attached_file :img, | |
:url => "/system/images/:attachment/:id/:basename.:extension", | |
:path => "#{Rails.root}/public/system/images/:attachment/:id/:basename.:extension" | |
def set_width_and_height | |
# this next line is the magic line | |
geo = Paperclip::Geometry.from_file(img.to_file(:original)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Filename: RAILS_ROOT/lib/paperclip_processors/thumbnail_with_dimensions.rb | |
# Required Configuration in the model | |
# has_attached_file :image, | |
# :styles => { | |
# :thumbnail => { | |
# :geometry => "100x100>", | |
# :format => :png, | |
# :processors => [:thumbnail_with_dimensions], | |
# :mystyle => :thumbnail | |
# }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'cramp' | |
gem 'erubis', '2.6.5' | |
gem 'usher', "0.6.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Package: require('node-asset').Package | |
# Coffee files | |
coffee_package: new Package 'where/you/want/output.js', [ | |
'where/is/coffee/dir' | |
'or/file.coffee' | |
'coffee/type/also/support/file.js' | |
], { | |
type: 'coffee' | |
# Watch for changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'action_dispatch' | |
require 'capybara/rails' | |
require 'capybara/dsl' | |
module RSpec::Rails | |
module IntegrationExampleGroup | |
extend ActiveSupport::Concern | |
include ActionDispatch::Integration::Runner | |
include RSpec::Rails::TestUnitAssertionAdapter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cleaning up and extending the Gemfile | |
remove_file 'Gemfile' | |
create_file 'Gemfile', <<-GEMFILE | |
source 'http://rubygems.org' | |
gem 'rails', '3.2.8' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rack file for local Rubygems server, using YARD | |
require "rubygems" | |
require "yard" | |
libraries = {} | |
Gem.source_index.find_name('').each do |spec| | |
libraries[spec.name] ||= [] | |
libraries[spec.name] << YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :gem) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
if ARGV.size < 2 | |
puts "Usage: #{$0} <src dir> <dest dir> [branch name]" | |
puts " CAUTION! Running without a branch name, it will try to copy all 'local' branches, but this is probably not what you want, and is untested. Copy just those branches you really need." | |
exit | |
end | |
src_repo = File.expand_path(ARGV[0]) | |
dest_repo = File.expand_path(ARGV[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'usb' | |
require 'betabrite' | |
### | |
# Get a betabrite sign: | |
# | |
# http://www.betabrite.com/ | |
# http://www.amazon.com/Brite-Prism-Moving-Message-Display/dp/B000MQAI72 | |
# | |
# Install gems: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'matrix' | |
require './matrix_block_mixin' | |
require './map_reduce' | |
require 'benchmark' | |
def map(key, value) | |
inputs = [] | |
a = value[:a] | |
b = value[:b] |
OlderNewer