The following rules of programming style are excerpted from the book "The Elements of Programming Style" by Kernighan and Plauger, published by McGraw Hill. Here is quote from the book: "To paraphrase an observation in The Elements of Style by Strunk and White, the rules of programming style, like those of English, are sometimes broken, even by the best writers. When a rule is broken, however, you will usually find in the program some compensating merit, attained at the cost of the violation. Unless you are certain of doing as well, you will probably do best to follow the rules."
| ' Q B a s i c G o r i l l a s | |
| ' | |
| ' Copyright (C) IBM Corporation 1991 | |
| ' | |
| ' Your mission is to hit your opponent with the exploding banana |
| # Put this file on config/initializer | |
| # This will create an empty whitelist of attributes available for mass assignment for | |
| # all models in your app. As such, your models will need to explicitly whitelist | |
| # accessible parameters by using an attr_accessible declaration. This technique is best | |
| # applied at the start of a new project. However, for an existing project with a thorough | |
| # set of functional tests, it should be straightforward and relatively quick to insert this | |
| # initializer, run your tests, and expose each attribute (via attr_accessible) as dictated | |
| # by your failing tests. |
by Jonathan Rochkind, http://bibwild.wordpress.com
Capistrano automates pushing out a new version of your application to a deployment location.
I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".
| class TicketsController < ApplicationController | |
| def show | |
| tickets = params[:tickets].split(",") | |
| ticket_data = tickets.map do |ticket| | |
| parallel { Faraday.get("http://tickets.local/#{ticket}") } | |
| end | |
| render json: { tickets: ticket_data.map(&:result) } | |
| end |
Locate the section for your github remote in the .git/config file. It looks like this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:joyent/node.git
Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:
This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.
The script is here:
#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"
| # 1) Create your private key (any password will do, we remove it below) | |
| $ cd ~/.ssh | |
| $ openssl genrsa -des3 -out server.orig.key 2048 | |
| # 2) Remove the password | |
| $ openssl rsa -in server.orig.key -out server.key |