Skip to content

Instantly share code, notes, and snippets.

View sevos's full-sized avatar

Artur Roszczyk sevos

View GitHub Profile
@sevos
sevos / gist:193079
Created September 24, 2009 21:54
Example recipe for RoRDevToolkit
installation_unit "postgres",
:description => "Install PostgreSQL server, PGAdmin3 and Ruby&Rails adapters" do |i|
i.install_system_package "postgres"
i.step "First start PostgreSQL server", :supported => :fedora do |s,i|
s.surun "service postgresql initdb"
s.surun "service postgresql start"
end
i.step "Run console to set default postgres password" do |s,i|
s.info "When you see"
s.info "postgres=# prompt type:"
module Animal
def self.included(base)
class << base
def method_added(name)
unless (@wrapped_methods ||= []).include? name
@wrapped_methods.push name
puts "Defined #{name}"
wrap_method name
end
end
upstream logo_contest_cluster {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name logo-contest.eax.pl;
access_log /home/sevos/apps/logo-contest/log/access.log;
error_log /home/sevos/apps/logo-contest/log/error.log;
class MethodClass
def initialize; @test = 1; end
def test
@test
end
end
class ReaderClass
attr_reader :test
def initialize; @test = 1; end
@sevos
sevos / gist:805849
Created February 1, 2011 13:29
spree
def create_user_session(data)
@user_session = UserSession.new(data)
@user_session.save do |result|
if result
# Should restore last uncompleted order and add current(guest) order to it, if exists.
order = @user_session.record.orders.last(:conditions => {:completed_at => nil})
if order
if (session[:order_token] && guest_order = Order.find(:first, :conditions => {:token => session[:order_token], :user_id => nil, :completed_at => nil}))
guest_order.line_items.each do |line_item|
order.add_variant(line_item.variant, line_item.quantity)
@sevos
sevos / authentications_controller.rb
Created February 10, 2011 20:40
Spec file for authentications controller used in OmniAuth integration
class AuthenticationsController < ApplicationController
before_filter :authenticate_user!, :only => :destroy
def create
omniauth = request.env['omniauth.auth']
authentication = Authentication.find_by_provider_and_uid(omniauth["provider"], omniauth["uid"])
if current_user
if authentication && authentication.try(:user) != current_user
flash[:error] = I18n.t("This %{provider} account is already connected to another account in our service", :provider => authentication.provider)
elsif authentication.nil?
describe "Activity form" do
let(:user) { Factory(:user) }
before { sign_in user.email, user.password }
describe "entering activity" do
before do
@enter = lambda do |what, duration, project=""|
within("#activity_form") do
fill_in "What?", :with => what
fill_in "How long?", :with => duration
@import clearfix.sass
$grid_width: 1200px
$grid_glue: 10px
$grid_boxes: 24
=grid-container
+clearfix
padding:
left: 0px
class DailyStatsReport < KPI::Report
def users
result 'Users', User.count, :description => 'Total users count'
end
def premium_users
result 'Premium users', User.premium.count
end
def premium_users_percentage
!!!
%html
%head
%title
Zrzuta na...
= yield :title
= stylesheet_link_tag "application"
= javascript_include_tag "application"
= csrf_meta_tags