Skip to content

Instantly share code, notes, and snippets.

@stevenhaddox
stevenhaddox / gist:5613327
Created May 20, 2013 16:16
Anyone seen / know how to fix this yajl gem error in JRuby?
[sysadmin@support chef-11.4.4]$ jruby -S irb
irb(main):001:0> require 'rubygems'
=> false
irb(main):002:0> require 'yajl'
LoadError: load error: yajl/yajl -- java.lang.UnsatisfiedLinkError: failed to load shim library, error: /home/sysadmin/opt/stow/jruby-1.7.4/lib/native/x86_64-Linux/libjruby-cext.so: cannot open shared object file: No such file or directory
from org/jruby/RubyKernel.java:1054:in `require'
from /home/sysadmin/opt/stow/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:36:in `require'
from /home/sysadmin/opt/stow/jruby-1.7.4/lib/ruby/gems/shared/gems/yajl-ruby-1.1.0/lib/yajl.rb:1:in `(root)'
from org/jruby/RubyKernel.java:1054:in `require'
from /home/sysadmin/opt/stow/jruby-1.7.4/lib/ruby/shared/rubygems/custom_require.rb:1:in `(root)'
@stevenhaddox
stevenhaddox / bundle_package_safe.md
Last active December 12, 2015 00:49
Is it safe to use $ bundle package and subsequently $ bundle install --local for your deploy while waiting for the new rubygems.org?

Can you bypass RubyGems.org and still deploy?

If you can run the following command and get the following result:

$ bundle check                                                                             
The Gemfile's dependencies are satisfied

CONGRATULATIONS!

You can run the bundle package command and still deploy your project without needing to touch RubyGems.org (perhaps stick in 127.0.0.1 in your hosts file if you're still concerned):

@stevenhaddox
stevenhaddox / am_i_going_crazy.txt
Created May 31, 2012 13:44
Failing Jenkins Suite with All Passing Specs.... ?!
+ bundle exec rake test --trace
WARNING: 'require 'rake/rdoctask'' is deprecated. Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
at /var/lib/jenkins/workspace/<app_name>/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
** Invoke test (first_time)
** Execute test
** Invoke test:units (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
@stevenhaddox
stevenhaddox / server_certificates_to_pem.md
Last active December 14, 2023 05:42
Convert .crt & .key files into .pem file for HTTParty

Two ways to do it, but only worked for me so I'll put it first and the second for reference:

$ openssl pkcs12 -export -in hostname.crt -inkey hostname.key -out hostname.p12
$ openssl pkcs12 -in hostname.p12 -nodes -out hostname.pem

Other options for this method in comments below:

# Note, the -certfile root.crt appends all CA certs to the export, I've never needed these so it's optional for my personal steps
$ openssl pkcs12 -export -in hostname.crt -inkey hostname.key -certfile root.crt -out hostname.p12

Note, I've always had my hostname.crt as part of my .pem, so I keep my certs but apparently you may not have to, hence the nocerts flag being an extra option in this sample

@stevenhaddox
stevenhaddox / code_setup.md
Created June 30, 2011 08:32
undefined method `[]' for nil:NilClass in OmniAuth Custom Strategy

RESOLVED

Figured out this error, please DISREGARD! We were forgetting to redirect to the callback_url at the end of the request_phase as we thought that was handled by OmniAuth (oops...)

To replicate this error you should be able to do the following:

class Boot
def run
load_initializer
extend_environment
Rails::Initializer.run(:set_load_path)
end
def extend_environment
Rails::Initializer.class_eval do
old_load = instance_method(:load_environment)
def _authenticate_oauth_echo
require 'httparty'
# header auth only for now; also lock down the auth provider endpoint so we can't spoof
if(request.env["HTTP_X_AUTH_SERVICE_PROVIDER"] != 'https://api.twitter.com/1/account/verify_credentials.json' || request.env["HTTP_X_AUTH_SERVICE_PROVIDER"].blank?)
return false
else
auth_service_provider = request.env["HTTP_X_AUTH_SERVICE_PROVIDER"]
verify_credentials_authorization = request.env["HTTP_X_VERIFY_CREDENTIALS_AUTHORIZATION"]
end
This is an example of using RVM's Project .rvmrc file
to have it automatically bootstrap your environment, including bundler.
This could be further expanded to do anything you require :)
The important thing to remember is that the purpose of these files is
to allow you to very easily have your 'project context' (aka 'environment')
loaded automatically for you when you enter the project in the shell (cd).
require "rubygems"
require 'directory_watcher'
commands = [
{ :tell => "Firefox", :to => "activate" },
{ :tell => "System Events", :to => "keystroke \"1\" using command down" },
{ :tell => "System Events", :to => "keystroke \"r\" using command down" },
{ :tell => "TextMate", :to => "activate" }
]
export RUBY_HEAP_MIN_SLOTS=1000000
export RUBY_HEAP_SLOTS_INCREMENT=250000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=100000000
export RUBY_HEAP_FREE_MIN=1000000