Skip to content

Instantly share code, notes, and snippets.

Tyler Rick TylerRick

  • USA
Block or report user

Report or block TylerRick

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@TylerRick
TylerRick / .gitignore
Created Jan 19, 2018 — forked from ZJONSSON/force_labels.js
Automatic floating labels using d3 force-layout
View .gitignore
d3-force-labels.js
@TylerRick
TylerRick / main.rb
Created Jan 16, 2018 — forked from coorasse/main.rb
CanCanCan Issue
View main.rb
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '5.1.4'
@TylerRick
TylerRick / action_mailer-dont_log_attachments.rb
Last active Oct 19, 2017
Override the version from the actionmailer gem in order to not log attachments.
View action_mailer-dont_log_attachments.rb
ActionMailer::Base.class_eval do
class << self
protected
# Override the version from the actionmailer gem in order to not log attachments.
#
# Note: This depends on the patch from https://github.com/mikel/mail/pull/858, which adds
# parts.inspect_structure and fixes an issue with mail.without_attachments!
#
@TylerRick
TylerRick / gist:d5e2a57c95b354ddec5d
Last active Aug 29, 2015
zeus crash: Wrong message type! Expected ActionResponseMessage, (v0.15.3)
View gist:d5e2a57c95b354ddec5d
> zeus start
Starting Zeus server v0.15.3
[ready] [crashed] [running] [connecting] [waiting]
boot
├── default_bundle
│  └── development_environment
│  └── prerake
├── default_bundle_with_test_env
│  └── test_environment
│  ├── cucumber_environment
@TylerRick
TylerRick / table_bounds_width_bug.rb
Created May 12, 2014
Indent doesn't get reset after rendering a centered table
View table_bounds_width_bug.rb
require "prawn"
Prawn::Document.generate("#{__FILE__}.pdf") do |pdf|
pdf.start_new_page margin: [100, 100, 100, 100]
pdf.stroke_axis
orig_bounds_width = pdf.bounds.width
pdf.formatted_text_box [ { :text => "width: #{pdf.bounds.width}" } ], :at => [0, 20]
pdf.indent(100) do
pdf.stroke_axis
@TylerRick
TylerRick / gist:9815597
Created Mar 27, 2014
time bundle exec rake canvas:compile_assets for https://github.com/instructure/canvas-lms
View gist:9815597
canvas (stable) > time bundle exec rake canvas:compile_assets
--> Compiling static assets [css]
warning Webkit only supports pixels for the start and end stops for radial gradients. Got: 100%
warning Webkit only supports pixels for the start and end stops for radial gradients. Got: 100%
warning Webkit only supports pixels for the start and end stops for radial gradients. Got: 100%
--> creating styleguide
# writing file: app/views/info/styleguide.html.erb
--> Compiling static assets [jammit]
--> Compiled static assets [css/jammit]
--> Compiling static assets [javascript]
@TylerRick
TylerRick / gist:9811465
Last active Aug 29, 2015
Canvas installation errors
View gist:9811465
Following https://github.com/instructure/canvas-lms/wiki/Quick-Start I ran into some problems. Here's what I did to work around them.
I am installing on my development computer, running Ubuntu 13.10.
dpkg --get-selections | egrep -i "postgresql"
postgresql install
postgresql-9.1 install
postgresql-9.1-postgis deinstall
postgresql-client-9.1 install
postgresql-client-common install
@TylerRick
TylerRick / reduce_precision_of_datetime_columns.rb
Last active Dec 20, 2015
Change all datetime columns to have a precision of 0, to match the default precision of these columns in MySQL. This is useful if you migrate a database from MySQL to PostgreSQL and don't need the extra microsecond precision (precision: 6) that is the default in PostgreSQL (see http://www.postgresql.org/docs/9.2/static/datatype-datetime.html).
View reduce_precision_of_datetime_columns.rb
# Change all datetime columns to have a precision of 0, to match the default precision of these
# columns in MySQL.
#
# This is useful if you migrate a database from MySQL to PostgreSQL and don't need the extra
# microsecond precision (precision: 6) that is the default in PostgreSQL
# (see http://www.postgresql.org/docs/9.2/static/datatype-datetime.html).
#
# Before:
# > some_record.created_at.strftime('%Y-%m-%d %H:%M:%S.%N')
# => "2013-07-25 11:49:33.270032000"
@TylerRick
TylerRick / form_helper_extensions.rb
Last active Dec 18, 2015
date_field helper for HTML5 type="date" inputs! And a version of value_before_type_cast that returns a string in ISO-8601 format as the value for Dates, as specified by http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#date-state-(type=date)
View form_helper_extensions.rb
# Extensions to gems/actionpack-3.2.13/lib/action_view/helpers/form_helper.rb
=begin
A version of InstanceTag.value_before_type_cast that returns a string in ISO-8601 format for Date columns.
The original behavior of value_before_type_cast was to return the Date object itself. But the default to_s on a Date returns a string like "June 5, 2013".
However, HTML5 date input fields expect their values to be in ISO-8601 format ("2013-06-05") and won't recognize the value if it is in some other format.
This makes it so you can simply do this:
@TylerRick
TylerRick / delegate_to_all.rb
Last active Jul 29, 2019
DelegateToAll. Like delegate.rb from Ruby's std lib but lets you have multiple target/delegate objects.
View delegate_to_all.rb
# DelegateToAll. Like delegate.rb from Ruby's std lib but lets you have multiple target/delegate objects.
require 'delegate'
class DelegatorToAll < Delegator
# Pass in the _obj_ to delegate method calls to. All methods supported by
# _obj_ will be delegated to.
#
def initialize(*targets)
__setobj__(targets)
You can’t perform that action at this time.