Skip to content

Instantly share code, notes, and snippets.

View ugisozols's full-sized avatar

Uģis Ozols ugisozols

View GitHub Profile
5.times do
sleep 1
if Time.now.to_i.even?
x = [1,2,3].inject([]) do |arr, i|
arr << i
end
end
puts x.inspect
@ugisozols
ugisozols / 0-README.md
Created March 2, 2012 06:15 — forked from ream88/0-README.md
Ruby-1.9.x debugger install script

Ruby-1.9.3 debugger install script

This script will install ruby-debug19 under your current Ruby 1.9.3 environment.

Requirements

  • rbenv

Installation

diff --git a/core/app/assets/javascripts/refinery/boot_wym.js.erb b/core/app/assets/javascripts/refinery/boot_wym.js.erb
index 6e79eba..f712ff6 100644
--- a/core/app/assets/javascripts/refinery/boot_wym.js.erb
+++ b/core/app/assets/javascripts/refinery/boot_wym.js.erb
@@ -158,7 +158,7 @@ var wymeditor_boot_options = $.extend({
+ "</form>"
+ "</div>"
- , dialogPath: "<%= Refinery::Core::Engine.routes.url_helpers.root_path %>refinery/dialogs/"
+ , dialogPath: "<%= Refinery::Core::Engine.routes.url_helpers.admin_dialogs_path %>/"
@ugisozols
ugisozols / gist:2604650
Created May 5, 2012 18:38
application.css
/* Default error colouring */
/* line 3, ../../../../../core/app/assets/stylesheets/refinery/formatting.css.scss */
article, nav, header, footer, aside, hgroup, section {
display: block;
}
/* line 7, ../../../../../core/app/assets/stylesheets/refinery/formatting.css.scss */
div.fieldWithErrors {
display: inline;
}
# Engine - Refinery::Cars::Cars
Rails.application.routes.draw do
root :to => "refinery/cars/cars#index"
mount Refinery::Core::Engine, :at => "/"
end
@ugisozols
ugisozols / gist:2717293
Created May 17, 2012 08:02
how to setup refinery model decorator
# app/decorators/models/refinery/page_decorator.rb
Refinery::Page.class_eval do
def my_method
end
end
diff --git a/core/lib/refinery/extension_generation.rb b/core/lib/refinery/extension_generation.rb
index 1a44565..6e9c83f 100644
--- a/core/lib/refinery/extension_generation.rb
+++ b/core/lib/refinery/extension_generation.rb
@@ -180,9 +180,7 @@ module Refinery
end
def exit_with_message!(message)
- puts ""
- puts message
@ugisozols
ugisozols / page.rb
Created November 14, 2012 12:11
Refinery::Pages::Url
# app/models/refinery/page.rb
# ... code ...
def url
@url ||= Refinery::Pages::Url.build(self)
end
def uncached_nested_url
[parent.try(:uncached_nested_url), to_param.to_s].compact.flatten
@ugisozols
ugisozols / gist:4125166
Created November 21, 2012 14:43
Stop subclassing array
diff --git a/core/lib/refinery/plugins.rb b/core/lib/refinery/plugins.rb
index a22497f..1d8e4ee 100644
--- a/core/lib/refinery/plugins.rb
+++ b/core/lib/refinery/plugins.rb
@@ -1,5 +1,10 @@
module Refinery
- class Plugins < Array
+ class Plugins
+ include Enumerable
+
@ugisozols
ugisozols / gist:4132588
Created November 22, 2012 19:14
Don't depend on Rails' delegate
diff --git a/core/lib/refinery/plugins.rb b/core/lib/refinery/plugins.rb
index 7f7efea..869286a 100644
--- a/core/lib/refinery/plugins.rb
+++ b/core/lib/refinery/plugins.rb
@@ -1,11 +1,16 @@
+require 'forwardable'
+
module Refinery
class Plugins
include Enumerable