Skip to content

Instantly share code, notes, and snippets.

View yumitsu's full-sized avatar
🐢
I LIEK TURTLES

Alex Zinchenko yumitsu

🐢
I LIEK TURTLES
  • St. Petersburg, Russia
View GitHub Profile
- 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
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",
def create
if session[:verified].nil?
flash[:message] = 'Проверьте правильность введенных данных'
render :action => :new
session[:verified] = true
else
# Работа с данными и вставка в БД
end
end
# 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 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
#
# 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
# -*- encoding: utf-8 -*-
$KCODE = 'u'
require 'i18n'
######
# I18n.i('мир', 'рд') => "мира"
# i('мир', 'рд') => "мира"
if I18n.locale == :ru
125a126,131
>
> hidden.bind('uploadcare-success', function() {
> UploadCare.FileData.fetch(hidden.val(), function(data) {
> UploadCare.Line.showFileData(data);
> });
> });
206a213,229
> },
>
var testObj = {
_version: '0.1',
setVersion: function(ver) {
this._version = ver;
return this;
},
getVersion: function() {
return this._version;
@yumitsu
yumitsu / gist:2000124
Created March 8, 2012 10:13
Rake::CLI in JavaScript
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() {