Skip to content

Instantly share code, notes, and snippets.

View simi's full-sized avatar
🇨🇿

Josef Šimánek simi

🇨🇿
View GitHub Profile
@simi
simi / route_problem.rb
Created April 19, 2011 16:21
Routing problem :(
# rake routes:
customer_zone_order_messages POST /zakaznicka_zona/orders/:order_id/messages(.:format) {:action=>"create", :controller=>"customer_zone/messages"}
# routes.rb:
scope(:path => 'my_path', :module => :customer_zone, :as => 'customer_zone') do
resources :orders, :only => :show do
resources :messages, :only => :create
end
end
@simi
simi / tutorial.rb
Created June 9, 2011 15:14
Localize refinery engine
# First, you need to specify translated fields in your model
# model.rb
translates :text, :title
# make translation migration (stolen from https://github.com/svenfuchs/globalize3)
class CreatePosts < ActiveRecord::Migration
def self.up
Post.create_translation_table! :title => :string, :text => :text
@simi
simi / factories.rb
Created June 28, 2011 12:31 — forked from technicalpickles/factories.rb
Paperclip factory_girl macro working with Rails 3.1rc4
Factory.define :application do |factory|
factory.attachment(:sample, "public/samples/sample.doc", "application/msword")
end
@simi
simi / dsl_spec.rb
Created October 14, 2011 13:36
dsl example
@jane = Factory(:user)
@reward = Factory(:reward, :name => 'Invite friends', :points => 50, :every => 1.day)
@jane.can_achieve?(:invite_friends).should be true
@jane.achieve!(:invite_friends)
@jane.points.should be 50
@jane.can_achieve?(:invite_friends).should be false
@jane.time_to_unlock(:invite_friends).should be < 1.day
@simi
simi / rails.rb
Created October 17, 2011 12:59
Rails 3.1.1 Webrick with SSL support
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
require 'rubygems'
require 'rails/commands/server'
require 'rack'
require 'webrick'
require 'webrick/https'
module Rails
@simi
simi / gist:1443510
Created December 7, 2011 16:39
Travis Opera broken
Uncaught exception: RangeError: Maximum recursion depth exceeded
Error thrown at line 16, column 21800 in <anonymous function: type>(a) in http://travis-ci.org/assets/application-84208c4b20a5b796c07724c8b7b89dc3.js:
return a==?String(a):J[D.call(a)]||"object"
called from line 16, column 21950 in <anonymous function: isPlainObject>(a) in http://travis-ci.org/assets/application-84208c4b20a5b796c07724c8b7b89dc3.js:
if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))
called from line 16, column 19126 in <anonymous function: e.fn.extend>() in http://travis-ci.org/assets/application-84208c4b20a5b796c07724c8b7b89dc3.js:
l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.isPlainObject(d)?d:{},i[c]=e.extend(l,h,f)):f!==b&&(i[c]=f)
called from line 16, column 19126 in <anonymous function: e.fn.extend>() in http://travis-ci.org/assets/application-84208c4b20a5b796c07724c8b7b89dc3.js:
l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.
@simi
simi / gist:1718706
Created February 1, 2012 19:11
Try edge refinery
gem install rails
rails new retrorubies -m https://github.com/resolve/refinerycms/raw/master/templates/refinery/edge.rb
@simi
simi / refinery-test.sh
Last active September 30, 2015 04:07
Try edge refinery
gem install rails
rails new retrorubies -m http://refinerycms.com/t/edge
cd retrorubies
rails s
@simi
simi / Gemfile
Created February 7, 2012 14:32
Refinery + Twitter Bootstrap WIP
source 'https://rubygems.org'
gem 'rails', '3.2.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
@simi
simi / api.rb
Created February 22, 2012 17:08
Test API
require 'spec_helper'
require 'rack/test'
describe Api::Server do
include Rack::Test::Methods
def app
::Jimson::Server.new(::Api::Server.new)
end