background preloader

Ruby Tutorial with Code Samples

Ruby Tutorial with Code Samples

Creating Wizard Dialogs with Java Swing Oracle Technology Network > Java Software Downloads View All Downloads Top Downloads New Downloads What's New Java in the Cloud: Rapidly develop and deploy Java business applications in the cloud. Essential Links Developer Spotlight Java EE—the Most Lightweight Enterprise Framework? Blogs Technologies Contact Us About Oracle Cloud Events Top Actions News Key Topics Oracle Integrated Cloud Applications & Platform Services

Foodcritic - A lint tool for your Opscode Chef cookbooks Foodcritic has two goals: To make it easier to flag problems in your Chef cookbooks that will cause Chef to blow up when you attempt to converge. This is about faster feedback. If you automate checks for common problems you can save a lot of time. To encourage discussion within the Chef community on the more subjective stuff - what does a good cookbook look like? Prerequisites Foodcritic runs on Ruby (MRI) 1.9.2+ which depending on your workstation setup may be a more recent version of Ruby than you have installed. Installing RVM RVM can be installed from the current development code on the projects GitHub - however if you are just getting started with RVM I would recommend installing the latest stable version with the stable argument. See also this blog post from Michal Papis for more information: Installing Ruby 1.9.3 With RVM installed successfully you can now use it to install MRI 1.9.3:

Ruby Basic Tutorial Troubleshooters.Com, Code Corner and Ruby Revival Present Ruby Basic Tutorial Copyright (C) 2005 by Steve Litt Note: All materials in Ruby Revival are provided AS IS. By reading the materials in Ruby Revival you are agreeing to assume all risks involved in the use of the materials, and you are agreeing to absolve the authors, owners, and anyone else involved with Python Patrol of any responsibility for the outcome of any use of these materials, even in the case of errors and/or omissions in the materials. To the 99.9% of you honest readers who take responsibility for your own actions, I'm truly sorry it is necessary to subject all readers to the above disclaimer. CONTENTS This is a Ruby tutorial for one not knowing Ruby. Ruby can be used as a fully object oriented language, in which case you'd create classes and objects to accomplish everything. If that doesn't make any sense to you, don't worry, it's just a way of saying that Ruby can be very easy to learn and use. Let's count to 10...

Hello Ruby on Rails world | mentalized There is a newer version of this article updated for Rails 3 To some people Rails have a fairly high learning curve. And certainly, it’s somewhat higher than, say, PHP. This is a step by step tutorial to getting over the first hurdle: Creating a “hello world” application in Ruby on Rails. It works in Rails 1.0 assuming you have ruby and rails already installed and working on your system: rails hello cd hello ruby script\generate controller hello Create a file called index.rhtml in app/views/hello, containing “Hello world”. ruby script\server Navigate to in your browser and be greeted with your friendly application: “Hello world” PS: is a lot prettier “Hello world”-ish page.

Installing Chef — Ceph documentation Chef defines three types of entities: Chef Nodes: Run chef-client, which installs and manages software.Chef Server: Interacts with chef-client on Chef nodes.Chef Workstation: Manages the Chef server. See Chef Architecture Introduction for details. Create a chef User The chef-client command requires the proper privileges to install and manage installations. On each Chef node, we recommend creating a chef user with full root privileges. ssh user@chef-node sudo useradd -d /home/chef -m chef sudo passwd chef To provide full privileges, add the following to /etc/sudoers.d/chef. echo "chef ALL = (root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/chef sudo chmod 0440 /etc/sudoers.d/chef If you are using a version of sudo that doesn’t support includes, you will need to add the following to the /etc/sudoers file: chef ALL = (root) NOPASSWD:ALL Important Do not change the file permissions on /etc/sudoers. Generate SSH Keys for Chef Clients Chef’s knife tool can run ssh. You may use RSA or DSA keys. Tip

