Skip to content

Instantly share code, notes, and snippets.

@jpfinlay
jpfinlay / ubuntu-16.04LTS-Rails-5.2-Ruby-2.5.1.md
Last active July 27, 2018 07:29
Git 2.18 / OhMyZSH / Rbenv / Ruby 2.5.1 / Rails 5.2 / Postgres 9.5.13

Ubuntu 16.04LTS with Rails 5.2, Ruby 2.5.1 and PostgeSQL 9.5.13

July 26, 2018

Install pre-requisites and Git (2.18.0)

$ sudo apt-get update && sudo apt-get upgrade
$ sudo apt install git-core zsh autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev -y
$ sudo apt-add-repository ppa:git-core/ppa && sudo apt-get update && sudo apt-get install git -y 

Create .gitconfig

@jpfinlay
jpfinlay / app.rake
Created March 11, 2013 23:16
Sample rake file for poplating a development database.
namespace :app do
desc "Ensures that the reset task only happens in development,
not the production environment"
task ensure_development_environment: :environment do
if Rails.env.production?
raise "Rake tasks aborted - you are running a production environment.\n
(You are requesting that the production database is dropped!)"
end
end
<h1>Login</h1>
<%= form_tag author_sessions_path, method: :post do %>
<div class="field">
<%= label_tag :username %>
<%= text_field_tag :username %>
<br/>
</div>
<div class="field">
<%= label_tag :password %>
class AuthorSessionsController < ApplicationController
def new
@author = Author.new
end
def create
@author = login(params[:username], params[:password])
if @author
redirect_back_or_to(articles_path, message: 'Logged in successfully.')
else
<body>
<p class="flash">
<%= flash.notice %>
</p>
<div id="container">
<div id="content">
<%= yield %>
<hr>
<h6>
<% if logged_in? %>
@jpfinlay
jpfinlay / application.html.erb
Created February 15, 2013 12:04
Example Rails 3.2.x layout file
<!DOCTYPE html>
<html>
<head>
<title>Blogger</title>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<p class="flash">
@jpfinlay
jpfinlay / articles.css.scss
Created February 15, 2013 11:48
Example SCSS file
$light_gray: #CCC;
body {
background-color: $light_gray;
font: {
family: Helvetica, Arial, sans-serif;
size: 14px;
}
}
@jpfinlay
jpfinlay / postgresql-cheatsheet
Last active March 28, 2019 12:00
Adding users and databases to Postgresql 9.1.7
# Login as postgres user (superuser)
sudo -u postgres psql <db>
# Login to a db using a username
psql db_name -U username
# Create a new user and allow them to create databases
CREATE USER username WITH LOGIN;
ALTER ROLE username WITH CREATEDB;