Skip to content

Instantly share code, notes, and snippets.

@jperry
jperry / remote_authenticatable.rb
Last active February 8, 2023 15:48
Devise and warden remote authentication
module Devise
module Models
module RemoteAuthenticatable
extend ActiveSupport::Concern
#
# Here you do the request to the external webservice
#
# If the authentication is successful you should return
# a resource instance
@jperry
jperry / .bashrc
Created November 26, 2014 21:17
Git Helpers
source ~/.git-completion.bash
#### SETTINGS FOR GIT ####
alias sourcetree='open -a SourceTree'
function _git_prompt() {
local git_status="`git status -unormal 2>&1`"
if ! [[ "$git_status" =~ Not\ a\ git\ repo ]]; then
if [[ "$git_status" =~ nothing\ to\ commit ]]; then
@jperry
jperry / both_sources_enabled.txt
Created May 19, 2014 00:31
berkshelf multiple source output
[20:19:26] ~/workspace/bithub/berkshelf-test > berks install --debug
I, [2014-05-18T20:19:35.809619 #75819] INFO -- : Reducing lockfile
D, [2014-05-18T20:19:35.809687 #75819] DEBUG -- : Current lockfile:
D, [2014-05-18T20:19:35.809712 #75819] DEBUG -- :
D, [2014-05-18T20:19:35.809770 #75819] DEBUG -- : DEPENDENCIES
D, [2014-05-18T20:19:35.809802 #75819] DEBUG -- :
D, [2014-05-18T20:19:35.809835 #75819] DEBUG -- : GRAPH
D, [2014-05-18T20:19:35.809867 #75819] DEBUG -- :
D, [2014-05-18T20:19:35.809900 #75819] DEBUG -- : Unlocking dependencies no longer in the Berksfile
D, [2014-05-18T20:19:35.809933 #75819] DEBUG -- : Removing transitive dependencies
@jperry
jperry / gist:46dd2e753ac7c817a6ec
Created May 16, 2014 18:55
libarchive gem install
==> ubuntu: ================================================================================
==> ubuntu: Error executing action `install` on resource 'chef_gem[libarchive-ruby]'
==> ubuntu: ================================================================================
==> ubuntu:
==> ubuntu:
==> ubuntu: Gem::Installer::ExtensionBuildError
==> ubuntu: -----------------------------------
==> ubuntu: ERROR: Failed to build gem native extension.
==> ubuntu:
==> ubuntu: /opt/chef/embedded/bin/ruby extconf.rb
@jperry
jperry / Berksfile
Last active August 29, 2015 14:01
my berksfile
source "http://localhost:26200"
source "https://api.berkshelf.com"
community_cookbooks = {
'apt' => '2.3.8',
'ark' => '0.4.0',
'aws' => '1.0.0',
'bash-completion' => '0.1.0',
'cpu' => '0.2.0',
'curl' => '2.0.0',
def prompt_user(question, input=STDIN, output=STDOUT)
  console = HighLine.new(input, output)
  console.agree("<%= color('#{question}', GREEN) %>")
end
# Want to override the input based on say an environment variable,
# is the code below an ugly approach?
@jperry
jperry / gist:4003812
Created November 2, 2012 19:31
autoscale group output in xml
<DescribeAutoScalingGroupsResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
<DescribeAutoScalingGroupsResult>
<AutoScalingGroups>
<member>
<Tags>
<member>
<ResourceId>projectA-production-subprojectA-992-projectAsubprojectAGroup-49GEKI5AGPAZ</ResourceId>
<PropagateAtLaunch>true</PropagateAtLaunch>
<Value>subprojectA</Value>
<Key>Name</Key>
@jperry
jperry / gist:2972902
Created June 22, 2012 14:05
class instance variable
class Test
def self.test_variable
@test_variable ||= 0
end
def self.test_variable=(n)
@test_variable = n
end
@jperry
jperry / gist:2229720
Created March 28, 2012 19:33
Chefspec example
spec_helper.rb
Rspec.configure do |config|
def converge(recipe_name)
chef_run = ChefSpec::ChefRunner.new(:cookbook_path => File.dirname(__FILE__))
chef_run.coverge recipe_name
chef_run
end
end