Skip to content

Instantly share code, notes, and snippets.

@matthewtodd
Created November 11, 2009 07:55

Revisions

  1. matthewtodd revised this gist Nov 11, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #!/usr/bin/env ruby
    #!/usr/bin/env ruby -wKU

    # I use 2 different Heroku accounts, one for my own apps and one for Amani's.
    # This script givens me a reasonable way to switch between them, with a little
  2. matthewtodd revised this gist Nov 11, 2009. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -7,16 +7,16 @@
    require 'pathname'
    require 'yaml'

    file = Pathname.new(ENV['HOME']).join('.heroku', 'credentials')
    config = YAML.load(DATA)
    credentials = Pathname.new(ENV['HOME']).join('.heroku', 'credentials')
    config = YAML.load(DATA)

    current_user = file.readlines.first.chomp
    current_user = credentials.readlines.first.chomp
    available_users = config.keys - [current_user]
    selected_user = available_users.abbrev[ARGV.shift]

    if password = config[selected_user]
    puts "Re-authenticating as #{selected_user}."
    file.open('w') do |file|
    credentials.open('w') do |file|
    file.puts(selected_user)
    file.puts(password)
    end
  3. matthewtodd revised this gist Nov 11, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@
    config = YAML.load(DATA)

    current_user = file.readlines.first.chomp
    available_users = config.keys.sort - [current_user]
    available_users = config.keys - [current_user]
    selected_user = available_users.abbrev[ARGV.shift]

    if password = config[selected_user]
  4. matthewtodd renamed this gist Nov 11, 2009. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. matthewtodd created this gist Nov 11, 2009.
    29 changes: 29 additions & 0 deletions gistfile1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    #!/usr/bin/env ruby

    # I use 2 different Heroku accounts, one for my own apps and one for Amani's.
    # This script givens me a reasonable way to switch between them, with a little
    # less typing than moving a symlink around. And I get to use abbrev!
    require 'abbrev'
    require 'pathname'
    require 'yaml'

    file = Pathname.new(ENV['HOME']).join('.heroku', 'credentials')
    config = YAML.load(DATA)

    current_user = file.readlines.first.chomp
    available_users = config.keys.sort - [current_user]
    selected_user = available_users.abbrev[ARGV.shift]

    if password = config[selected_user]
    puts "Re-authenticating as #{selected_user}."
    file.open('w') do |file|
    file.puts(selected_user)
    file.puts(password)
    end
    else
    puts "You are #{current_user}."
    end

    __END__
    [email protected]: ELIDED
    [email protected]: ELIDED