Skip to content

Instantly share code, notes, and snippets.

View leemour's full-sized avatar

Viacheslav Ptsarev leemour

View GitHub Profile
@leemour
leemour / Gemfile
Created April 18, 2013 08:50 — forked from datenimperator/Gemfile
Sinatra, sprockets, compass, bootstrap-sass playing together
source :rubygems
gem 'shotgun', :group=>:development
gem 'rack-cache'
gem 'sinatra', :require => 'sinatra/base'
gem 'sinatra-support'
gem 'haml'
#place this in config/locales/translit.rb
# encoding: utf-8
# I18n transliteration delegates to Russian::Transliteration (we're unable
# to use common I18n transliteration tables with Russian)
#
# Правило транслитерации для I18n использует Russian::Transliteration
# (использовать обычный механизм и таблицу транслитерации I18n с
# русским языком не получится)
ru:
devise:
confirmations:
confirmed: "Ваша учётная запись подтверждена. Теперь вы вошли в систему."
send_instructions: "В течение нескольких минут вы получите письмо с инструкциями по подтверждению вашей учётной записи."
send_paranoid_instructions: "Если ваш адрес email есть в нашей базе данных, то в течение нескольких минут вы получите письмо с инструкциями по подтверждению вашей учётной записи."
failure:
already_authenticated: "Вы уже вошли в систему."
inactive: "Ваша учётная запись ещё не активирована."
invalid: "Неверный адрес email или пароль."
@leemour
leemour / application_controller.rb
Created May 31, 2013 16:48 — forked from gonzedge/application_controller.rb
Rails 404 and 500 error pages
class ApplicationController < ActionController::Base
# ...
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, with: lambda { |exception| render_error 500, exception }
rescue_from ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, with: lambda { |exception| render_error 404, exception }
end
private
def render_error(status, exception)
# A formtastic input which incorporates carrierwave uploader functionality.
#
# Intelligently adds the cache field, displays and links to the current
# value if there is one, adds a class to the wrapper when replacing an
# existing value, allows removing an existing value with the checkbox
# taking into account validation requirements.
#
# There are several options:
#
# * Toggle the replacement field with `replaceable: true/false`.

Rich Text Editing

External Links

  • WYSIWYG HTML
    • TinyMCE
      • looks like bootstrap
      • license: LGPL
      • integrates with Plupload for file uploading (PHP only)
  • integrates with MoxieManager for file management (PHP only)
function maybe(value) {
var obj = null;
function isEmpty() { return value === undefined || value === null }
function nonEmpty() { return !isEmpty() }
obj = {
map: function (f) { return isEmpty() ? obj : maybe(f(value)) },
getOrElse: function (n) { return isEmpty() ? n : value },
isEmpty: isEmpty,
nonEmpty: nonEmpty
}
@leemour
leemour / routes.rb
Created July 3, 2013 09:25 — forked from araslanov-e/gist:5895283
Routing constraint
# app/constraints/photo_constraint.rb
class PhotoConstraint
def initialize
@types = Photo::TYPES
end
def self.matches?(request)
@types.include?(request.path_parameters[:type])
end
end