Skip to content

Instantly share code, notes, and snippets.

View BenMorganIO's full-sized avatar
😀
Why is this here?

Ben A. Morgan BenMorganIO

😀
Why is this here?
View GitHub Profile
@BenMorganIO
BenMorganIO / medium_post_serializer.rb
Created March 17, 2016 02:18
Serializer Example - Medium Post
module Medium
class PostSerializer < ApplicationSerializer
attributes :title, :description
end
end
describe Medium::PostSerializer do
let(:post) { build :post }
subject { build_serializer post }
{
"title" : "Hello World",
"description" : ""
}
{
"title" : "Hello World",
"description" : null
}
module Medium
class PostSerializer < ApplicationSerializer
attributes :title, :description
end
end
describe Medium::PostSerializer do
let(:post) { build :post }
subject { build_serializer post }
[
{
"name" : "John Doe"
},
{
"name" : "Jane Doe"
}
]
{
"people" : [
{
"name" : "John Doe"
},
{
"name" : "Jane Doe"
}
]
}
class ApplicationController < ActionController::Base
before_action :authenticate_user!
private
def authenticate_user!
token = params[:token].presence
@current_user = User.find_by(token: token)
end
end
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember HABTM'
});
@BenMorganIO
BenMorganIO / 00_nginx_https_rw.config
Created November 14, 2016 02:00
I can't believe this is what it takes to do SSL redirection on AWS EB...
files:
"/tmp/45_nginx_https_rw.sh":
owner: root
group: root
mode: "000644"
content: |
#! /bin/bash
CONFIGURED=`grep -c "return 301 https" /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf`
@BenMorganIO
BenMorganIO / fastboot
Created December 7, 2016 22:39
Ember fastboot init.d daemon.
#!/bin/sh
### BEGIN INIT INFO
# Provides: fastboot
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Ember Fastboot server.
# Description: Boots up Ember Fastboot from the /var/web/frontend folder targeting the ./dist directory.