Skip to content

Instantly share code, notes, and snippets.

View edzhelyov's full-sized avatar

Evgeni Dzhelyov edzhelyov

  • Sofia, Bulgaria
View GitHub Profile
@edzhelyov
edzhelyov / product.rb
Created September 26, 2011 13:54
Product initialization
class Product < ActiveRecord::Base
belongs_to :product_type
has_many :product_attributes, :extend => FindersByAtrributeName
def initialize(attributes = nil)
super
define_dynamic_accessors
end
def define_dynamic_accessors
SVG.draw do
group do
fill :red
nested do
circle ...
end
end
end
$(function() {
$('select[data-nested-select]').each(function() {
var select = $(this),
groupName = select.data('nested-select'),
optgroups = select.find('optgroup'),
options = select.find('optgroup option'),
groupSelect = $('<select>'),
promptOption = makeOption(groupName, null, false);
groupSelect.append(promptOption);
@edzhelyov
edzhelyov / bg.yml
Created June 22, 2011 08:29
Simple I18n templating
This is the default title: Това е по подразбиране
Project title: Име на проекта
@edzhelyov
edzhelyov / sequel_display.rb
Created June 8, 2011 12:41
Strange behavior for sequel model
class Laptop < Sequel::Model
end
l = Laptop.new
l.columns
[:id, :hdd, :display]
l.hdd
=> nil
l.display
@edzhelyov
edzhelyov / 001_create_laptops.rb
Created June 7, 2011 12:54
Sequel migration helpers
module Helper
def create_product(name)
create_table name do
primary_key :id
String :name, :null => false
end
end
end
Sequel.migration do
@edzhelyov
edzhelyov / app.rb
Created March 8, 2011 14:01
Sinatra inline templates
require 'haml'
get '/' do
haml :overview
end
__END__
@@ overview
%html