Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View osulyanov's full-sized avatar
🎯
Focusing

Oleg osulyanov

🎯
Focusing
  • Passion.io
View GitHub Profile
#!/usr/bin/env ruby
require 'octokit'
project = ARGV[0]
if project.nil?
puts 'project is empty'
abort
end
client = Octokit::Client.new(:access_token => "")
# Create repo
@osulyanov
osulyanov / rspec_model_testing_template.rb
Created November 14, 2015 13:28 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@osulyanov
osulyanov / image_uploader.rb
Last active September 11, 2015 08:30
Generate random file name and save old saved file names (CarrierWave FTP)
def filename
if original_filename
if model && model.read_attribute(mounted_as).present?
model.read_attribute(mounted_as)
else
"#{SecureRandom.hex}.#{File.extname(file.filename)}"
end
end
end
@osulyanov
osulyanov / gist:27989db9bb6255ff86fe
Created March 10, 2015 09:43
Bootstrap menu dropdown on hover
// outside the scope of the jQuery plugin to
// keep track of all dropdowns
var $allDropdowns = $();
// if instantlyCloseOthers is true, then it will instantly
// shut other nav items when a new one is hovered over
$.fn.dropdownHover = function(options) {
// the element we really care about
// is the dropdown-toggle's parent
@osulyanov
osulyanov / rspec_hepler.rb
Created April 14, 2014 01:21
Capybara auto-saving screenshots on test failures
RSpec.configure do |config|
config.after(:each) do
if example.exception && example.metadata[:js]
meta = example.metadata
filename = File.basename(meta[:file_path])
line_number = meta[:line_number]
screenshot_name = "screenshot-#{filename}-#{line_number}.png"
screenshot_path = "#{Rails.root.join("tmp")}/#{screenshot_name}"
page.save_screenshot(screenshot_path)
@osulyanov
osulyanov / ru.yml
Created April 8, 2014 07:09
Translations for nested attributes
ru:
activerecord:
theme/posts:
text: Содержание # theme[posts][text]
@osulyanov
osulyanov / gist:8617046
Created January 25, 2014 14:15 — forked from barek2k2/gist:5520967
Apache an nginx configuration for browser cache for static resources
For Apache, use the Location directive into your virtual host(be sure you have included expires and headers modules)
<LocationMatch "^/assets/.*$">
Header unset ETag
FileETag None
ExpiresActive On
ExpiresDefault "access plus 30 days"
</LocationMatch>
@osulyanov
osulyanov / new_gist_file
Created November 21, 2013 07:07
Heroku tips
# Set up heroku app
heroku git:remote -a app_name
# Create db backup
heroku pgbackups:capture
# Download last db backup
curl -o latest.dump `heroku pgbackups:url`
# Restore local base from Heroku
@osulyanov
osulyanov / Capfile.rb
Created November 18, 2013 07:04
Nginx + Unicorn + Capistrano http://habrahabr.ru/post/120368/
load 'deploy'
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
load 'config/deploy' # remove this line to skip loading any of the default tasks
@osulyanov
osulyanov / new_gist_file.sh
Created November 16, 2013 07:55
Install Bitrix Env
wget repos.1c-bitrix.ru/yum/bitrix-env.sh
chmod +x bitrix-env.sh
./bitrix-env.sh
Email settings:
http://dev.1c-bitrix.ru/learning/course/?COURSE_ID=48&LESSON_ID=2946&LESSON_PATH=3918.4635.4739.4796.2946