Skip to content

Instantly share code, notes, and snippets.

@obrientimothya
obrientimothya / testapp-install-guard
Created December 20, 2017 15:04
Testapp init guard
bundle install
guard init
@obrientimothya
obrientimothya / Gemfile
Created December 20, 2017 15:01
Testapp Install Guard
# --- snip
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'guard'
gem 'guard-rspec'
@obrientimothya
obrientimothya / testapp-install-tmux
Created December 20, 2017 14:56
Testapp install tmux
sudo yum install tmux
@obrientimothya
obrientimothya / install-rspec
Created December 20, 2017 14:11
Testapp Install RSpec
bundle install
rails g rspec:install
@obrientimothya
obrientimothya / Gemfile
Created December 20, 2017 14:05
Testapp Gemfile
# --- snip
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'rspec-rails', '~> 3.6'
gem 'capybara'
end
# --- /snip
@obrientimothya
obrientimothya / create-testapp
Last active December 20, 2017 13:57
Create testapp
mkdir testapp
cd testapp
rvm use ruby-2.4.1@testapp --ruby-version --create
rails new . -T
@obrientimothya
obrientimothya / people.js
Created January 25, 2016 05:51
api-jwt /controllers/people.js
// 1. Load the Person model
var Person = require('../models/person.js');
// 2. Get a paginated list of all People
exports.list = function(req, res){
var query = {};
var page = req.params.page || 1;
var options = {
select: 'first last',
page: page
@obrientimothya
obrientimothya / person.js
Created January 25, 2016 05:48
jwt-api /models/person.js
// 1. Include required modules
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
mongoosePaginate = require('mongoose-paginate'),
bcrypt = require('bcryptjs');
// 2. Define the MongoDB schema for the people collection
var personSchema = new Schema({
first : {type: String, required: 'FirstNameInvalid'},
last : String,
@obrientimothya
obrientimothya / routes.js
Last active January 25, 2016 11:07
api-jwt /routes.js
// 1. Include config and modules
var config = require('./config');
var moment = require('moment');
var jwt = require('jwt-simple');
var Auth = require('./controllers/auth.js');
var People = require('./controllers/people.js');
// 2. Authentication Middleware
function ensureAuthenticated(req, res, next) {
if (!req.headers.authorization) {
@obrientimothya
obrientimothya / config.js
Created January 25, 2016 05:12
api-jwt /config.js
module.exports = {
// 1. MongoDB
MONGO_URI: process.env.MONGO_URI || 'mongodb://localhost/apijwt',
// 2. JWT
TOKEN_SECRET: process.env.TOKEN_SECRET || 'pvpnCCZfwOF85pBjbOebZiYIDhZ3w9LZrKwBZ7152K89mPCOHtbRlmr5Z91ci4L',
// 3. Express Server Port
LISTEN_PORT: process.env.LISTEN_PORT || 3000
};