Skip to content

Instantly share code, notes, and snippets.

View jtperreault's full-sized avatar

James T. Perreault jtperreault

  • Traverse City, MI
View GitHub Profile
CREATE UNIQUE NONCLUSTERED INDEX index_users_reset_password_token
ON dbo.users (reset_password_token)
WHERE reset_password_token IS NOT NULL
ALTER INDEX index_users_on_reset_password_token
ON dbo.users (reset_password_token)
WHERE reset_password_token IS NOT NULL
REBUILD
@jtperreault
jtperreault / gist:5152678
Created March 13, 2013 14:31
logwatch ssh output
--------------------- SSHD Begin ------------------------
Didn't receive an ident from these IPs:
58.174.96.26 (CPE-58-174-96-26.cxyh2.woo.bigpond.net.au): 1 Time(s)
Illegal users from:
undef: 6 times
oracle [preauth]: 2 times
db2inst1 [preauth]: 1 time
@jtperreault
jtperreault / gist:5161942
Last active May 9, 2019 16:01
This is the service script for Nginx installed to /opt/ by the Phusion Passenger gem. This script should reside in /etc/init.d/ and is invoked to manage the nginx process from the command line like so: $ service nginx restart
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
class Project < ActiveRecord::Base
attr_accessible :description, :name
has_many :user_projects
has_many :users, :through => :user_projects
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 HomeController < ApplicationController
def index
@data = session[:omniauth_data]
end
end
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
@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
@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 Product < ApplicationRecord
scope :published, -> {
where(:is_published => true)
}
belongs_to :category
validates_presence_of :name, :price
mount_uploader :image, ImageUploader
validates_processing_of :image