Skip to content

Instantly share code, notes, and snippets.

View maslenkov's full-sized avatar

Eugene Maslenkov maslenkov

View GitHub Profile
@maslenkov
maslenkov / find_attr.js
Created December 25, 2015 12:43
recursively find attribute in js
function find_attr(obj, name) {
var k
for(k in obj) {
if(k == name) {
return k
} else if(typeof(obj[k]) == 'object') {
path = find_attr(obj[k], name)
if(path) {
console.log(k + '/' + path)
return (k + '/' + path)
@maslenkov
maslenkov / check.sh
Last active August 29, 2015 14:15
git bisect with script
#!/bin/zsh --login
cd ~/path/to/project_dir/
bundle install
bundle exec rake db:test:prepare
line=$(bundle exec rspec path/to/spec/feature_name_spec.rb | grep 1\ failure)
if [ ${line:-null} = null ]; then
exit 0
else
exit 1
@maslenkov
maslenkov / Gemfile
Created December 19, 2014 15:13
rake task to recreate all image versions in rails project with carrierwave
...
gem 'ruby-progressbar'
...
@maslenkov
maslenkov / gist:409340c6a273fbbb4061
Last active October 23, 2017 12:43
Notes to resolve pg gem issue
Error:
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
Decision:
gem install pg -v '0.17.1' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
Decision 2(better):
This problem can happen due to lack of dependencies. To fix it u can try smth like for rvm:
rvm requirements
home Finished in 4 minutes 17.7 seconds
work Finished in 2 minutes 2.9 seconds
@maslenkov
maslenkov / rspec_example.rb
Last active December 27, 2015 09:28
what way is the best? one spec for block, or few specs for scenario.
# было
context 'add medication' do
before do
create :consult_medication
visit admin_consult_medications_path
within('#sidebar') { click_link 'Add' }
fill_in 'consult_medication[name]', :with => form.name
click_button 'Create'
end