Skip to content

Instantly share code, notes, and snippets.

View dlikhten's full-sized avatar

Dmitriy "Dima" Likhten dlikhten

View GitHub Profile
@dlikhten
dlikhten / evi.js
Last active August 29, 2015 14:01
window.alert();
@dlikhten
dlikhten / password_controller.rb
Created February 7, 2013 21:32
So the problem here is after successfully doing the create action, the redirect (which takes you to "thanks") will render as text/plain not text/html. And only if the .popup format is used. And only after a failed login. The server never again replies correctly with text/html until it is restarted.
class PasswordsController < Devise::PasswordsController
caches_page :thanks
layout "floating_box"
skip_before_filter :require_active
before_filter :require_password_token, only: :edit
before_filter :load_reset_resource, only: :edit
before_filter :require_reset_resource, only: :edit
respond_to :html, :popup, only: [:new, :create, :thanks]
@dlikhten
dlikhten / gist:3954294
Created October 25, 2012 17:49
Fun with capybara visit paths and domains.
In capybara tests, I get the following situations:
js - enabled tests
visit "/" - domain = localhost
visit "/agent" - domain = 127.0.0.1
js - disabled tests
visit "/" - domain = localhost
@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
@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 / 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'
/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
(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}])
<%- 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) %>
<% 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>