Skip to content

Instantly share code, notes, and snippets.

View leemour's full-sized avatar

Viacheslav Ptsarev leemour

View GitHub Profile
# 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`.
@leemour
leemour / bundle_isntall.sh
Created October 19, 2013 18:01
Bundle Install in parallel
bundle install -jN
@leemour
leemour / ru.yml
Created October 23, 2013 08:06
Russian locale for Formtastic
ru:
formtastic:
yes: Да
no: Нет
create: Создать %{model}
update: Обновить %{model}
submit: Сохранить %{model}
cancel: Отменить %{model}
reset: Обнулить %{model}
required: обязательно
@leemour
leemour / form_control.rb
Last active December 27, 2015 03:48 — forked from tanraya/gist:7248683
Form control Simple form bootstrap
%w[
CollectionSelectInput
DateTimeInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
RangeInput
StringInput
TextInput
].each do |input_type|
@leemour
leemour / simple_form_bootstrap.rb
Created November 1, 2013 06:59
Form control Simple form bootstrap
/config/initializers/simple_form_bootstrap.rb
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.wrappers :bootstrap, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.wrapper tag: 'div', class: 'col-lg-8' do |ba|
ba.use :input
@leemour
leemour / define_method.rb
Created December 11, 2013 08:00
Define method in ruby
def method_missing(m)
self.class.class_exec do
define_method(:screech) {puts "This is the new screech."}
end
end
@leemour
leemour / until_gets_stop.rb
Created February 14, 2014 12:42
Loop until gets stop
Thread.new do
# Do this in a new thread so that the loop can run at the same time as gets (the latter waits until a newline is entered)
until gets.chomp == "stop"; end
# Exit the entire program (this only stops the current thread in IRB, I warn you)
exit
end
puts "Program started"
loop do
sleep 5
@leemour
leemour / Guardfile
Created February 19, 2014 14:33
RSpec exclude spec folders path
guard 'rspec', :spec_paths => ['spec/models', 'spec/workers', 'spec/observers'] do
# ...
end
@leemour
leemour / Guardfile
Created February 19, 2014 18:23
Guard was slow now is fast with ignore
ignore([%r{^bin/*}, %r{^config/*}, %r{^db/*}, %r{^lib/*}, %r{^log/*}, %r{^public/*}, %r{^tmp/*}])
guard :rspec, :spec_paths => ['spec/models', 'spec/lib'],
cmd: 'spring rspec -f doc --tag ~@slow',
# all_after_pass: true,
all_on_start: false,
failed_mode: :keep do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
HTML
=====
<script type='text/javascript'>
window.jQuery || document.write('<script src="js/jquery-1.7.1.js">\x3C/script>')
</script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.0.6/modernizr.min.js' type='text/javascript'></script>
<script type='text/javascript'>
window.Modernizr || document.write('<script src="js/modernizr-2.0.6.js">\x3C/script>')
</script>