Skip to content

Instantly share code, notes, and snippets.

View dlikhten's full-sized avatar

Dmitriy "Dima" Likhten dlikhten

View GitHub Profile
<%
mode = 0
mode |= 1 if local_assigns.include?(:phone)
mode |= 2 if local_assigns.include?(:location)
suffix = [ '', '_dual', '_dual', '_triple' ][ mode ]
%>
<ul class="profile_info<%= suffix>">
<li><%= link_to(fb_name(owner, :use_you => false, :linked => false), owner) %></li>
<% if mode == 1 %>
<li><%= location %></li>
<% suffix = [ '_triple', '_dual', '' ] %>
<ul class="profile_info<%= yield :suffix %>">
<li><%= link_to(fb_name(owner, :use_you => false, :linked => false), owner) %></li>
<% if local_assigns.include?(:phone) %>
<li class="phone"><%= phone %></li>
<% suffix.pop %>
<%end%>
<% if local_assigns.include?(:location) %>
<li><%= location %></li>
<% suffix.pop %>
class Billing < ActiveRecord::Base
has_many :addresses
has_many :billing_addresses, :conditions => {:address_type => 'billing'}, :class_name => "Address"
has_many :mailing_addresses, :conditions => {:address_type => 'mailing'}, :class_name => "Address"
end
<% division = f.object %>
<div class="division_wrap to_remove">
<%= f.error_messages %>
<div class="division">
<h4 class="division_name_edit inline"><%=h division.name %></h4>
<%= f.hidden_field :id %>
<%= f.hidden_field :name %>
<% if division.editable? %>
<a href="#" class="edit_link">Edit</a>
<%- semantic_form_for(@doctor) do |form| -%>
<!-- if i comment this one out, the second will show -->
<%- form.semantic_fields_for :user_roles do |role_form| -%>
<%- role_form.semantic_fields_for :user do |user_form| -%>
<%= user_form.input(:email) %>
<%- end -%>
<%- end -%>
<!-- this will not render unless the prev is commented out -->
<%- form.semantic_fields_for :npi_record do |npi_form| -%>
<%= npi_form.input(:npi_number) %>
(defn map-select [row selector]
(apply str (concat (interpose "\t" (selector row)) "\n")))
(defn tsv [rows]
(let [header (map-select (first rows) keys)
rows (apply str (for [row rows]
(map-select row vals)))]
(str header rows)))
; => (def p [{"a" 34 "b" 234 "c" 234} {"a" 234 "b" 234 "c" 24}])
/home/zeep/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find rails (>= 0) amongst [minitest-1.6.0, rake-0.8.7, rdoc-2.5.8] (Gem::LoadError)
from /home/zeep/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /home/zeep/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems.rb:1195:in `gem'
from /home/zeep/.rvm/gems/ruby-1.9.2-p290/bin/rails:18:in `<main>'
/home/zeep/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find rack (>= 0) amongst [minitest-1.6.0, rake-0.8.7, rdoc-2.5.8] (Gem::LoadError)
from /home/zeep/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /home/zeep/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems.rb:1195:in `gem'
from /home/zeep/.rvm/gems/ruby-1.9.2-p290/bin/rackup:18:in `<main>'
/usr/bin/env: ruby: No such file or directory
@dlikhten
dlikhten / backbone-relational-issue72-spec.js
Created March 17, 2012 06:22
Problem with Backbone Relational (issue 72)
var Location = Backbone.RelationalModel.extend({
});
var LocatableA = Backbone.RelationalModel.extend({
relations: [{
type: "HasMany",
key: 'locations',
relatedModel: Location,
reverseRelation: {
key: 'locatable'
@dlikhten
dlikhten / Data Logs
Created October 1, 2012 01:02
Rails won't read this one
This POST is ignored by rails completely, It just posts and authenticity is rejected, the "_method" is rejected so rails can't rout properly, etc.
Rails 3.2.8
Thin
Both local & heroku have this problem.
------WebKitFormBoundarymOqg5iqQUYsBo0SI
Content-Disposition: form-data; name="utf8"
✓
@dlikhten
dlikhten / gist:3827497
Created October 3, 2012 15:15
Pub/Pri class methods in ruby
class Herp
class << self
private
def foo
"foo"
end
public
def bar
"bar"
end