background preloader

Ruby

Facebook Twitter

Understanding how Ruby stores objects in memory - the Ruby Heap - The Irish Penguin. Ruby has it's own heap management which actually consists of several 'Ruby Heaps' to manage objects created during the execution of a Ruby program; this is separate from the System Heap for your Operating System.

Understanding how Ruby stores objects in memory - the Ruby Heap - The Irish Penguin

Each individual Ruby Heap contains Slots, with each Slot able to one reference one object. The entire space that an object takes up in memory is not stored inside the Slot. Rather each Slot is a small fixed size space which can be thought of as the Ruby interpreter's handle a location in memory. This location exists outside of the Ruby Heap itself and contains the real 'meat' of the object. JavaScript Meets Ruby: John Barnette Explains Johnson. Some technologies are so unique and unusual we sometimes question why they exist in the first place.

JavaScript Meets Ruby: John Barnette Explains Johnson

Segway's personal transporter is one example, and Ruby's Johnson library to access JavaScript from Ruby is another. To understand this technology we had an online chat with Johnson's creator and lead developer John Barnette in Seattle. But before we start let's bring some context into this topic. AJAX relies primarily on the availability of a DOM, an XMLHTTPRequest object and capable JavaScript to perform what looks like a desktop app on a website or what we refer to as Web2.0. Few developers however have felt the need to build a bridge between JavaScript on the client and Ruby on the server. Johnson's purpose however is to shed light on what goes behind the scenes and make automated AJAX testing possible. Johnson got created for a couple of reasons. Debugging Ruby. Garbage Collection and the Ruby Heap. Ruby object allocation & why you should care. Recently I was tasked with finding how to optimize a web application with heavy traffic.

Ruby object allocation & why you should care

The application (a Rails 2.3.x app) gets about 3 million requests per hour and most of these requests cannot really be easily cached so they go through the entire stack. This is probably not the case of most web apps out there. None the less, my findings my help you understand Ruby better and maybe think differently about memory management. This is certainly not an advanced GC blog post, I will try to keep it as simple as possible.

My goal is to show you how Ruby memory allocation works and why it can affect your app performance and finally, how can you avoid to allocate to many objects. Home · cucumber/cucumber Wiki. Ruby on Rails Tutorial. Writing Own Ruby Methods. Ruby Summary. The Bastards Book of Ruby. Compilation - Compile ruby script into exe. FAQ · rdp/ruby_tutorials_core Wiki. Welcome to the list of Frequently Asked Questions on the ruby-talk mailing list !

FAQ · rdp/ruby_tutorials_core Wiki

Feel free to add to it! Jamescook/RubyRedditAPI. Ashbb/green_shoes. Ashbb/green_shoes. Mwunsch/tumblr. Ruby ri Tool. Sequel: The Database Toolkit for Ruby. Ruby DBI: Database Access. Troubleshooters.Com and Code Corner and Ruby Revival Present Ruby Database ConnectivityCopyright (C) 2006 by Steve Litt Note: All materials in Ruby Revival are provided AS IS.

Ruby DBI: Database Access

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 Ruby Revival of any responsibility for the outcome of any use of these materials, even in the case of errors and/or omissions in the materials. Ruby/DBI Tutorial. This session will teach you how to access a database using Ruby.

Ruby/DBI Tutorial

The Ruby DBI module provides a database-independent interface for Ruby scripts similar to that of the Perl DBI module. DBI stands for Database independent interface for Ruby which means DBI provides an abstraction layer between the Ruby code and the underlying database, allowing you to switch database implementations really easily. It defines a set of methods, variables, and conventions that provide a consistent database interface, independent of the actual database being used. DBI can interface with the following: Ruby QuickRef. Table of Contents Language General Tips These are tips I’ve given over and over and over and over…

Ruby QuickRef

Adding Type Checking to Ruby. 6 Feb 2008 What’s the first thing you think of when you consider the Ruby Language?

Adding Type Checking to Ruby

Dynamic types, right? Ruby is famous (infamous?) For its extremely flexible type system, and as a so-called “scripting language”, the core of this mechanism is a lack of type checking. This feature allows for some very concise expressions and a great deal of flexibility, but sometimes makes your code quite a bit harder to understand. Several different solutions have been proposed to workaround this limitation. Another, less common technique is to simply perform dynamic type checks within the method itself.

This code explicitly checking the dynamic kind of the parameter values to ensure that they are of type or subtype of String. Primarily, it’s ugly! Download Ruby. Here you can get the latest Ruby distributions in your favorite flavor.

Download Ruby

The current stable version is 3.0.2. Please be sure to read Ruby’s License. Ways of Installing Ruby We have several tools on each major platform to install Ruby: On Linux/UNIX, you can use the package management system of your distribution or third-party tools (rbenv and RVM). See the Installation page for details on using package management systems or third-party tools. Factory methods in Ruby. Matrices en Ruby : 1 - Attention ! On ne se refait pas...

