Skip to content

Instantly share code, notes, and snippets.

View mgarciap's full-sized avatar

Manuel Garcia mgarciap

View GitHub Profile
irb(main):007:0> app.get '/?foo[]=bar&foo[]=pub'
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
from /opt/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.beta/lib/action_dispatch/http/filter_parameters.rb:78:in `process_parameter_filter'
from /opt/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.beta/lib/action_dispatch/http/filter_parameters.rb:84:in `process_parameter_filter'
from /opt/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.beta/lib/action_dispatch/http/filter_parameters.rb:84:in `map'
from /opt/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.beta/lib/action_dispatch/http/filter_parameters.rb:84:in `process_parameter_filter'
from /opt/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.beta/lib/action_dispatch/http/filter_parameters.rb:78:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0.beta/lib/action_dispatch/http/filter_parameters.rb:78:in `process_parameter_filte
@mgarciap
mgarciap / gist:5196087
Last active December 15, 2015 03:39
Ruby script to change every single IP reference in cloudfoundry VCAP_SETUP to a new IP. Name it: vcap_dev_update_ip -> /home/manu/cloudfoundry/vcap/dev_setup/bin/vcap_dev_update_ip It needs to know the vcap configuration location. The associated script will use: /home/manu/cloudfoundry/.deployments/devbox/config. Chage if needed
#!/usr/bin/env ruby
# Update the IP address in a CF deployed config files.
# Look for an IP address in all the yml files in a
# particular folder and replace it with the current IP address
DIR = File.dirname(__FILE__)
module VcapUtilities
# Reads the ip of a given interface
@mgarciap
mgarciap / gist:5196093
Created March 19, 2013 13:27
Script to reconfigure VCAP_SETUP after a change on eth0 IP. This will be done automatically when you put in /etc/network/if-up.d Be aware that you need to create a Ruby script following: https://gist.github.com/mgarciap/5196087
#! /bin/sh
# Reload the nats_server when an interface comes up, to allow it to start
# listening on new addresses.
# This is only enabled if the config file of the nats_server has a tracked-net-iface line
# That defines what interface its IP must be.
set -e
LOG_FILE=/var/log/nats_server.log
touch $LOG_FILE
# Don't bother to restart nats-server when lo is configured.
@mgarciap
mgarciap / gist:5484840
Last active December 16, 2015 19:28
Pushing a very simple sinatra app to CF V2.
vagrant@precise64:~/tests/my_sinatra_app$ cf push -t
Name> my_app
>>>
REQUEST: GET http://localhost:8181/v2/spaces/fe154e51-ac6f-4210-9777-0b7fdba77a52/apps?q=name%3Amy_app&inline-relations-depth=1
REQUEST_HEADERS:
Accept : application/json
Authorization : bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI1ODVhMDc5Yi02M2IyLTQyNjctOGUzNC1kNjg2NzViNjUzMjUiLCJzdWIiOiIwYzMzY2Y4Ni0wMjc5LTQxMjEtOGIyMS02Njg4NTU3Y2RjN2MiLCJzY29wZSI6WyJjbG91ZF9jb250cm9sbGVyLmFkbWluIiwiY2xvdWRfY29udHJvbGxlci5yZWFkIiwiY2xvdWRfY29udHJvbGxlci53cml0ZSIsIm9wZW5pZCIsInBhc3N3b3JkLndyaXRlIiwic2NpbS5yZWFkIiwic2NpbS53cml0ZSJdLCJjbGllbnRfaWQiOiJjZiIsImNpZCI6ImNmIiwiZ3JhbnRfdHlwZSI6InBhc3N3b3JkIiwidXNlcl9pZCI6IjBjMzNjZjg2LTAyNzktNDEyMS04YjIxLTY2ODg1NTdjZGM3YyIsInVzZXJfbmFtZSI6ImFkbWluIiwiZW1haWwiOiJhZG1pbiIsImlhdCI6MTM2NzI2Nzg3OSwiZXhwIjoxMzY3MzExMDc5LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvdWFhL29hdXRoL3Rva2VuIiwiYXVkIjpbInNjaW0iLCJvcGVuaWQiLCJjbG91ZF9jb250cm9sbGVyIiwicGFzc3dvcmQiXX0.764AZwHbzhHwUIRAKZhPss90wotRRK2hxaHfjp3OY3k
Content-Length : 0
RESPO
@mgarciap
mgarciap / gist:5502588
Created May 2, 2013 14:29
Sinatra app push... almost there.
travis@precise64:/cf-box/sinatra$ cf push -t
Name> app3
>>>
REQUEST: GET http://127.0.0.1:8181/v2/spaces/11118df7-07a3-437d-81b9-9904e1e977d7/apps?q=name%3Aapp3&inline-relations-depth=1
REQUEST_HEADERS:
Accept : application/json
Authorization : bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI2NTE0OGYwNy0wMWNkLTQ1MDAtODBhMS03NGQ3NmRkMzI2NDQiLCJzdWIiOiIzNDg0OTY2Yi1kM2QxLTQ3MTgtYmRmNC0xMDlkZDliZjg2MGYiLCJzY29wZSI6WyJjbG91ZF9jb250cm9sbGVyLmFkbWluIiwiY2xvdWRfY29udHJvbGxlci5yZWFkIiwiY2xvdWRfY29udHJvbGxlci53cml0ZSIsIm9wZW5pZCIsInBhc3N3b3JkLndyaXRlIiwic2NpbS5yZWFkIiwic2NpbS53cml0ZSJdLCJjbGllbnRfaWQiOiJjZiIsImNpZCI6ImNmIiwiZ3JhbnRfdHlwZSI6InBhc3N3b3JkIiwidXNlcl9pZCI6IjM0ODQ5NjZiLWQzZDEtNDcxOC1iZGY0LTEwOWRkOWJmODYwZiIsInVzZXJfbmFtZSI6ImFkbWluIiwiZW1haWwiOiJhZG1pbiIsImlhdCI6MTM2NzUwMjA1OCwiZXhwIjoxMzY3NTQ1MjU4LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAvdWFhL29hdXRoL3Rva2VuIiwiYXVkIjpbInNjaW0iLCJvcGVuaWQiLCJjbG91ZF9jb250cm9sbGVyIiwicGFzc3dvcmQiXX0.n00vPTM7XydLyYukAAr0NtIKILpwPgDqxKEnRLTwVng
Content-Length : 0
RESPONSE: [200]
@mgarciap
mgarciap / gist:5504998
Created May 2, 2013 20:07
vagrant@precise64:~/micro/scripts$ sudo -E ./create_mcf.sh After a long, long time..
Starting micro bosh compilation
Starting BOSH Agent for compiling micro bosh package, agent pid is 22600
#[22600] INFO: Configuring Agent with: {"configure"=>false, "logging"=>{"level"=>"DEBUG"}, "mbus"=>"https://vcap:vcap@localhost:6969", "agent_id"=>"not_configured", "blobstore_options"=>{"blobstore_path"=>"/var/vcap/micro_bosh/data/cache"}, "blobstore_provider"=>"local", "infrastructure_name"=>"vsphere", "platform_name"=>"ubuntu", "base_dir"=>"/var/vcap", "smtp_port"=>2825, "process_alerts"=>true, "heartbeat_interval"=>60}
#[22600] INFO: Starting agent 1.5.0.pre.3...
#[22600] INFO: Skipping configuration step (use '-c' argument to configure on start)
#[22600] INFO: Starting up https agent
I, [2013-05-02T20:00:11.050639 #22622] INFO -- : Creating Blobstore client with local provider and options {"blobstore_path"=>"/var/vcap/micro_bosh/data/cache"}
I, [2013-05-02T20:00:11.092354 #22622] INFO -- : Compiling /var/vcap/bosh/src/micro_bosh/release.yml with tarball /var/vcap/bosh/src/micro_bosh/release.tgz
#[2
Starting micro bosh compilation
Starting BOSH Agent for compiling micro bosh package, agent pid is 25069
#[25069] INFO: Configuring Agent with: {"configure"=>false, "logging"=>{"level"=>"DEBUG"}, "mbus"=>"https://vcap:vcap@localhost:6969", "agent_id"=>"not_configured", "blobstore_options"=>{"blobstore_path"=>"/var/vcap/micro_bosh/data/cache"}, "blobstore_provider"=>"local", "infrastructure_name"=>"vsphere", "platform_name"=>"ubuntu", "base_dir"=>"/var/vcap", "smtp_port"=>2825, "process_alerts"=>true, "heartbeat_interval"=>60}
#[25069] INFO: Starting agent 1.5.0.pre.3...
#[25069] INFO: Skipping configuration step (use '-c' argument to configure on start)
#[25069] INFO: Starting up https agent
#[25069] INFO: Message processors: {"migrate_disk"=>Bosh::Agent::Message::MigrateDisk, "list_disk"=>Bosh::Agent::Message::ListDisk, "mount_disk"=>Bosh::Agent::Message::MountDisk, "unmount_disk"=>Bosh::Agent::Message::UnmountDisk, "state"=>Bosh::Agent::Message::State, "drain"=>Bosh::Agent::Message::Drain, "apply"=>Bosh::A
@mgarciap
mgarciap / gist:5637749
Created May 23, 2013 17:17
Error running 'sudo ./bosh/bin/monit start all' for the micro_ng
Every 2.0s: ./bosh/bin/monit summary Thu May 23 16:33:40 2013
The Monit daemon 5.2.4 uptime: 5m
Process 'postgres' running
Process 'nats' running
Process 'warden' running
Process 'dea_next' running
Process 'dir_server' running
Process 'health_manager_next' running
[cf-install] Running provisioner: chef_solo...
Generating chef JSON and uploading...
Running chef-solo...
stdin: is not a tty
[2013-05-27T18:42:06+00:00] INFO: *** Chef 10.14.2 ***
[2013-05-27T18:42:07+00:00] INFO: Setting the run_list to ["recipe[apt::default]", "recipe[git]", "recipe[chef-golang]", "recipe[ruby_build]", "recipe[rbenv::user]", "recipe[java::openjdk]", "recipe[sqlite]", "recipe[mysql::server]", "recipe[postgresql::server]", "recipe[rbenv-alias]", "recipe[rbenv-sudo]", "recipe[cloudfoundry::warden]", "recipe[cloudfoundry::dea]", "recipe[cloudfoundry::uaa]"] from JSON
[2013-05-27T18:42:07+00:00] INFO: Run List is [recipe[apt::default], recipe[git], recipe[chef-golang], recipe[ruby_build], recipe[rbenv::user], recipe[java::openjdk], recipe[sqlite], recipe[mysql::server], recipe[postgresql::server], recipe[rbenv-alias], recipe[rbenv-sudo], recipe[cloudfoundry::warden], recipe[cloudfoundry::dea], recipe[cloudfoundry::uaa]]
[2013-05-27T18:42:07+00:00] INFO: Run List expands to [apt::default, git, c
vagrant@precise64:/vagrant/test-apps/hello-node$ cf push
Name> node
Instances> 1
Custom startup command> node app.js
1: 64M
2: 128M
3: 256M