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 | |
has_many :stories, :dependent => :destroy | |
has_many :tasks, :class_name => "Story", | |
:dependent => :nullify, | |
:foreign_key => "responsible_user_id" | |
attr_accessible :name, :email, :password, :password_confirmation | |
has_secure_password | |
validates_presence_of :password, :on => :create |
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
module ReversePolishNotation | |
class << self | |
def calc(formula) | |
chain = prepare formula | |
stack = [] | |
while chain.any? do | |
item = chain.shift | |
if item.kind_of? Float | |
stack.push item | |
else |
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
require File.expand_path("../../config/environment", __FILE__) | |
OLD_BASE_DIR = "public/system/uploads/object_model" | |
FALLBACK_PATH = "/images/fallback/default.png" | |
def copy(model, mounter_name) | |
mounter = model.public_send(mounter_name) | |
if mounter.to_s != FALLBACK_PATH | |
basename = File.basename mounter.to_s |
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
{ :name_ru => "Абхазия", :name_en => "Abkhazia", :alpha2 => "AB", :alpha3 => "ABH" } | |
{ :name_ru => "Австралия", :name_en => "Australia", :alpha2 => "AU", :alpha3 => "AUS" } | |
{ :name_ru => "Австрия", :name_en => "Austria", :alpha2 => "AT", :alpha3 => "AUT" } | |
{ :name_ru => "Азербайджан", :name_en => "Azerbaijan", :alpha2 => "AZ", :alpha3 => "AZE" } | |
{ :name_ru => "Албания", :name_en => "Albania", :alpha2 => "AL", :alpha3 => "ALB" } | |
{ :name_ru => "Алжир", :name_en => "Algeria", :alpha2 => "DZ", :alpha3 => "DZA" } | |
{ :name_ru => "Американское Самоа", :name_en => "American Samoa", :alpha2 => "AS", :alpha3 => "ASM" } | |
{ :name_ru => "Ангилья", :name_en => "Anguilla", :alpha2 => "AI", :alpha3 => "AIA" } | |
{ :name_ru => "Ангола", :name_en => "Angola", :alpha2 => "AO", :alpha3 => "AGO" } | |
{ :name_ru => "Андорра", :name_en => "Andorra", :alpha2 => "AD", :alpha3 => "AND" } |
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
# gem install capybara --pre | |
# gem install rspec | |
# rspec capybara_test.rb | |
require 'rubygems' | |
require 'capybara' | |
require 'capybara/rspec' | |
Capybara.configure do |c| | |
c.current_driver = :selenium |
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
import scipy.misc | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import math | |
hx = 7.5 | |
hy = 6.3 | |
fi = -15 * np.pi / 180 | |
kx = 1.2 | |
ky = 0.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
Broadcast::ScheduleItem | |
=> Broadcast::ScheduleItem( ... time: time, ...) | |
i = Broadcast::ScheduleItem.last | |
i.time | |
=> 2000-01-01 10:50:07 UTC | |
i.time.class | |
=> Time | |
i.time.utc | |
=> 2000-01-01 10:50:07 UTC |
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
Варианты инициализации views в backbone | |
======================================= | |
* в рельсовой вьюхе | |
* через jQuery селекторы (если есть id, инициализируем нужные вьюхи) | |
* через gon передавать контроллер и экшен | |
* написать роутер, основанный на window.location(придется отказаться от single page) | |
для всех, кроме последнего: | |
* инициализировать вьюхи |
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
$ -> | |
$groups_selector = $('#user_advertisement_company_fb_page_id') | |
$fb_accounts_selector = $('#user_advertisement_company_facebook_account_id') | |
$stub_message = $('<option/>', text: 'Идет загрузка…') | |
group_filler = -> | |
if @value | |
previous_value = $('option', $groups_selector).val() | |
$groups_selector.html $stub_message | |
$.getJSON "/api/facebook_accounts/#{@value}/pages", (data) -> |
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
--- | |
- | |
hosts: default | |
vars: | |
postgresql: | |
version: 9.1 | |
password: my_secret_password | |
tasks: |
OlderNewer