Matrices en Ruby : 1 - Attention !

Ruby Exceptions. The execution and the exception always go together. If you are opening a file, which does not exist, then if you did not handle this situation properly, then your program is considered to be of bad quality. The program stops if an exception occurs. So exceptions are used to handle various type of errors, which may occur during a program execution and take appropriate action instead of halting program completely. Ruby provide a nice mechanism to handle exceptions. We enclose the code that could raise an exception in a begin/end block and use rescue clauses to tell Ruby the types of exceptions we want to handle. Force calculation result to BigDecimal. How Can I Store Key/Value Pairs in Ruby? Using Structs and OpenStructs. Question: How Can I Store Key/Value Pairs in Ruby?

When you need key/value storage in Ruby, it's easy to reach for hashes every time. However, you do have some other choices here that can make your code more readable and faster. Answer: Your first alternative option for key/value storage is the Struct. The Struct class is like a struct in C or C++ . #! Automating Windows and Their Controls With Ruby. Update: added part about handling popups. How would you automate windows and their controls like button and text fields if you had to? How would you do that in Ruby? I guess you wouldn’t. At least not in any user-friendly way. Until now. Let’s Start to RAutomate. Ruby on Windows. Why are You doomed being Ruby developer on Windows platform : Witold Rugowski aka NetManiac. Why are You doomed being Ruby developer on Windows platform Posted on February 5, 2008 - Filed Under Ruby If you're new here, you may want to subscribe to my RSS feed.

You can also get updates by email Thanks for visiting! Today I have lost several hours trying to figure what is going with Amazon S3 Ruby gem. A lot of stress and wasted three hours. And from debugger my todays troubles has began. Ruby Exceptions. Raising An Exception An exception is a special kind of object, an instance of the class Exception or a descendant of that class that represents some kind of exceptional condition; it indicates that something has gone wrong. When this occurs, an exception is raised (or thrown). By default, Ruby programs terminate when an exception occurs. But it is possible to declare exception handlers. An exception handler is a block of code that is executed if an exception occurs during the execution of some other block of code. Ruby Built-in Functions. Since the Kernel module is included by Object class, its methods are available everywhere in the Ruby program. They can be called without a receiver (functional form).

Therefore, they are often called functions. A complete list of Built-in Functions is given here for your reference: Functions for Numbers: Design Patterns in Ruby : The Factory Method. Ruby Modules and Mixins. Modules are a way of grouping together methods, classes, and constants. Modules give you two major benefits. Modules provide a namespace and prevent name clashes.Modules implement the mixin facility. Modules define a namespace, a sandbox in which your methods and constants can play without having to worry about being stepped on by other methods and constants.

Maths in Ruby

Charts. Considerations. Rails. Ruby & Java. Tutos. Ruby to Application. File & Directory Management. RubyGems. Data Management. GUI. Time & Calculation Limitations. Proxy Authentication in open-uri - comp.lang.ruby. Ruby at Work - Internet access through a Proxy Server. While reviewing Brian Marick's book "Scripting for Testers" (due out later this year or early next), I discovered that some of the internet access RUBY commands and scripts always failed when I tried them from work. Here's the weird thing - the same commands and scripts worked from my home computer. So what gives? I found the answer when I googled comp.lang.ruby and tinkered around in IRB from my work computer. It turned out to be the Proxy Server at work.

For lack of a better place to store this nugget of knowledge, this seems like a good place for now. Open a command prompt on a Windows machine, and launch IRB. You need to add the Proxy Server address (and user & password, if required) to the URL you are trying to access. Proxy_addr = 'your.proxy.host' proxy_port = 8080 response = Net::HTTP::Proxy(proxy_addr, proxy_port).get_response(host, path)---- => response.body now returns the page source, just like it does from my home computer. Proxy_addr = ' = 8080 text = page.read; nil----

Rubular: a Ruby regular expression editor and tester. Ruby Regexp Class - Regular Expressions in Ruby. Tutoriel HAML. HAML est un langage de template pour Ruby on Rails conçu pour créer des fichier HTML de manière rapide et élégante. Il se substitue au RHTML et apporte à Rails un vrai langage de template : clair, concis et puissant.

PLEAC-Ruby. Using the Ruby Development Tools plug-in for Eclipse. Editor's note: To learn what's new and changed in RDT since this article was written, read the developerWorks article "Easy Ruby development, the Eclipse way. " FrontPage - Ruby-GNOME2 Project Website. Open-uri: Ruby Standard Library Documentation. RinRuby. Installation Quick Start Examples: Gettysburg Regression Tim Churches Complete Documentation (from paper in Journal of Statistical Software) Authors: