Skip to content

Instantly share code, notes, and snippets.

View jtperreault's full-sized avatar

James T. Perreault jtperreault

  • Terakeet
  • Traverse City, MI
View GitHub Profile
message = "You have been granted to #{pluralize(industry_names.count, "industry")}: #{industry_list.join(', ')}"
@user.send_to_slack(message)
@jtperreault
jtperreault / code.rb
Last active March 18, 2019 23:09 — forked from ben-tvpp/code.rb
class WalkSectionController < ApplicationController
def go_for
@walk_section = WalkSection.find(params[:id])
@walk = @walk_section.walk
# full_url = request.base_url + request.path
# i = full_url.rindex( '/' )
@base_url = request.base_url
@walk_section_buttons = @walk_section.walk_section_buttons
end
Results of ping while running speedtest at http://www.dslreports.com/speedtest
PING google.com (173.194.192.102): 56 data bytes
64 bytes from 173.194.192.102: icmp_seq=0 ttl=42 time=41.444 ms
64 bytes from 173.194.192.102: icmp_seq=1 ttl=42 time=41.425 ms
64 bytes from 173.194.192.102: icmp_seq=2 ttl=42 time=41.300 ms
64 bytes from 173.194.192.102: icmp_seq=3 ttl=42 time=42.305 ms
64 bytes from 173.194.192.102: icmp_seq=4 ttl=42 time=44.678 ms
64 bytes from 173.194.192.102: icmp_seq=5 ttl=42 time=44.088 ms
64 bytes from 173.194.192.102: icmp_seq=6 ttl=42 time=48.350 ms
@jtperreault
jtperreault / application.html.erb
Last active October 3, 2017 15:17
Preventing layout on root_url?
<%= render 'layouts/header' unless current_page?(root_url) %>
<h1>All the Phones I know about!</h1>
<div id="every-phone">
<% @phones.each do |fone| %>
<h5><%= fone.name %></h5>
<% end %>
</div>
@jtperreault
jtperreault / phones_controller.rb
Created May 15, 2017 01:37
example phone controller
class PhonesController < ApplicationController
def index
@phones = Phone.all
end
end
class Product < ApplicationRecord
scope :published, -> {
where(:is_published => true)
}
belongs_to :category
validates_presence_of :name, :price
mount_uploader :image, ImageUploader
validates_processing_of :image
@jtperreault
jtperreault / installation.sh
Created October 14, 2015 03:25 — forked from mikhailov/installation.sh
nginx+passenger (real production config)
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
@jtperreault
jtperreault / gist:4e3964c536cb73d23772
Created September 12, 2014 14:23
taxcloud gem console interaction output
irb(main):002:0> origin = TaxCloud::Address.new(address1: '7297 E. Shore Rd.', address2: '', city: 'traverse city', state: 'michigan', zip5: '49686')
=> #<TaxCloud::Address:0x007fc17f6e5080 @address1="7297 E. Shore Rd.", @address2="", @city="traverse city", @state="michigan", @zip5="49686">
irb(main):003:0> dest = TaxCloud::Address.new(address1: '659 Cork Pine Ln.', address2: '', city: 'Vassar', state: 'michigan', zip5: '48768')
=> #<TaxCloud::Address:0x007fc17dce3e48 @address1="659 Cork Pine Ln.", @address2="", @city="Vassar", @state="michigan", @zip5="48768">
irb(main):004:0> transaction = TaxCloud::Transaction.new(customer_id: 1, cart_id: 1, origin: origin, destination: dest)
=> #<TaxCloud::Transaction:0x007fc17f7d71c8 @cart_items=[], @customer_id=1, @cart_id=1, @origin=#<TaxCloud::Address:0x007fc17f6e5080 @address1="7297 E. Shore Rd.", @add
irb(main):005:0> transaction.cart_items << TaxCloud::CartItem.new(index: 1, item_id: 'sku-02', tic: TaxCloud::TaxCodes::GENERAL, price: '14.00', quantity: 2)
=> [#<Tax
be rake db:migrate
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /Users/james/Code/CCE/Rakefile:9)
Connecting to database specified by database.yml
** vote_fu: initialized properly.
DEPRECATION WARNING: Calling set_table_name is deprecated. Please use `self.table_name = 'the_name'` instead. (called from <class:Feedback> at /Users/james/Code/CCE/app/models/feedback.rb:5)
PG::UndefinedTable: ERROR: relation "feedback" does not exist
LINE 5: WHERE a.attrelid = '"feedback"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrel