View gist:8773e608cba8b1fb17b1
// ==UserScript==
// @name TitleCapitalize Headings in StackEdit
// @namespace http://hibbard.eu/
// @version 0.1
// @description Apply titlecapitalization to h2 and h3 headings in StackEdit.
// @description Inspired muchly by Bruno Skvorc: http://www.sitepoint.com/implementing-titlecapitalization-stackedit/
// @author James Hibbard
// @match https://stackedit.io/editor*
// @copyright 2015, hibbard.eu
// @require http://code.jquery.com/jquery-latest.js
View archive_trello.rb
# Archive Trello Cards Programatically
#
# Get TRELLO_DEVELOPER_PUBLIC_KEY from:
# https://trello.com/1/appKey/generate
#
# Get TRELLO_MEMBER_TOKEN from:
# https://trello.com/1/authorize?key=TRELLO_DEVELOPER_PUBLIC_KEY&name=Arch&expiration=never&response_type=token&scope=read,write
# substituting TRELLO_DEVELOPER_PUBLIC_KEY for your actual key
#
# Get BOARD_ID (alphanumeric string, found in the board's URL):
View site.css
body{background-color:#FFF;color:#303030;line-height:1.6;font-size:16pt;font-weight:300}
a{text-decoration:none;color:#0083ff}
time{color:#ababab}
.super{vertical-align:super;font-size:50%}
.content{text-align:left;max-width:775px;margin:0 auto 2em}
.content ul{padding-left:2.5em}
.content ol{padding-left:2.5em}
.container{margin-bottom:3em;margin-left:1em;margin-right:1em}
.content .header{text-align:center;border-bottom-style:solid;border-bottom-color:#e4e4e4;border-bottom-width:.3em}
.content .header .siteTitle{font-size:3.5em;font-weight:700;margin-top:-.25em}
View registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
def update
account_update_params = devise_parameter_sanitizer.sanitize(:account_update)
@user = User.find(current_user.id)
if needs_password?
successfully_updated = @user.update_with_password(account_update_params)
else
account_update_params.delete('password')
account_update_params.delete('password_confirmation')
View edit.html.erb
<h2>Login Details</h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
View users_controller.rb
def update
if user_params[:password].blank?
user_params.delete(:password)
user_params.delete(:password_confirmation)
end
successfully_updated = if needs_password?(@user, user_params)
@user.update(user_params)
else
@user.update_without_password(user_params)
View seeds.rb
r1 = Role.create({name: "Regular", description: "Can read items"})
r2 = Role.create({name: "Seller", description: "Can read and create items. Can update and destroy own items"})
r3 = Role.create({name: "Admin", description: "Can perform any CRUD operation on any resource"})
u1 = User.create({name: "Sally", email: "sally@example.com", password: "aaaaaaaa", password_confirmation: "aaaaaaaa", role_id: r1.id})
u2 = User.create({name: "Sue", email: "sue@example.com", password: "aaaaaaaa", password_confirmation: "aaaaaaaa", role_id: r2.id})
u3 = User.create({name: "Kev", email: "kev@example.com", password: "aaaaaaaa", password_confirmation: "aaaaaaaa", role_id: r2.id})
u4 = User.create({name: "Jack", email: "jack@example.com", password: "aaaaaaaa", password_confirmation: "aaaaaaaa", role_id: r3.id})
i1 = Item.create({name: "Rayban Sunglasses", description: "Stylish shades", price: 99.99, user_id: u2.id})
View application.html.erb
<% if user_signed_in? %>
Signed in as <%= current_user.email %>. Not you?
<%= link_to "Edit profile", edit_user_registration_path %>
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
<% else %>
<%= link_to "Sign up", new_user_registration_path %> or <%= link_to "sign in", new_user_session_path %>
<% end %>
<% flash.each do |name, msg| %>
<%= content_tag :div, msg, id: "flash_#{name}" %>
View generate_project_with_scaffolding_and_assosciations.rb
rails new store
cd store
rails g scaffold user name:string role:belongs_to
rails g scaffold role name:string description:string
rails g scaffold item name:string description:text 'price:decimal{5,2}', user:belongs_to
rake db:migrate