Capturing Output in Capistrano

Posted about 1 year back at BlogFish - Jonathan Weiss

A common question about Capistrano tasks is how to capture the output of a task. By default Capistrano will just execute your command and ignore any output.

But sometimes you want to capture and log the output. There is no easy command to do this right now, you have to use the SSH channels:

run "cat /etc/passwd " do |ch, stream, data|
  if stream == :err
    logger.debug "capured output on STDERR: #{data}"
  else # stream == :out
    logger.debug "capured output on STDOUT: #{data}"
  end
end

You can even send data back depending on the captured output:

run "mysql -u root my_database -p < /tmp/dump.sql" do |ch, stream, data|
  if data =~ /password:/
    ch.send_data(root_password)
  end
end

Using this technique you can store command output in the Webistrano log or just print it if you are using stock Capistrano.

DHH's Keynote at RailsConf Europe 2007

Posted about 1 year back at Ruby Inside

Dhhnotes

The guys at RailsOnWave have done a great job of recording David Heinemeier Hansson's keynote speech at the latest RailsConf Europe and have put it online, viewable within a Flash video player. Nice work!

JRuby compiler finished

Posted about 1 year back at InfoQ Personalized Feed for unregistered user - Register to upgrade!

As Charles Nutter reports, JRuby's Ruby to Bytecode compiler is finished. This is used for AOT and JIT compilation, and will go into JRuby 1.1. Future plans include a compiler that could help with Java integration by turning Ruby classes into Java types.

