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
@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) %>
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
class HomeController < ApplicationController
def index
@data = session[:omniauth_data]
end
end
class CreateProducts < ActiveRecord::Migration
def up
create_table :projects_users, :id => false do |t|
t.references :user, :null => false
t.references :project, :null => false
end
end
def down
drop_table :projects_users
end
class Project < ActiveRecord::Base
attr_accessible :description, :name
has_many :user_projects
has_many :users, :through => :user_projects
end