Skip to content

Instantly share code, notes, and snippets.

View dlupu's full-sized avatar
🏠
Working from home

Dorian dlupu

🏠
Working from home
View GitHub Profile
@dlupu
dlupu / main.js
Created January 24, 2021 21:17
Storybook configuration that picks up Ruby on Rails webpacker packs
// .storybook/main.js
//
// this module makes the assumption that
// the local host is accessible at http://localhost:3001"
let fs = require('fs');
module.exports = {
stories: ['../spec/components/**/*.stories.json'],
addons: [
@dlupu
dlupu / hotwire_stimulus_2_0.md
Last active March 16, 2022 19:02 — forked from scottharvey/stimulus.md
Hotwire Stimulus 2.0 cheatsheet (in the process of being updated). If you have any feedback, please comment.
@dlupu
dlupu / application_controller.rb
Created October 5, 2020 20:05 — forked from sunny/application_controller.rb
Rails helper so that "?_locale_keys=1" in URL shows locale keys
class ApplicationController < ActionController::Base
include I18nHelper
end
@dlupu
dlupu / plugin.sh
Created December 30, 2019 18:51
Create rspec rails plugin
# http://stackoverflow.com/questions/8507798/rails-3-1-plugin-gem-dummy-test-app-rspec
# http://namick.tumblr.com/post/17663752365/how-to-create-a-gemified-plugin-with-rails-3-2-rspec
rails plugin new plugin_name --skip-test-unit --dummy-path=spec/dummy
cd plugin_name
# Add rspec-rails to gemspec dev deps
# s.add_development_dependency "rspec-rails"
bundle install
@dlupu
dlupu / cloud9.md
Created September 28, 2017 08:36
Cloud 9 debug and cheatsheet

Errors

PG::ConnectionBad: could not connect to server: Connection refused

PG::ConnectionBad: could not connect to server: Connection refused Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

@dlupu
dlupu / products_controller.rb
Last active June 13, 2016 19:21
Solidus (Spree) render API serializers outside the API
# app/controllers/products_controller.rb
class ProductsController < Spree::ProductsController
helper Spree::Api::ApiHelpers
def index
@searcher = build_searcher(params.merge(include_images: true))
@products = @searcher.retrieve_products
json = Rabl.render(nil, 'spree/api/products/index.v1', {
@dlupu
dlupu / rubocop_pre_commit_hook
Last active February 18, 2021 15:50 — forked from kiran/rubocop_pre_commit_hook
forked pre-commit hook for changed ruby files. (whitespace sensitivity in the regex was borking selection)
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /^\s*(A|AM|M)/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED
@dlupu
dlupu / deploy_to_scalingo_from_semaphore_ci.sh
Last active January 11, 2016 07:59
Script I use to automatically deploy code to https://scalingo.com/ from https://semaphoreci.com/
### THIS SCRIPT IS EXECUTED IN THE APP ROOT FOLDER ###
# be sure scalingo.com is a known ssh host 00:00
ssh-keyscan -H -p 22 scalingo.com >> ~/.ssh/known_hosts
# install Scalingo CLO
curl -O https://cli-dl.scalingo.io/install && bash install
# DPL is a deploy tool made for continuous deployment (ruby)
gem install dpl
@dlupu
dlupu / error_backtrace
Last active December 26, 2015 00:06
ActionView::Template::Error: private method `routes' called for #<ActionDispatch::Routing::RouteSet::NamedRouteCollection:0x007fde7a5e4498> https://github.com/railsware/js-routes/issues/171
ActionView::Template::Error: private method `routes' called for #<ActionDispatch::Routing::RouteSet::NamedRouteCollection:0x007fde7a5e4498>
~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/js-routes-1.2.0/lib/js_routes.rb:62:in `generate'
~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/js-routes-1.2.0/app/assets/javascripts/js-routes.js.erb:2:in `_evaluate_template'
~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sprockets-3.5.2/lib/sprockets/erb_processor.rb:26:in `call'
~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sprockets-3.5.2/lib/sprockets/erb_processor.rb:13:in `call'
~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sprockets-3.5.2/
@dlupu
dlupu / error_backtrace
Last active December 25, 2015 22:53
`alias_method': undefined method `attributes_for' for class `Devise::ParameterSanitizer' (NameError) - https://github.com/scambra/devise_invitable/issues/616
~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-5.0.0.beta1/lib/active_support/core_ext/module/aliasing.rb:37:in `alias_method': undefined method `attributes_for' for class `Devise::ParameterSanitizer' (NameError)
from ~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-5.0.0.beta1/lib/active_support/core_ext/module/aliasing.rb:37:in `alias_method_chain'
from ~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/devise_invitable-5c4260faf54a/lib/devise_invitable/parameter_sanitizer.rb:12:in `included'
from ~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/devise_invitable-5c4260faf54a/lib/devise_invitable/rails.rb:20:in `include'
from ~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/devise_invitable-5c4260faf54a/lib/devise_invitable/rails.rb:20:in `block in <class:Engine>'
from ~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-5.0.0.beta1/lib/active_support/lazy_load_hooks.rb:36:in `call'
from ~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesuppo