Skip to content

Instantly share code, notes, and snippets.

@renier
renier / gist:9815009
Created March 27, 2014 18:43
Is there a better way to pick up included files for 'rake package'?
require 'rake/packagetask'
require 'bundler/gem_tasks'
require 'rubocop/rake_task'
require 'find'
require 'pathname'
ROOT_DIR = File.dirname(__FILE__)
spec = Gem::Specification::load("#{Dir.glob(ROOT_DIR + '/*.gemspec')[0]}")
@renier
renier / gist:11150973
Created April 21, 2014 18:06
Juju bootstrap fail - precise-amd64 juju box, Juju 1.18.1
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'JujuBox'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] -- 22 => 2122 (adapter 1)
@renier
renier / gist:fc3c5bf0a87d239db972
Created May 18, 2014 15:56
PackageTask example
require 'bundler/gem_tasks'
require 'rake/packagetask'
require 'rubocop/rake_task'
require 'rspec/core/rake_task'
ROOT_DIR = File.dirname(__FILE__)
gemspec = Gem::Specification.load("#{Dir.glob(ROOT_DIR + '/*.gemspec')[0]}")
RSpec::Core::RakeTask.new(:spec) do |t|
@renier
renier / gist:9d23ead9a36ba2939d18
Created June 3, 2014 01:52
Rubocop NameError
irb(main):001:0> require 'rubocop'
=> true
irb(main):002:0> Rubocop
NameError: uninitialized constant Rubocop
@renier
renier / test.sh
Last active August 29, 2015 14:02
Document is not available right away in elasticsearch
#!/bin/sh -x
curl -w "\n" -X DELETE http://localhost:9200/testing;
curl -w "\n" -X POST http://localhost:9200/testing/group -d '{"name":"default","description":"This is the default group.","id":null}';
# This next request returns 0 hits
curl -w "\n" -X GET http://localhost:9200/testing/group/_search;
sleep 1;
# After waiting one second, this request returns the previously created document
curl -w "\n" -X GET http://localhost:9200/testing/group/_search;
#!/bin/sh
sed -i -e '/^PermitRootLogin/d' /etc/ssh/sshd_config
echo 'PermitRootLogin without-password' >> /etc/ssh/sshd_config
service ssh restart || service sshd restart
@renier
renier / httparty_uses_basic_auth_creds_in_url.rb
Created November 17, 2014 19:21
Make HTTParty pick out basic auth credentials from URL
module HTTParty
module ClassMethods
private
alias_method :orig_perform_request, :perform_request
def perform_request(http_method, path, options, &block)
if path.include? '@'
options ||= {}
scheme_auth, host_uri = path.split('@')
scheme, creds = scheme_auth.split('//')
@renier
renier / oauth_understands_grape.rb
Created November 17, 2014 19:19
Make OAuth understand Grape requests
require 'oauth'
require 'oauth/request_proxy/rack_request'
module OAuth
module RequestProxy
class RackRequest
proxies Grape::Request
end
end
end
@renier
renier / norequiretty.sh
Last active August 29, 2015 14:20
No requiretty
sed -i -e 's/ requiretty/ !requiretty/' /etc/sudoers
var input = "/*global put:true,globals:true,here:true*/" + lines.join("\n");