Skip to content

Instantly share code, notes, and snippets.

View tubbo's full-sized avatar
😎
losing my sight, losing my mind, go to the general to save some time

Tom Scott tubbo

😎
losing my sight, losing my mind, go to the general to save some time
View GitHub Profile
class Instance < ActiveRecord::Base
has_many :reports
has_many :exams, primary_key: 'study_instance_uid', foreign_key: 'study_inst_uid', inverse_of: :instance
has_many :patients, through: :exams
before_save :set_reading_physician
def reading_physician
(set_reading_physician and save!) if reading_physician.nil?
read_attribute(:reading_physician) || ''
@tubbo
tubbo / promise.rb
Created May 19, 2015 05:29
Playing around with promises in Ruby, inspired by Sandi Metz' talk "Nothing Is Something"
class Promise
attr_reader :object
def initialize(object)
@object = object
end
def try(method)
@tries << method
self

Keybase proof

I hereby claim:

  • I am tubbo on github.
  • I am tubbo (https://keybase.io/tubbo) on keybase.
  • I have a public key whose fingerprint is F787 E5BA AA9A E3DF 95FC 7791 D414 A7A0 9348 E547

To claim this, I am signing this object:

@tubbo
tubbo / posts_controller.rb
Created November 10, 2009 06:44
blog/posts_controller
class Blog::PostsController < ApplicationController
before_filter :authorization_required, :except => [:index, :show]
layout 'application', :except => :feed
# GET /blog/posts
def index
@posts = Post.all
respond_to do |format|
format.html # index.html.erb
# Logfile created on Tue Nov 10 06:38:31 +0000 2009Starting the New Relic Agent
Processing Blog::PostsController#index (for 69.142.78.178 at 2009-11-10 06:38:32) [GET]
Parameters: {"action"=>"index", "controller"=>"blog/posts"}
NameError (uninitialized constant Blog::Post):
app/controllers/blog/posts_controller.rb:7:in `index'
/usr/lib/ruby/gems/1.8/gems/newrelic_rpm-2.9.5/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:138:in `perform_action'
/usr/lib/ruby/gems/1.8/gems/newrelic_rpm-2.9.5/lib/new_relic/agent/method_tracer.rb:62:in `trace_method_execution_with_scope'
<h2>post a new message</h2>
<% form_for [:blog, @post], :html=>{:method=>:post} do |f| %>
<%= f.error_messages %>
<fieldset>
<legend>content</legend>
<%= f.text_field :title %><br /><br />
<%= f.text_area :body %><br />
<div style="width: 100%; text-align: center">
in... <%= collection_select :post, :category, Category.all, :id, :name, {:prompt => true} %>
</div>
<h2>~/blog</h2>
<%= render :partial => 'blog/post', :object => @post %>
<hr align="center" />
<!-- comments here -->
<div style="width: 100%; text-align: center"><%= link_to 'Back', blog_posts_path %></div>
<div id="<%= post.id %>" class="blog_post">
<div id="header">
<h3><%= link_to post.title, blog_post_path(post), :class => 'title' %></h3>
<div id="meta">
posted in
<%= link_to post.category.name, blog_category_path(post.category), :class => 'nobold' %>
<%= format_post_date post.created_at %>.
</div>
</div>
<div id="body">
<h2 style="margin-left: 15px">welcome to psychedelica berserk</h2>
<div class="blog">
<%
@posts.each do |post|
render :partial => 'blog/post', :object => post
end
%>
</div>
<script type="text/javascript">
$(function() {
$("#tabs").tabs();
});
</script>
<div id="tabs">
<h1>psychedeli.ca</h1>
<ul>
<li><a href="#tabs-1">prose</a></li>
<li><a href="/music">music</a></li>