Probable Iterations (#141)

Posted about 1 year back at Ruby Quiz

by Kenneth Kin Lum

You just did some probability calculations, and don't know if the answers are correct. So you write a program to verify the results. If you have eight dice, and throw them all at once, what is the probability that there are AT LEAST three fives? Try to write a program that find out the "number of desirable outcomes" / "number of possible outcomes" by iterating through all the possible outcomes of the dice throw. It has a verbose mode to see that the program is running correctly (for the case 2 dice, at least 1 five):

C:\rails\depot>ruby dice.rb -v 2 1
1 [1,1]
2 [2,1]
3 [3,1]
4 [4,1]
5 [5,1] <==
6 [6,1]
7 [1,2]
8 [2,2]
9 [3,2]
10 [4,2]
11 [5,2] <==
12 [6,2]
13 [1,3]
14 [2,3]
15 [3,3]
16 [4,3]
17 [5,3] <==
18 [6,3]
19 [1,4]
20 [2,4]
21 [3,4]
22 [4,4]
23 [5,4] <==
24 [6,4]
25 [1,5] <==
26 [2,5] <==
27 [3,5] <==
28 [4,5] <==
29 [5,5] <==
30 [6,5] <==
31 [1,6]
32 [2,6]
33 [3,6]
34 [4,6]
35 [5,6] <==
36 [6,6]

Number of desirable outcomes is 11
Number of possible outcomes is 36

Probability is 0.3055555555555556

C:\rails\depot>ruby dice.rb 8 3

Number of desirable outcomes is 226491
Number of possible outcomes is 1679616

Probability is 0.1348468935756745

It also has a "sample mode" to print out the samples every 50,000 times in the loop:

C:\rails\depot>ruby dice.rb -s 8 3
1 [1,1,1,1,1,1,1,1]
50001 [3,6,3,4,3,1,2,1]
100001 [5,5,6,1,6,1,3,1]
150001 [1,5,3,5,2,2,4,1]
200001 [3,4,6,2,5,2,5,1]
250001 [5,3,3,6,1,3,6,1]
300001 [1,3,6,3,4,3,1,2]
350001 [3,2,3,1,1,4,2,2]
400001 [5,1,6,4,3,4,3,2]
450001 [1,1,3,2,6,4,4,2]
500001 [3,6,5,5,2,5,5,2] <==
550001 [5,5,2,3,5,5,6,2] <==
600001 [1,5,5,6,1,6,1,3]
650001 [3,4,2,4,4,6,2,3]
700001 [5,3,5,1,1,1,4,3]
750001 [1,3,2,5,3,1,5,3]
800001 [3,2,5,2,6,1,6,3]
850001 [5,1,2,6,2,2,1,4]
900001 [1,1,5,3,5,2,2,4]
950001 [3,6,1,1,2,3,3,4]
1000001 [5,5,4,4,4,3,4,4]
1050001 [1,5,1,2,1,4,5,4]
1100001 [3,4,4,5,3,4,6,4]
1150001 [5,3,1,3,6,4,1,5]
1200001 [1,3,4,6,2,5,2,5]
1250001 [3,2,1,4,5,5,3,5] <==
1300001 [5,1,4,1,2,6,4,5]
1350001 [1,1,1,5,4,6,5,5] <==
1400001 [3,6,3,2,1,1,1,6]
1450001 [5,5,6,5,3,1,2,6] <==
1500001 [1,5,3,3,6,1,3,6]
1550001 [3,4,6,6,2,2,4,6]
1600001 [5,3,3,4,5,2,5,6] <==
1650001 [1,3,6,1,2,3,6,6]

Number of desirable outcomes is 226491
Number of possible outcomes is 1679616

Probability is 0.1348468935756745

Webistrano 1.1 released

Posted about 1 year back at BlogFish - Jonathan Weiss

Webistrano 1.1 is finally out. Webistrano is a Web UI for managing Capistrano deployments. It lets you manage projects and their stages like test, production, and staging with different settings.

It took a little longer because we got some feedback at Rails Conf Europe that we incorporated.

Further Webistrano now has its new home and own Trac/Wiki/Ticketsystem at the Peritor Labs. Peritor Labs is the place where we are going to release inhouse projects like Webistrano under the BSD license. At the moment there is only Webistrano but more will follow.

This means that the Subversion URL also changed. If you tracked Webistrano through svn, please switch to new URL:

svn switch --relocate http://webistrano.rubyforge.org/svn/trunk/ \
http://webistrano.rubyforge.org/svn/trunk http://labs.peritor.com/svn/webistrano/trunk

The major change in version 1.1 is a new shiny UI by the curtsy of Marcus Lamer.

Check out some new screenshots.

Further recipes are now associated to stages and not projects anymore so that different stages of a project can have different recipes. Webistrano now also set two variables inside recipes by default. Those two variables ( :webistrano_project and :webistrano_stage) are set to the project and stage name and can be used to do some decision making inside your recipes.

Upgrading from 1.0 is quite easy, just download the new version, copy your configuration files over and upgrade the database:

RAILS_ENV=production rake db:migrate

The roadmap for the next versions includes some basic monitoring capabilities and some form of permission management that lets you manage which user can deploy which projects and so on. The screencasts have not been updated yet but the content they provide is still valid, the only change is that recipes now belong to stages.

If you have any feedback, please comment here or use the Wiki.

Direct download link: webistrano-1.1.zip or at the Peritor Labs project page.

Managing EC2 Reservations with Ruby

Posted about 1 year back at igvita.com

Over the course of past couple of weeks the guys (and gals!) at Amazon have hosted a number of great 'AWS Start-Up' events to evangelize their services and share the stories of some of the startups that have come to fruition based on their platform. I've had a chance to attend the New York event, as well as present in Boston earlier today - kudos to the AWS team for putting together these events, we've met dozens of exciting new startups, entrepreneurs, and a lot of the AWS team itself.

Interestingly enough, watching the presentations and even talking to a lot of the developers in the crowd resulted in very similar pain points: server monitoring, management, and automation. Hence, below is a modest contribution (a Ruby script) for terminating an entire reservation of EC2 instances on the fly. Instead of manually specifying each instance id, you can give it a reservation number (r-xxxxxxx) and all the machines will be shut down:

> ec2-terminate-reservation.rb

#!/usr/bin/ruby
 
reservation = ARGV[0]
if reservation.nil?
    puts "No reservation id"
    exit
end
 
instances = []
collect = false
`ec2-describe-instances`.each_line { |l|
    l = l.chomp.split("\\t")
    if l[1] == reservation
        collect = true
        next
    end
 
    collect = false if collect and l.first == "RESERVATION"
 
    instances << l[1] if collect
}
 
puts "Terminating #{instances.size} servers: #{instances.join(' ')}"
`$EC2_HOME/bin/ec2-cmd TerminateInstances #{instances.join(' ')}`
 

To use this as any regular EC2 management command copy the provided file into your $EC2_HOME directory, and you're all ready to go. A sample use case would be:

ilya@tux:~$ ec2-terminate-reservation r-f707e49e
Terminating 5 servers: i-348d635d i-378d635e i-368d635f i-098d6360 i-088d6361

Managing EC2 Reservations with Ruby

Posted about 1 year back at igvita.com

Over the course of past couple of weeks the guys (and gals!) at Amazon have hosted a number of great ‘AWS Start-Up‘ events to evangelize their services and share the stories of some of the startups that have come to fruition based on their platform. I’ve had a chance to attend the New York event, as well as present in Boston earlier today - kudos to the AWS team for putting together these events, we’ve met dozens of exciting new startups, entrepreneurs, and a lot of the AWS team itself.

Interestingly enough, watching the presentations and even talking to a lot of the developers in the crowd resulted in very similar pain points: server monitoring, management, and automation. Hence, below is a modest contribution (a Ruby script) for terminating an entire reservation of EC2 instances on the fly. Instead of manually specifying each instance id, you can give it a reservation number (r-xxxxxxx) and all the machines will be shut down:

> ec2-terminate-reservation.rb

#!/usr/bin/ruby
 
reservation = ARGV[0]
if reservation.nil?
    puts "No reservation id"
    exit
end
 
instances = []
collect = false
`ec2-describe-instances`.each_line { |l|
    l = l.chomp.split("\t")
    if l[1] == reservation
        collect = true
        next
    end
 
    collect = false if collect and l.first == "RESERVATION"
 
    instances << l[1] if collect
}
 
puts "Terminating #{instances.size} servers: #{instances.join(' ')}"
`$EC2_HOME/bin/ec2-cmd TerminateInstances #{instances.join(' ')}`

To use this as any regular EC2 management command copy the provided file into your $EC2_HOME directory, and you’re all ready to go. A sample use case would be:

ilya@tux:~$ ec2-terminate-reservation r-f707e49e
Terminating 5 servers: i-348d635d i-378d635e i-368d635f i-098d6360 i-088d6361

, , ,

Managing EC2 Reservations with Ruby

Posted about 1 year back at igvita.com

Over the course of past couple of weeks the guys (and gals!) at Amazon have hosted a number of great 'AWS Start-Up' events to evangelize their services and share the stories of some of the startups that have come to fruition based on their platform. I've had a chance to attend the New York event, as well as present in Boston earlier today - kudos to the AWS team for putting together these events, we've met dozens of exciting new startups, entrepreneurs, and a lot of the AWS team itself.

Interestingly enough, watching the presentations and even talking to a lot of the developers in the crowd resulted in very similar pain points: server monitoring, management, and automation. Hence, below is a modest contribution (a Ruby script) for terminating an entire reservation of EC2 instances on the fly. Instead of manually specifying each instance id, you can give it a reservation number (r-xxxxxxx) and all the machines will be shut down:

> ec2-terminate-reservation.rb

#!/usr/bin/ruby
 
reservation = ARGV[0]
if reservation.nil?
    puts "No reservation id"
    exit
end
 
instances = []
collect = false
`ec2-describe-instances`.each_line { |l|
    l = l.chomp.split("\\t")
    if l[1] == reservation
        collect = true
        next
    end
 
    collect = false if collect and l.first == "RESERVATION"
 
    instances << l[1] if collect
}
 
puts "Terminating #{instances.size} servers: #{instances.join(' ')}"
`$EC2_HOME/bin/ec2-cmd TerminateInstances #{instances.join(' ')}`
 

To use this as any regular EC2 management command copy the provided file into your $EC2_HOME directory, and you're all ready to go. A sample use case would be:

ilya@tux:~$ ec2-terminate-reservation r-f707e49e
Terminating 5 servers: i-348d635d i-378d635e i-368d635f i-098d6360 i-088d6361

But Macs Are So Expensive!

Posted about 1 year back at RailsJitsu

Ok, enough of this bullshit line already. Every time I start introducing what it is like to develop software on a Mac I get some cheapskate ass wipe who claims that Macs are too expensive and that is as far as they want to go with the conversation.

First off, you are a hacker, not a bus boy. You make good money for today’s market. You make far more than a mechanic, a teacher, and even quite a few attorneys. You aren’t in the soup line (and I have been at one time).

To dispel this myth straight off, a Mac Mini costs $500. I have spent that on a single tattoo, a night out with a hot girl (and no, I am talking about paying for the night, not paying the girl for 1 night), and even on weed, back when I was into that sort of thing.

But here is the real kicker. I coded on Windows for nigh on 11 years. First I was a Visual C++ guy, then onto VB, then into the world of ASP and SQL Server, and finally ASP.Net and C#. The cost of the software it takes to do enterprise (Know what makes something enterprise? Add a few zeros on the end of the price tag.) is astounding. And guess what? I stole my software.

Yes that’s right, I stole my copies of Visual Studio, HomeSite, and Photoshop. And so did ever single developer I ever worked with. The companies paid for their licenses, we stole ours. And with price tags of $300 to $1200 it is no wonder!

However in the world of Mac I find that almost every piece of software I end up using permanently is under $100. Photoshop being the one exception that I still have my boss buy. And most of the best stuff like Quicksilver is free.

So the next time a die in the wool Windows coder tells me a Mac is too expensive I think I’ll just punch him in his lying mouth.

Point in case….


MacBook Pro $3000
TextMate $55
MySQL FREE

Having a hottie ask me about my notebook? Priceless!

I mean really, how often has a nice looking (Southern Cali Standards) girl asked you about your Dell?

Besides, using a combination of OS X, Quicksilver, TextMate (while I use for EVERYTHING text, in fact I am writing this blog post now in it), and Ruby on Rails my productivity has gone through the roof.

Bottom line, getting a Mac is not costly, it has great advantages, and you can look cool while using it. it is what separates the Geek from the Hacker to the rest of the world, and to us technology savvy folk, it is what separates those who are passionate about what they do, how they do it, and what tools they use, and the robots.

I’ve ranted enough, feel free to argue with me Windows boys.

WTF: The Mythical Business Layer

Posted about 1 year back at Segment7

Worse Than Failure made a post a few days ago about, among other things, built-in complexity, especially where its unnecessary and unsuited for getting things done.

Just look at the dreadful specs we’re given to work with:

When a Sale is Cleared, only Managers with Void Approval and Executives may issue a Cancellation Request. If the Propagation Status for the Transferable Receivable is not Pending and the Expense Allocation Type is Reversible, the Cancellation Request is issued for Processing; otherwise, it is issued for Approval.

I’m sure those of you who managed to make it through that spec did not have visions of IF-ELSE code blocks swirling through your head. I’ll bet some of you, without even seeing the rest of specs, excitedly envisioned a CancelationWorkflowProvider that inherited from the abstract RequestWorkflowProvider and implemented the IPermissionRequired, IPropogationStatusRequired, and IExpenseAllocationTypeRequired interfaces, and was powered by the all-encompassing WorkflowManager. Why? Because that’s so much more challenging than writing a simple IF-ELSE code block.

The Mythical Business Layer via Worse Than Failure

While the post focuses on the “business layer” of an application, its applicable to any development. There’s no need to write that extra library! Start with the core of you want to do, and grow, then refactor, then grow again. Reuse what already exists unless it can’t be molded to your will. If your application code gets too big pull a library out. Don’t write the library up-front, you don’t need it and you won’t need it.

Getting started with Rubinius development

Posted about 1 year back at InfoQ Personalized Feed for unregistered user - Register to upgrade!

Rubinius is quickly gathering interest and is coming close to Ruby support. We take a look at Rubinius development, what to check out and where to start.

But Macs Are So Expensive!

Posted about 1 year back at RailsJitsu

Macs are too expensive…. Ok, enough of this bullshit line already. Every time I start introducing what it is like to develop software on a Mac I get some cheapskate ass-wipe who claims that Macs are too expensive and that is as far as they want to go with the conversation.

Ok, enough of this bullshit line already. Every time I start introducing what it is like to develop software on a Mac I get some cheapskate ass wipe who claims that Macs are too expensive and that is as far as they want to go with the conversation.

First off, you are a hacker, not a bus boy. You make good money for today’s market. You make far more than a mechanic, a teacher, and even quite a few attorneys. You aren’t in the soup line (and I have been at one time).

To dispel this myth straight off, a Mac Mini costs $500. I have spent that on a single tattoo, a night out with a hot girl (and no, I am talking about paying for the night, not paying the girl for 1 night), and even on weed, back when I was into that sort of thing.

But here is the real kicker. I coded on Windows for nigh on 11 years. First I was a Visual C++ guy, then onto VB, then into the world of ASP and SQL Server, and finally ASP.Net and C#. The cost of the software it takes to do enterprise (Know what makes something enterprise? Add a few zeros on the end of the price tag.) is astounding. And guess what? I stole my software.

Yes that’s right, I stole my copies of Visual Studio, HomeSite, and Photoshop. And so did ever single developer I ever worked with. The companies paid for their licenses, we stole ours. And with price tags of $300 to $1200 it is no wonder!

However in the world of Mac I find that almost every piece of software I end up using permanently is under $100. Photoshop being the one exception that I still have my boss buy. And most of the best stuff like Quicksilver is free.

So the next time a die in the wool Windows coder tells me a Mac is too expensive I think I’ll just punch him in his lying mouth.

Point in case….

MacBook Pro         $3000
TextMate            $55
MySQL               FREE

Having a hottie ask me about my notebook? Priceless!

I mean really, how often has a nice looking (Southern Cali Standards) girl asked you about your Dell?

Besides, using a combination of OS X, Quicksilver, TextMate (while I use for EVERYTHING text, in fact I am writing this blog post now in it), and Ruby on Rails my productivity has gone through the roof.

Bottom line, getting a Mac is not costly, it has great advantages, and you can look cool while using it. it is what separates the Geek from the Hacker to the rest of the world, and to us technology savvy folk, it is what separates those who are passionate about what they do, how they do it, and what tools they use, and the robots.

I’ve ranted enough, feel free to argue with me Windows boys.

But Macs Are So Expensive!

Posted about 1 year back at RailsJitsu

Macs are too expensive…. Ok, enough of this bullshit line already. Every time I start introducing what it is like to develop software on a Mac I get some cheapskate ass-wipe who claims that Macs are too expensive and that is as far as they want to go with the conversation.

Ok, enough of this bullshit line already. Every time I start introducing what it is like to develop software on a Mac I get some cheapskate ass wipe who claims that Macs are too expensive and that is as far as they want to go with the conversation.

First off, you are a hacker, not a bus boy. You make good money for today’s market. You make far more than a mechanic, a teacher, and even quite a few attorneys. You aren’t in the soup line (and I have been at one time).

To dispel this myth straight off, a Mac Mini costs $500. I have spent that on a single tattoo, a night out with a hot girl (and no, I am talking about paying for the night, not paying the girl for 1 night), and even on weed, back when I was into that sort of thing.

But here is the real kicker. I coded on Windows for nigh on 11 years. First I was a Visual C++ guy, then onto VB, then into the world of ASP and SQL Server, and finally ASP.Net and C#. The cost of the software it takes to do enterprise (Know what makes something enterprise? Add a few zeros on the end of the price tag.) is astounding. And guess what? I stole my software.

Yes that’s right, I stole my copies of Visual Studio, HomeSite, and Photoshop. And so did ever single developer I ever worked with. The companies paid for their licenses, we stole ours. And with price tags of $300 to $1200 it is no wonder!

However in the world of Mac I find that almost every piece of software I end up using permanently is under $100. Photoshop being the one exception that I still have my boss buy. And most of the best stuff like Quicksilver is free.

So the next time a die in the wool Windows coder tells me a Mac is too expensive I think I’ll just punch him in his lying mouth.

Point in case….

MacBook Pro         $3000
TextMate            $55
MySQL               FREE

Having a hottie ask me about my notebook? Priceless!

I mean really, how often has a nice looking (Southern Cali Standards) girl asked you about your Dell?

Besides, using a combination of OS X, Quicksilver, TextMate (while I use for EVERYTHING text, in fact I am writing this blog post now in it), and Ruby on Rails my productivity has gone through the roof.

Bottom line, getting a Mac is not costly, it has great advantages, and you can look cool while using it. It is what separates the Geek from the Hacker to the rest of the world, and to us technology savvy folk, it is what separates those who are passionate about what they do, how they do it, and what tools they use, and the robots.

I’ve ranted enough, feel free to argue with me Windows boys.

UC Berkley teaches Ruby on Rails

Posted about 1 year back at Riding Rails - home

UC Berkley is teaching Ruby on Rails in it’s CS198 Rad Labs class. The class is being taught by Dave Patterson, the creator of RISC, SPARC, RAID, and more. Quite an adorsement.

UC Berkeley teaches Ruby on Rails

Posted about 1 year back at Riding Rails - home

UC Berkeley is teaching Ruby on Rails in its CS198 Rad Labs class. The class is being taught by Dave Patterson, the creator of RISC, SPARC, RAID, and more. Quite an endorsement.


1 ... 515 516 517 518 519 ... 634