Skip to content

Instantly share code, notes, and snippets.

View firedev's full-sized avatar
👁️
👁

Nick Ostrovsky firedev

👁️
👁
View GitHub Profile
class TestCyrillic
class << self
def cyrillic?(string)
string[/\p{Cyrillic}/]
end
end
end
class String
def cyrillic?
➜ local git:(master) tmux-new test
➜ local git:(master) tmux new-session -d test
sessions should be nested with care, unset $TMUX to force
➜ local git:(master) tmux new-session -dP test
sessions should be nested with care, unset $TMUX to force
➜ local git:(master) tmux new-session -S dotfiles -dP test
new-session: illegal option -- S
usage: new-session [-AdDP] [-c start-directory] [-F format] [-n window-name] [-s session-name] [-t target-session] [-x width] [-y height] [command]
➜ local git:(master)
namespace :inquiries do
resources :combiners, only: [:create]
end
# supervise_inquiries_combiners_path
# /supervise/inquiries/combiners ! нет :inquiry_id
# supervise/inquiries/combiners#create
resources :inquiries do
resources :combiners
@firedev
firedev / record_not_found.rb
Created August 8, 2014 11:04
Redirects visitor up the restful route if record not found
# controllers/concerns/record_not_found.rb
#
# Redirects visitor up the restful route if record not found
#
# /articles/404 -> /articles/ -> /
module RecordNotFound
extend ActiveSupport::Concern
included do
@firedev
firedev / seed.rb
Last active August 29, 2015 14:04
Seed.rb - imports records from .yml files
# db/seeds.rb
#
# https://gist.github.com/firedev/5d9cd290da97d3c131e3
#
# Imports records from .yml files in db/seed/model.yml
def put_cycle
@r ||= %w(- \\ | /)
print((@r << @r.shift)[0])
print "\b"
@firedev
firedev / decorated.rb
Last active August 29, 2015 14:04
Hides Draper decorator inside the model and lazily decorates resources
# Hides Draper decorator inside the model and lazily decorates resources
#
# https://gist.github.com/firedev/7a82059b30a2157d4c56
#
# model.rb:
# include Decorated
#
# Just make sure there are no overlapping method names in ModelDecorator
module Decorated
@firedev
firedev / translit.rb
Last active August 29, 2015 14:03
Converts russian strings to english translit
# translit.rb
#
# https://gist.github.com/firedev/128521f9cc8d63eaff77
#
# Converts russian strings to english translit
#
# Usage:
#
# Translit.(string)
@firedev
firedev / metable_model.rb
Last active August 29, 2015 14:02
Creates :meta from given :body when saving models
# app/models/concerns/metable_model.rb
#
# https://gist.github.com/firedev/644b41967cf6c1c9d035
#
# Usage:
#
# rails g migration addMetaToModel meta:string
#
# include MetableModel
# metable [:meta] [, :body] [, &block]
@firedev
firedev / readmarkable.rb
Created June 7, 2014 05:04
ReadMarkable
module ReadMarkable
extend ActiveSupport::Concern
included do
has_many :read_marks
def touch_read_at
update_column(:read_at, Time.now)
end
@firedev
firedev / development.rb
Last active August 29, 2015 13:58
MockSMTP/MailCatcher sniffer for your development.rb
# config/environments/development.rb
require "net/smtp" # don't forget to add this first
# Try to sniff out if MockSMTP or MailCatcher is running
begin
smtp = Net::SMTP.start "localhost", 1025
if smtp.started?
smtp.quit
puts ">> Emails WILL be sent to the SMTP server on port 1025"