Skip to content

Instantly share code, notes, and snippets.

View ugisozols's full-sized avatar

Uģis Ozols ugisozols

View GitHub Profile
@ugisozols
ugisozols / gist:1027992
Created June 15, 2011 20:13
Search Psych::SyntaxError
# This will help you trace .yml file which containts Psych::SyntaxError
require "rubygems"
require "psych"
$LOAD_PATH.unshift(File.dirname(__FILE__))
# specify your locales folder in Dir.glob("*") with relative path from this file
Dir.glob("*").sort.each do |file|
begin
%w(title menu_title).each do |column|
pages = pages.joins(:translations).select(
"#{translation_class.table_name}.#{column} as page_#{column}"
).where("#{translation_class.table_name}.#{column} IS NOT NULL")
end
def self.search_filter(name,manufacture_id,product_type_id)
f_manufacture_id = manufacture_id
f_manufacture_id = f_manufacture_id.join(', ') unless manufacture_id.nil?
result = order("id DESC")
result = result.where("name LIKE ?", "%#{name}%") unless name.empty?
result = result.where("manufacture_id IN (?)", f_manufacture_id) unless manufacture_id.nil?
result = result.where(:product_type_id => product_type_id) unless product_type_id.blank?
result
@ugisozols
ugisozols / gist:1467105
Created December 12, 2011 13:19
Refinery CMS specs using minitest
# Refinery CMS Core RSpec specs converted to MiniTest::Spec
# spec/minitest_helper.rb
require "minitest/spec"
require "minitest/autorun"
require "mocha"
ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment", __FILE__)
@ugisozols
ugisozols / gist:1600844
Created January 12, 2012 14:32
Refinery::Blog routes
Refinery::Core::Engine.routes.draw do
# frontend
namespace :blog do
root :to => "posts#index"
resources :posts
end
# backend
namespace :blog, :path => "" do
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