service zenoss stop
yum remove zenoss mysql-server mysql-client mysql-shared rabbitmq-server redis memcached
rpm -ef --nodeps MySQL-shared-compat
rm -rf /var/lib/mysql/
rm -rf /var/lib/rabbitmq/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#model (idea 100% stolen from ryanb) | |
def author_tokens=(ids) | |
ids.gsub!(/CREATE_(.+?)_END/) do | |
Author.create!(:name => $1).id | |
end | |
self.author_ids = ids.split(",") | |
end | |
# jquery.tokeninput.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This shell script is intended to be sourced into your shell. It adds | |
# Default Zenoss server settings. | |
[ -z "$ZENOSS_URL" ] && export ZENOSS_URL="http://localhost:8080" | |
[ -z "$ZENOSS_USERNAME" ] && export ZENOSS_USERNAME="admin" | |
[ -z "$ZENOSS_PASSWORD" ] && export ZENOSS_PASSWORD="zenoss" | |
# Generic call to make Zenoss JSON API calls easier on the shell. | |
zenoss_api () { | |
ROUTER_ENDPOINT=$1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Variant 1 | |
def user_params(type) | |
params.require(type.to_sym).permit(attributes) | |
end | |
# Variant 2 | |
def user_params(type) | |
case type | |
when "user" | |
params.require(:user).permit(user_attributes) |
I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api
Rails.application.routes.draw do
constraints subdomain: "api" do
scope module: "api" do
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Django ORM Optimization Tips | |
Caveats: | |
* Only use optimizations that obfuscate the code if you need to. | |
* Not all of these tips are hard and fast rules. | |
* Use your judgement to determine what improvements are appropriate for your code. | |
""" | |
# --------------------------------------------------------------------------- |