This file contains 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
- semantic_form_for [@user] do |form| | |
= form.input :username | |
= form.input :email | |
= form.input :password, :as => :password | |
= form.input :password_confirmation, :as => :password | |
= form.input :roles, :as => :select, :collection => [:admin, :moderator], :prompt => false | |
%br/ | |
- form.buttons do | |
= form.commit_button |
This file contains 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 Article < ActiveRecord::Base | |
belongs_to :author, :class_name => "User", :foreign_key => "user_id" | |
validates_presence_of :title | |
validates_presence_of :content | |
has_foreign_language :title | |
has_foreign_language :content | |
validates_attachment_content_type :image, :content_type => [ 'image/jpeg', 'image/jpg', 'image/gif', 'image/png' ], :message => "не является изображением" | |
has_attached_file :image, :path => ":rails_root/public/assets/:id/:style_:basename.:extension", | |
:url => "/public/assets/:id/:style_:basename.:extension", |
This file contains 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 create | |
if session[:verified].nil? | |
flash[:message] = 'Проверьте правильность введенных данных' | |
render :action => :new | |
session[:verified] = true | |
else | |
# Работа с данными и вставка в БД | |
end | |
end |
This file contains 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
# Taken from passenger_memory_stats script | |
# Returns the private dirty RSS for the given process, in KB. | |
def determine_private_dirty_rss(pid) | |
total = 0 | |
File.read("/proc/#{pid}/smaps").split("\n").each do |line| | |
line =~ /^(Private)_Dirty: +(\d+)/ | |
if $2 | |
total += $2.to_i | |
end |
This file contains 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
# This will ride alongside god and kill any rogue memory-greedy | |
# processes. Their sacrifice is for the greater good. | |
unicorn_worker_memory_limit = 300_000 | |
Thread.new do | |
loop do | |
begin | |
# unicorn workers | |
# |
This file contains 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
# http://unicorn.bogomips.org/SIGNALS.html | |
rails_env = ENV['RAILS_ENV'] || 'production' | |
rails_root = ENV['RAILS_ROOT'] || "/data/github/current" | |
God.watch do |w| | |
w.name = "unicorn" | |
w.interval = 30.seconds # default | |
# unicorn needs to be run from the rails root |
This file contains 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
# -*- encoding: utf-8 -*- | |
$KCODE = 'u' | |
require 'i18n' | |
###### | |
# I18n.i('мир', 'рд') => "мира" | |
# i('мир', 'рд') => "мира" | |
if I18n.locale == :ru |
This file contains 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
125a126,131 | |
> | |
> hidden.bind('uploadcare-success', function() { | |
> UploadCare.FileData.fetch(hidden.val(), function(data) { | |
> UploadCare.Line.showFileData(data); | |
> }); | |
> }); | |
206a213,229 | |
> }, | |
> |
This file contains 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
var testObj = { | |
_version: '0.1', | |
setVersion: function(ver) { | |
this._version = ver; | |
return this; | |
}, | |
getVersion: function() { | |
return this._version; |
This file contains 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
var Namespace, Namespaces, Task, namespace, task; | |
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | |
Namespaces = { | |
names: [], | |
descriptions: [], | |
tasks: [], | |
injectMethods: function(ins) { | |
var nspaces; | |
nspaces = this; | |
ins.fqn = function() { |
OlderNewer