Skip to content

Instantly share code, notes, and snippets.

# grab a page
page = Page.find(1)
# grab the page's list of content_items and eager load each page's markups
content_items = page.content_items.includes(:markups)
# first content_item
content_item = content_items.first
# returns a collection of markups - doesn't output a SQL query
content_item.markups

How to setup Heroku Hostname SSL with GoDaddy SSL Certificate and Zerigo DNS Heroku recently added an exciting new 'Hostname SSL' option. This option offers the broad compatibility of IP-based SSL, but at 1/5 the price ($20 / month at the time of this writing).

The following tutorial explains how to use Heroku's new 'Hostname SSL' option on your Heroku project. Before we begin, let's list what we're using here:

* Heroku Hostname SSL
* GoDaddy Standard SSL Certificate
* Zerigo DNS

Note: I am not using the Heroku Zerigo DNS add-on, instead I have a separate Zerigo account for my DNS needs. I do this because Zerigo offers 30 hosts on free direct accounts, versus only 10 hosts on the free Heroku add-on.

@tybenz
tybenz / app.js
Last active August 29, 2015 14:02
Restify app **before** paper-router. The typical way node server-side apps are written. Single file JS file with server setup and route/action bindings all in one place.
var restify = require('restify');
var BananaModel = require( './models/banana.js' );
var PeelModel = require( './models/peel.js' );
var server = restify.createServer({
name: 'luca',
});
server.use( function crossOrigin( req, res, next ) {
res.header( "Access-Control-Allow-Origin", "*" );
var BananaModel = require( '../models/banana.js' );
var BananaController = {
index: function( req, res, next ) {
res.send( BananaModel.getAll() );
}
create: function( req, res, next ) {
var banana = BananaModel.new({
weight: req.params.weight,
@tybenz
tybenz / app.js
Last active August 29, 2015 14:02
Restify app **after** paper-router. Read comments below to get an idea of how it works.
var restify = require('restify');
var PaperRouter = require( 'paper-router' );
var routes = require( './routes' );
var server = restify.createServer({
name: 'luca',
});
server.use( function crossOrigin( req, res, next ) {
res.header( "Access-Control-Allow-Origin", "*" );
{
"requireCurlyBraces": [ "if", "else", "for", "while", "do" ],
"requireSpaceAfterKeywords": [ "if", "else", "for", "while", "do", "switch", "return" ],
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowMultipleVarDecl": true,
{
"id": 387,
"publication_id": 154,
"title": "Eastern Cottontails",
"subtitle": "By H Cagle 9.26.12",
"pages": [
{
"id": 1068,
"issue_id": 387,
"type": "sections",

Image Upload to S3

url: https://localhost:8083/api/v0/uploadImage
type: POST
Data: { ids: { id: <issue_id>, publication_id: <publication_id>, image_id: <image_uuid> }, file: <image file> }
returns: { result: true/false, publishedURL, error }

Publish

url: https://localhost:8083/api/v0/publish
Error detected while processing function lightline#link:
line 1:
E716: Key not present in Dictionary: _mode_, mode(), 'normal')
Press ENTER or type command to continue
Error detected while processing function lightline#link:
line 1:
E116: Invalid arguments for function get(g:lightline._mode_, mode(), 'normal')
Press ENTER or type command to continue
Error detected while processing function lightline#link:
line 1:
### Keybase proof
I hereby claim:
* I am tybenz on github.
* I am tybenz (https://keybase.io/tybenz) on keybase.
* I have a public key whose fingerprint is 42BF 9F22 838F 09CF E7C7 8933 EAE0 94DA 0A5E C1FA
To claim this, I am signing this object: