Skip to content

Instantly share code, notes, and snippets.

View OneDivZero's full-sized avatar

Micha OneDivZero

  • Cologne
View GitHub Profile
# rubocop:disable Rails/OutputSafety
class UspListInput < SimpleForm::Inputs::StringInput
# INFO: wrapper_options := {:class=>"form-control", :error_class=>"is-invalid", :valid_class=>"is-valid"}
def input(_wrapper_options)
input_html_options[:type] ||= input_type
template.content_tag(:div, id: input_id, class: custom_wrapper_style, data: { prefix: input_id }) do
template.concat(build_markup)
end
end
@OneDivZero
OneDivZero / git-checkout.rake
Created February 16, 2017 10:01 — forked from sunny/git-checkout.rake
Task to checkout a branch in rails and apply or rollback the migrations between the two.
# encoding: UTF-8
#
# $ rake checkout new_branch_name
#
# Via https://gist.github.com/jonlemmon/4076864
#
# 1. Roll back any migrations on your current branch which do not exist on the
# other branch
# 2. Discard any changes to the db/schema.rb file
# 3. Check out the other branch
@OneDivZero
OneDivZero / post_checkout_migrations.sh
Created February 16, 2017 10:00 — forked from brysgo/post_checkout_migrations.sh
Post checkout hook for managing rails migrations and bundle install
CHECKING_OUT_BRANCH=$3
OLD_BRANCH=$1
NEW_BRANCH=$2
if [ $CHECKING_OUT_BRANCH -eq 1 ]
then
FILES_CHANGED=`git diff $OLD_BRANCH $NEW_BRANCH --name-status`
MIGRATIONS_REMOVED=`echo "$FILES_CHANGED" | egrep 'D\tdb/migrate/([0-9]+)' | sort -r`
MIGRATIONS_ADDED=`echo "$FILES_CHANGED" | egrep 'A\tdb/migrate/([0-9]+)'`
@OneDivZero
OneDivZero / rails_switch_branch.py
Created February 16, 2017 09:59 — forked from skyriverbend/rails_switch_branch.py
Rails: Switch branches and run migrations
#!/usr/local/bin/python
"""
To use this script, you must be in the root directory of a Rails project that
is using git. You should also make sure that your directory does not contain any
uncommitted changes. Then run:
$ python rails_switch_branch.py name_of_another_branch
Running the above will do the following: