Skip to content

Instantly share code, notes, and snippets.

Change root password:

sudo passwd

Change user password:

passwd
@deepakmahakale
deepakmahakale / autopopulate_migrations.md
Last active December 1, 2016 21:08
Autopopulate migrations with proper command

If the migration name is of the form "AddXXXToYYY" or "RemoveXXXFromYYY" and is followed by a list of column names and types then a migration containing the appropriate add_column and remove_column statements will be created.

Creating a table

$ rails g migration CreateUsers email:string:index

db/migrate/20161201203703_create_users.rb

class CreateUsers < ActiveRecord::Migration
@searls
searls / 1-irb.rb
Created December 3, 2015 14:10
debugging an activeadmin controller method
> Admin::EstimatesController.instance_method(:update).source
" def update(options={}, &block)
object = resource
if update_resource(object, resource_params)
options[:location] ||= smart_resource_url
end
respond_with_dual_blocks(object, options, &block)
end"
@mudge
mudge / en.rb
Last active September 5, 2023 09:32
Using date ordinals in Rails through an I18n time format.
# This goes in config/locales/en.rb (*not* en.yml)
{
:en => {
:time => {
:formats => {
:full => lambda { |time, _| "%H:%M | %A, #{time.day.ordinalize} %B %Y" }
}
}
}
}
@pahanix
pahanix / gist:885671
Created March 24, 2011 19:22
Clear your logs in development automatically when they are too large.
# config/initializers/clear_logs.rb
# This snippet simply clears your logs when they are too large.
# Large logs mean looooong search in TextMate. You know it :)
# Every time you run rails server or rails console it checks log sizes
# and clears the logs for you if necessary.
if Rails.env.development?
MAX_LOG_SIZE = 2.megabytes