Skip to content

Instantly share code, notes, and snippets.

View universal's full-sized avatar

Johannes / universa1 universal

View GitHub Profile
@universal
universal / 1 - checkout_helper.rb
Created March 20, 2012 10:18
Improve Spree's checkout step indicator
# At this checkout step indicator, all the checkout steps are turned into links. But how to
# turn *only* my completed steps into links?
#
# <jammanbo> state_machine has no memory. if you need to determine whether you have been
# in a state you need to design your machine so that that can be determined from the
# current state.
#
# ----------
#
# Expected result:
describe "GET #new" do
before do
@user = User.new
User.stub(:new).and_return(@user)
end
it "authorizes access" do
should_authorize(:new, @user)
get :new
ned
@universal
universal / destroy.js.erb
Created October 19, 2012 10:10 — forked from anonymous/gist:3917294
ajax delete issue
$('#<%= dom_id(@match) %>').fadeOut();
#!/bin/bash
# Favicon and Apple Touch Icon Generator
#
# This bash script takes an image as a parameter, and uses ImageMagick to convert it to several
# other formats used on modern websites. The following copies are generated:
#
# * apple-touch-icon-114x114-precomposed.png
# * apple-touch-icon-57x57-precomposed.png
# * apple-touch-icon-72x72-precomposed.png
public class MyClass
{
public static void main(String args[])
{
System.out.println("Hello World".hashCode());
}
}
=> -862545276
<p>
<b>Comment:</b>
<%= comment.body %>
</p>
<p>
<%= link_to 'Destroy Comment', [comment.post, comment],
:confirm => 'Are you sure?',
:method => :delete %>
</p>
@universal
universal / member.rb
Last active December 23, 2015 23:39 — forked from anonymous/gist:6711528
formatting and mutliple files...
class Member < ActiveRecord::Base
belongs_to :project
belongs_to :users
attr_accessible :project_id, :user_id
end
@universal
universal / member.rb
Last active December 23, 2015 23:49 — forked from anonymous/member.rb
class Member < ActiveRecord::Base
belongs_to :project
belongs_to :users
attr_accessible :project_id, :user_id
end
class Manufacturer < ActiveRecord::Base
def self.selectable
result = []
result << self.joins(:cars).joins(cars: :basic_articles).where(published: true, cars:{published: true}, basic_articles: {published: true, requires_extra: false}).map{ |r| r.id }
result << self.joins(:cars).joins(cars: :basic_articles).joins(cars: [basic_articles: :extras]).where(published: true, cars:{published: true}, basic_articles: {published: true, requires_extra: true}).map{ |r| r.id }
return self.where(id: result)
end
end
@universal
universal / Movi.rb
Last active December 26, 2015 05:29 — forked from bluehallu/Movi.rb
class Movie < ActiveRecord::Base
belongs_to :channel
validate :does_not_overlap, :valid_times
def self.from_xml(xml)
id = xml.attr('id') #parse movie id
channel = Channel.find_by_codename(xml.child.name) #get the channel from db
name = xml.child.xpath('name').text #get name
start_time = parse_time(xml.child.xpath('start_time').text)
end_time = parse_time(xml.child.xpath('end_time').text)