Skip to content

Instantly share code, notes, and snippets.

@MichaelCPell
MichaelCPell / Error when hitting root with get request
Created February 6, 2013 22:52
Error when trying to start Discourse on Heroku.
2013-02-06T22:42:52+00:00 app[web.1]: ActionView::Template::Error (undefined method `first' for nil:NilClass):
2013-02-06T22:42:52+00:00 app[web.1]: 119:
2013-02-06T22:42:52+00:00 app[web.1]: 120: <script>
2013-02-06T22:42:52+00:00 heroku[router]: at=info method=GET path=/ host=pell-discourse.herokuapp.com fwd=4.59.160.126 dyno=web.1 queue=0 wait=0ms connect=2ms service=223ms status=500 bytes=0
2013-02-06T22:42:52+00:00 app[web.1]: 121: Discourse.CDN = '<%= Rails.configuration.action_controller.asset_host %>';
2013-02-06T22:42:52+00:00 app[web.1]: 122: Discourse.BaseUrl = '<%= RailsMultisite::ConnectionManagement.current_hostname %>';
2013-02-06T22:42:52+00:00 app[web.1]: 123: Discourse.Environment = '<%= Rails.env %>';
2013-02-06T22:42:52+00:00 app[web.1]: 124: window.Discourse.Router.map(function() {
2013-02-06T22:42:52+00:00 app[web.1]: 125: return Discourse.routeBuilder.call(this);
2013-02-06T22:42:52+00:00 app[web.1]: app/views/layouts/
require 'faker'
# Create 15 topics
topics = []
15.times do
topics << Topic.create(
name: Faker::Lorem.words(rand(1..10)).join(" "),
description: Faker::Lorem.paragraph(rand(1..4))
)
end

#do as ec2-user

TODO: mark that I created a user with the name deploy. useradd -c "Friendly Version User Name" -s /bin/bash -m username

def events
response.headers["Content-Type"] = "text/event-stream"
while(true) do
...
response.stream.write "data: #{x.to_json}\n\n"
end
rescue IOError
logger.info "Stream has closed"
ensure
= link_to "New Category", new_category_path, :class => 'button primary table-action-button large'
%h2.section-title Categories
#applications.data
- if @categories.any?
%table.list-items.white
= render "table_header"
= render @categories
@MichaelCPell
MichaelCPell / andrea.md
Created July 8, 2014 18:19
Instructions for sending a link

You make a gist, and then you copy and paste what is in the browser url.

@MichaelCPell
MichaelCPell / gist:8efe6dd14fcfa735c6c3
Created July 21, 2014 20:08
Console recipe for Cap 2
desc "Remote console"
task :console, :roles => :app do
server = find_servers(:roles => [:app]).first
run_with_tty server, %W( ./script/rails console #{rails_env} )
end
desc "Remote dbconsole"
task :dbconsole, :roles => :app do
env = "production"
server = find_servers(:roles => [:app]).first
Your smallest next problem:
Make this command:
rails console$ Course.first.exercises
Produce (something like) this result:
>[{exercise 1 info}, {exercise 2 info}]
@MichaelCPell
MichaelCPell / gist:7ec31bfe6dbbb1dec0cf
Created August 8, 2014 23:25
module loading error
<!-- config.js -->
applicationModuleVendorDependencies = ['ngCookies', 'ngAnimate', 'ngTouch', 'ngSanitize', 'ui.router', 'ui.bootstrap', 'ui.utils', 'leaflet-directive'];
<!-- application.js -->
angular.module(ApplicationConfiguration.applicationModuleName, ApplicationConfiguration.applicationModuleVendorDependencies);
<!-- layout.server.view.html -->
@MichaelCPell
MichaelCPell / wiki.rb
Created September 10, 2014 03:44
Wiki model with AR optimizations
class Wiki < ActiveRecord::Base
has_many :collabs, dependent: :destroy
has_many :users, through: :collabs
has_one :owner_collab,
-> {where("owner = ?", true)},
class_name: "Collab"
has_one :owner, through: :owner_collab, source: :user
scope :grouped_collabs, -> {