Add the following to your bashrc.
#Add another docker window
function dock()
{
if [ "$1" == "-h" ]
then
SELECT table, | |
formatReadableSize(sum(bytes)) as size, | |
min(min_date) as min_date, | |
max(max_date) as max_date | |
FROM system.parts | |
WHERE active | |
GROUP BY table |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Remote terminal</title> | |
<link rel="stylesheet" href="xterm.css" /> | |
<script src="terminal.class.js"></script> | |
Cheat Sheets are greate but they are not a substitute for learning the framework and reading the documentation as we most certainly have not covered every potential example here. Please refer to the Rails Command Line Docs for more information.
You can get all of this information on the command line.
rails generate
with no generator name will output a list of all available generators and some information about global options.
rails generate GENERATOR --help
will list the options that can be passed to the specified generator.
#! /bin/bash | |
export RUN_AS='ubuntu'; | |
export INSTALL_DIR='/var/www/sentry'; | |
HOSTNAME='http://mysentry.example.com'; # No trailing slash | |
DB_HOST='something.rds.amazonaws.com'; | |
DB_PORT='5432'; | |
DB_USER='sentry'; | |
DB_NAME='sentry'; | |
DB_PASSWORD='DB_PASSWORD'; |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ |
#config/initializers/redis.rb | |
require 'redis' | |
require 'redis/objects' | |
REDIS_CONFIG = YAML.load( File.open( Rails.root.join("config/redis.yml") ) ).symbolize_keys | |
dflt = REDIS_CONFIG[:default].symbolize_keys | |
cnfg = dflt.merge(REDIS_CONFIG[Rails.env.to_sym].symbolize_keys) if REDIS_CONFIG[Rails.env.to_sym] | |
$redis = Redis.new(cnfg) | |
Redis::Objects.redis = $redis |
def self.dedupe | |
# find all models and group them on keys which should be common | |
grouped = all.group_by{|model| [model.title,model.info,model.address,model.phone] } | |
grouped.values.each do |duplicates| | |
# the first one we want to keep right? | |
first_one = duplicates.shift # or pop for last one | |
# if there are any more left, they are duplicates | |
# so delete all of them | |
duplicates.each{|double| double.destroy} # duplicates can now be destroyed | |
end |