Skip to content

Instantly share code, notes, and snippets.

@jurikern
jurikern / gist:5191521
Created March 18, 2013 22:41
Login with binded backbone
class Application.Views.Users.Login
@bindedWith: (selector) ->
$(selector).each ->
Application.Views.Users.Login($(@))
constructor: (@container) ->
_.extend(@, Backbone.Events)
@initForm()
initForm: =>
@jurikern
jurikern / gist:4524835
Created January 13, 2013 16:06
Compiling Objective-C Files an Linux (Ubuntu)
Before:
sudo apt-get -y install gnustep
sudo apt-get -y install gnustep-devel
sudo apt-get -y install build-essential
sudo apt-get -y install gobjc
sudo apt-get -y install gnustep-make
sudo apt-get -y install libgnustep-base-dev
Compiling for one source file (For example main.m):
gcc `gnustep-config --objc-flags` main.m -o hello -I /usr/include/GNUstep/ -L /usr/lib/GNUstep/ -lgnustep-base
@jurikern
jurikern / gist:4473824
Last active December 10, 2015 18:18
How update rbenv(ruby-build) with ruby versions list on MAC OS X.
before:
command: rbenv install 1.9.3-p362
output: ruby-build: definition not found: 1.9.3-p362
hack:
command: brew unlink ruby-build
output: Unlinking /usr/local/Cellar/ruby-build/20121120... 4 links removed
command: brew update
@jurikern
jurikern / gist:3973497
Created October 29, 2012 13:18
ActionController::Metal#session delegated to @_request.session, but @_request is nil
2012-10-29T13:15:49Z 4284 TID-oxp71xhu0 XmlFeedWorker MSG-oxp7irbuk INFO: start
2012-10-29T13:15:56Z 4284 TID-oxp71xhu0 XmlFeedWorker MSG-oxp7irbuk INFO: fail: 6.626 sec
2012-10-29T13:15:56Z 4284 TID-oxp71xhu0 WARN: {"retry"=>true, "queue"=>"default", "class"=>"XmlFeedWorker", "args"=>[], "error_message"=>"ActionController::Metal#session delegated to @_request.session, but @_request is nil: #<TemplatesController:0x007ff61b9f3788 @_routes=nil, @_action_has_layout=true, @_headers={\"Content-Type\"=>\"text/html\"}, @_status=200, @_request=nil, @_response=nil, @_prefixes=[\"templates\", \"application\"], @_config={}, @_lookup_context=#<ActionView::LookupContext:0x007ff6202a3730 @details_key=#<ActionView::LookupContext::DetailsKey:0x007ff61cb66e70 @hash=-3365680752233435110>, @details={:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee, :haml, :slim]}, @skip_default_locale=false, @cache=true, @prefixes=[\"templates\", \"application\"], @rendered_format=:html, @view_paths=#<ActionView::PathSet:0
@jurikern
jurikern / gist:3953143
Created October 25, 2012 15:03
undefined method `_prefixes' for TemplatesBuilder:Class
actionpack (3.2.8) lib/action_view/base.rb:209:in `initialize'
app/builders/templates_builder.rb:3:in `new'
app/builders/templates_builder.rb:3:in `process'
app/controllers/templates_controller.rb:6:in `create'
actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.8) lib/active_support/callbacks.rb:436:in `_run__2734696839539265386__process_action__2538432014012520187__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline-gplv2-dev lib64readline-gplv2-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -xvzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194/
./configure --prefix=/usr/local
make
make install
@jurikern
jurikern / gist:3664983
Created September 7, 2012 10:31
Regex brilliant collection
/^([0-9]{3}([0-9]{3})?|[0-9]{4})$/ -> 111. 1111, 111111
@jurikern
jurikern / gist:3435077
Created August 23, 2012 10:07
Validation using :if or :unless conditions
class EmploymentInformation < ActiveRecord::Base
attr_accessible :employment_status_id, :company_name, :university
validates :employment_status_id, :presence => true, :inclusion => { :in => proc { |req| req.employment_status_types.map{ |key, value| key } } }
validates :company_name, :presence => true, :format => { :with => /\A[A-z\s\-\._]+\z/ }, :unless => proc { |req| req.employment_status.nil? }
validates :university, :presence => true, :format => { :with => /\A[A-z\s\-\._]+\z/ }, :unless => proc { |req| req.employment_status.nil? }
end
@jurikern
jurikern / gist:3434316
Created August 23, 2012 08:36
Dropdown list validation on rails > 3.2
class Person
validates :gender_id, :presence => true, :inclusion => { :in => proc { |req| req.gender_types.map{ |key, value| key } } } #req - self 'Person' object
validates :title_id, :presence => true, :inclusion => { :in => proc { |req| req.title_types.map{ |key, value| key } } }
end
@file = YAML.load_file("#{Rails.root.join('path/to/folder', 'file.yml')}")