Ruby in Twenty Minutes Introduction This is a small Ruby tutorial that should take no more than 20 minutes to complete. It makes the assumption that you already have Ruby installed. (If you do not have Ruby on your computer install it before you get started.) Interactive Ruby Ruby comes with a program that will show the results of any Ruby statements you feed it. Open up IRB (which stands for Interactive Ruby). If you’re using macOS open up Terminal and type irb, then hit enter. irb(main):001:0> Ok, so it’s open. Type this: "Hello World" irb(main):001:0> "Hello World" => "Hello World" Ruby Obeyed You! What just happened? irb(main):002:0> puts "Hello World" Hello World => nil puts is the basic command to print something out in Ruby. Your Free Calculator is Here Already, we have enough to use IRB as a basic calculator: irb(main):003:0> 3+2 => 5 Three plus two. irb(main):004:0> 3*2 => 6 Next, let’s try three squared: irb(main):005:0> 3**2 => 9 In Ruby ** is the way you say “to the power of”. Ok, wait, what was that last one?

1.  Numbers Now that you've gotten everything setup , let's write a program! Open up your favorite text editor and type in the following: puts 1 + 2 Save your program (yes, that's a program!) Introduction to puts So what's going on in that program? puts 3 puts simply writes onto the screen whatever comes after it. Integer and Float In most programming languages (and Ruby is no exception) numbers without decimal points are called integers , and numbers with decimal points are usually called floating-point numbers , or more simply, floats Here are some integers: And here are some floats: In practice, most programs don't use floats; only integers. Simple Arithmetic So far, we've got all the makings of a simple calculator. puts 1.0 + 2.0 puts 2.0 * 3.0 puts 5.0 - 8.0 puts 9.0 / 2.0 This is what the program returns: (The spaces in the program are not important; they just make the code easier to read.) puts 1 + 2 puts 2 * 3 puts 5 - 8 puts 9 / 2 Mostly the same, right? Uh... except for that last one! A Few Things to Try

Bootstrap a Node — Chef Docs A node is any physical, virtual, or cloud machine that is configured to be maintained by a chef-client. There are two ways to install the chef-client on a node so that it may be maintained by the chef-client: knife bootstrap The knife bootstrap command is a common way to install the chef-client on a node. The default for this approach assumes that node can access the Chef website so that it may download the chef-client package from that location. The omnibus installer will detect the version of the operating system, and then install the appropriate version of the chef-client using a single command to install the chef-client and all of its dependencies, including an embedded version of Ruby, RubyGems, OpenSSL, key-value stores, parsers, libraries, and command line utilities. The omnibus installer puts everything into a unique directory (/opt/chef/) so that the chef-client will not interfere with other applications that may be running on the target machine. Run the bootstrap command Warning

Learn to Program, by Chris Pine A Place to Start for the Future Programmer I guess this all began back in 2002. I was thinking about teaching programming, and what a great language Ruby would be for learning how to program. I mean, we were all excited about Ruby because it was powerful, elegant, and really just fun, but it seemed to me that it would also be a great way to get into programming in the first place. Unfortunately, there wasn't much Ruby documentation geared for newbies at the time. And it wasn't very good. What saved me was that I made it really easy for people to contact me, and I always tried to help people when they got stuck. A couple of years later, it was getting pretty good. :-) So good, in fact, that I was ready to pronounce it finished, and move on to something else. It took me another year, but now I think it's really good, mostly because of the hundreds of brave souls who have helped me write it. What's here on this site is the original tutorial, more or less unchanged since 2004.

What is a Turing machine? © Copyright B.J. Copeland, July 2000 Turing first described the Turing machine in an article published in 1936, 'On Computable Numbers, with an Application to the Entscheidungsproblem', which appeared in Proceedings of the London Mathematical Society (Series 2, volume 42 (1936-37), pp. 230-265). The head and the tape A Turing machine is an idealised computing device consisting of a read/write head (or 'scanner') with a paper tape passing through it. The tape is divided into squares, each square bearing a single symbol--'0' or '1', for example. The input that is inscribed on the tape before the computation starts must consist of a finite number of symbols. The read/write head is programmable. States The head contains a subdevice that I call the indicator. Atomic operations There are just six types of fundamental operation that a Turing machine performs in the course of a computation. These are called the primitive or atomic operations of the machine. The instruction table An example

Related: