This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ru: | |
| date: | |
| abbr_day_names: | |
| - Вс | |
| - Пн | |
| - Вт | |
| - Ср | |
| - Чт | |
| - Пт | |
| - Сб |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def append_config_to_file | |
| tempfile = File.open("file.rb", 'w') | |
| f = File.new("config/application.rb") | |
| f.each do |line| | |
| tempfile << line | |
| if line.match(/class Application/) | |
| tempfile << " config.autoload_paths += %W(\#{config.root}/searches)\n" | |
| end | |
| end | |
| f.close |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace :faye_server do | |
| desc "Start faye server" | |
| task :start do | |
| run "cd #{current_path};RAILS_ENV=production bundle exec rackup faye.ru -s thin -E production -D -P tmp/pids/faye.pid" | |
| end | |
| desc "Stop faye server" | |
| task :stop do | |
| run "cd #{current_path};if [ -f tmp/pids/faye.pid ] && [ -e /proc/$(cat tmp/pids/faye.pid) ]; then kill -9 `cat tmp/pids/faye.pid`; fi" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User < ActiveRecord::Base | |
| #default_scope where(:banned => false) | |
| scope :unbanned, where(:banned => false) | |
| include ChooseCity | |
| rolify | |
| acts_as_voter | |
| has_karma(:questions, :as => :submitter, :weight => 0.5) | |
| mount_uploader :avatar, AvatarUploader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Module | |
| def access(*args) | |
| args.each do |arg| | |
| instance_var = ("@" + arg.to_s) | |
| define_method(arg.to_s + '=') {|val| instance_variable_set(instance_var, val)} | |
| define_method(arg) { instance_variable_get(instance_var)} | |
| end | |
| end | |
| def attr_access(*args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def few2last(array) | |
| array.slice(-2..-1).join("|") | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (1..5).to_a.zip (5..10).to_a | |
| #=> [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Item | |
| class << self | |
| def show | |
| puts "Class method show invoked" | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| l = lambda do |string| | |
| if string == "try" | |
| return "There's no such thing" | |
| else | |
| return "Do or do not." | |
| end | |
| end | |
| puts l.call("try") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready -> | |
| $('div#reload_form form').submit (event) -> | |
| event.preventDefault() | |
| form = $(this) | |
| url = form.attr('action') | |
| ammo = $('#ammo_to_reload').val() | |
| $.ajax | |
| type: 'put' | |
| url: url |