Skip to content

Instantly share code, notes, and snippets.

View mikeatlas's full-sized avatar
💻

Mike Atlas mikeatlas

💻
View GitHub Profile
@mikeatlas
mikeatlas / .git-flow-branch-in-prompt.sh
Last active December 20, 2015 20:08
git flow branch in bash prompt (add to ~/.bash_profile)
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
@mikeatlas
mikeatlas / clear_dev_logs_in_rails.rb
Last active February 28, 2021 14:39
automatically clear rails development logs on startup if they're too big
# config/initializers/clear_logs.rb
# This snippet simply clears your logs when they are too large.
# Every time you start the rails environment it checks log sizes
# and clears the logs for you if necessary.
if Rails.env.development?
MAX_LOG_SIZE = 10.megabytes
logs = File.join(Rails.root, 'log', '*.log')
@mikeatlas
mikeatlas / push_to_heroku.rake
Last active December 18, 2015 03:09
Example of how to dynamically set a rails secret_token per-heroku app instance. This sets a heroku environment variable on deployment, which is attempted to be read as a secret_token key file. If the token is not found, a new one is generated on the fly (draw back here is that a dynamic secret_key is used every time the app restarts, causing all…
desc 'Pushes to heroku demo app'
task :push_to_demo => :environment do |t, args|
app_name = 'demo'
push app_name
end
def push(app_name)
puts "$$$$$$$$$$ Pushing to heroku app: #{app_name}"
puts "$$$$$ Pushing to heroku app: #{app_name}"
@mikeatlas
mikeatlas / circle.yml
Created May 31, 2013 23:15
Sample circle.yml - How to precompile assets of a rails project (using the turbo-sprockets-rails3 gem) before pushing to heroku
deployment:
continuous_integration_deployment_test:
branch: master
commands:
- git config --global user.email "ci@test.com"
- git config --global user.name "Continuous Integration"
- git checkout -b with_precompiled_assets
- bundle exec rake assets:precompile assets:clean_expired:
timeout: 1500
- git add public/assets
@mikeatlas
mikeatlas / new_invitation.html.erb
Last active April 17, 2022 19:36
How to invite users in active admin with devise_invitable
<!-- /app/views/admin/users/new_invitiations.html.erb -->
<h2>Send invitation</h2>
<%= form_for @user, :url => send_invitation_admin_users_path do |f| %>
<table style='width: 50%'>
<tr>
<td><%= f.label :first_name %></td>
<td><%= f.text_field :first_name %></td>