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

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 / 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
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) || ''
class ApplicationController < ActionController::Base
include UserAuthentication
end
/config/routes.rb
------------------------------------------------------------------------
get '/products/update_productsubgroups', as: 'update_productsubgroups'
get '/update_productsubgroups' => 'products#update_productsubgroups'
resources :prodducts
/app/assets/javascript/products.coffee
------------------------------------------------------------------------
$ ->
$(document).on 'change', '#productgroups_select', (evt) ->
@tubbo
tubbo / group.rb
Last active August 29, 2015 14:14
class Group < ActiveRecord::Base
has_many :memberships
has_many :users, :through => :memberships
belongs_to :owner, class_name: 'User'
validates :owner, presence: true
validates :name, presence: true, length: { minimum: 6, maximum: 255 }
validates :description, length: { maximum: 255 }, allow_blank: true
end
<div class="row">
<div class="wide-block contact-form" id="message_form">
<!-- url: 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8', method: :post-->
<div id="spinner" class="spinner" style="display:none;">
<%= image_tag('ajax-loader.gif') %>
</div>
<%= form_for(@message ||= Alchemy::Message.new, :remote => true) do |form| %>
<%= form.hidden_field :contact_form_id, :value => element.id %>
<%#= form.hidden_field :oid, :value => '00D20000000DB0V'%>
{
:user_hash => Proc.new { |current_user|
OpenSSL::HMAC.hexdigest("sha256", "ENV['intercom_secret']", current_user.id.to_s)
}
}
class AdminTemplatesController < ApplicationController
def new
@admin_template = AdminTemplate.new
render 'admin/templates/form', layout: (not request.xhr?)
end
end
@tubbo
tubbo / -
Created September 22, 2014 18:06
cookbook_path 'cookbooks'
node_path '../chef-repo/nodes'
role_path '../chef-repo/roles'
environment_path '../chef-repo/environments'
data_bag_path '../chef-repo/data_bags'
#encrypted_data_bag_secret 'data_bag_key'
knife[:berkshelf_path] = 'cookbooks'