Skip to content

Instantly share code, notes, and snippets.

View jakenotjacob's full-sized avatar
🐼

Jake Campbell jakenotjacob

🐼
View GitHub Profile
@jakenotjacob
jakenotjacob / irb-deadlock
Created September 10, 2013 02:22
IRB deadlock
# irb 0.9.6(09/06/30)
# ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
2.0.0p247 :001 > ^C
# I entered ^D at this point, but it didn't show up.
2.0.0p247 :001 >
#<Class:0x000000025c4750>: No live threads left. Deadlock?
from /home/jake/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/ext/multi-irb.rb:231:in `stop'
from /home/jake/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/ext/multi-irb.rb:231:in `irb'
from /home/jake/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/cmd/subirb.rb:19:in `execute'
from /home/jake/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/cmd/nop.rb:20:in `execute'
PostgreSQL
gem install pg
- Postgres interface access through Ruby
su - postgres
(or use: sudo su … then once logged in as root… su postgres to switch to postgres user)
-This will switch to the postgres user for setup
Initialize DB Cluster & give access to postgres user
@jakenotjacob
jakenotjacob / gist:7761365
Created December 2, 2013 23:58
Seeding error
#=> spec/features/seeds_spec.rb
require 'spec_helper'
feature "Seed Data" do
scenario "The basics" do
#Load bin/rake task code prior to running
load Rails.root + "db/seeds.rb"
user = User.where(email: "admin@example.com").first!
project = Project.where(name: "Ticketee Beta").first!
end
end
@jakenotjacob
jakenotjacob / R4iA-chp9error
Created December 5, 2013 03:27
R4iA - can't cast ActionDispatch::Http::UploadedFile to string
##Tickets Controller
class TicketsController < ApplicationController
before_action :require_signin! #except: [:show, :index] (temp-disabled)
before_action :set_project
before_action :set_ticket, only: [:show, :edit, :update, :destroy]
#Restrict Permissions (creating tickets)
before_action :authorize_create!, only: [:new, :create]
before_action :authorize_update!, only: [:edit, :update]
before_action :authorize_delete!, only: :destroy
@jakenotjacob
jakenotjacob / gist:7799718
Created December 5, 2013 03:35
R4IA(chp.9): can't cast ActionDispatch::Http::UploadedFile to string
##SPEC TRACE##
Failures:
1) Creating Tickets Creating a ticket with an attachment
Failure/Error: click_button "Create Ticket"
TypeError:
can't cast ActionDispatch::Http::UploadedFile to string
# /home/jake/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/quoting.rb:76:in `type_cast'
@jakenotjacob
jakenotjacob / R4iA-Searcher_AR_conflict
Created December 23, 2013 06:08
R4iA: 11.5.2 - Searching by state with Searcher
Updating git://github.com/radar/searcher
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "activerecord":
In Gemfile:
searcher (>= 0) ruby depends on
activerecord (~> 3.0) ruby
rails (= 4.0.0) ruby depends on
@jakenotjacob
jakenotjacob / RubyBug
Last active January 3, 2016 18:28
Possible Ruby interpreter Bug
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
Rails 4.0.2
Gem 2.2.0
rvm 1.25.13 (stable)
[jake@white ServiceDesk]$ rails s
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
@jakenotjacob
jakenotjacob / computer.rb
Last active January 3, 2016 20:09
Figuring out the correct way to deal with FactoryGirl callbacks on a has_many association.
class Computer < ActiveRecord::Base
validates :make, presence: true, length: { maximum: 23 }
validates :model, presence: true, length: { maximum: 23 }
#ESN or MEID lengths should be expected, but we'll use 23 just 'cuz
validates :serial_number, presence: true, length: { maximum: 23 }
belongs_to :customer
end
@jakenotjacob
jakenotjacob / taglib.rb
Created January 21, 2014 05:27
Testing block precedence in TagLib
require 'taglib'
arr = ["examples/toons/toki/wrongdirname/4. Cigarette Lust.mp3",
"examples/toons/toki/wrongdirname/wrongartistlocation/07 - Towers (Ft. Szjerdene).mp3",
"examples/toons/04-caspa-i_beat_my_robot-jah.mp3",
"TuneSort.rb"]
arr.each do |ele|
TagLib::FileRef.open ele { |e|
puts e
@jakenotjacob
jakenotjacob / ARGVerrors.rb
Created January 23, 2014 05:51
Error when passing in ARGV values.
#!/usr/bin/env ruby
puts "Enter the tags for this post: "
tags = gets.chomp
date = Time.now.to_s.split(' ').first
args = ARGV
file_title = args.join("-")
post_title = args.join(" ")