background preloader

Bundler: The best way to manage a Ruby application's gems

Bundler: The best way to manage a Ruby application's gems

Getting Started with Rails 1 Guide Assumptions This guide is designed for beginners who want to get started with a Rails application from scratch. It does not assume that you have any prior experience with Rails. Rails is a web application framework running on the Ruby programming language. Be aware that some resources, while still excellent, cover versions of Ruby as old as 1.6, and commonly 1.8, and will not include some syntax that you will see in day-to-day development with Rails. 2 What is Rails? Rails is a web application development framework written in the Ruby programming language. Rails is opinionated software. The Rails philosophy includes two major guiding principles: Don't Repeat Yourself: DRY is a principle of software development which states that "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." 3 Creating a New Rails Project The best way to read this guide is to follow it step by step. 3.1 Installing Rails Open up a command line prompt. 9 Security

Ruby Readline What is Readline? The GNU Readline Library’s website sums it up best: The GNU Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. (…) The Readline library includes additional functions to maintain a list of previously-entered command lines, to recall and perhaps reedit those lines, and perform csh-like history expansion on previous commands. Users that have worked with the shell are very familiar with readline. This is the library that provides ⌃A, ⌃E, ↑, ↓, and a number of other keyboard shortcuts that you probably expect to have when working in a shell. Ruby ships with support for working with readline (or libedit). It takes just a few lines of Ruby to get the basic functionality and the core advantages that Readline provides such as keyboard shortcuts and history. Basic Functionality Here is the standard Ruby readline sample program: while line = Readline.readline('> ', true) p line end The Readline Module

When NoSQL Databases Are — Yes — Good For You And Your Company The proliferation of non-relational databases in the tech sector these days could lead you to think that these data management tools (also known as NoSQL databases) are eventually going to make traditional relational databases extinct. Not so. Each of these database types is best suited for very different types of workloads, and that's going to prevent either one from tromping the other into the dust. Which means that IT and other managers are going to have to figure out which approach is best suited for the task at hand. In this two-part series, I'll examine the capabilities of both NoSQL and relational databases to help you make the right decisions for your organization. "NoSQL"? Right off the bat, NoSQL databases are unique because they are usually independent from Structured Query Language (SQL) found in relational databases. See also: Relational Databases Aren't Dead—Heck, They're Not Even Sleeping NoSQL databases are designed to excel in speed and volume. Go Big Or Go Home Downtime?

Ruby Programming Language Home Mongoid (pronounced mann-goyd) is an Object-Document-Mapper (ODM) for MongoDB written in Ruby. It was conceived in August, 2009 during a whiskey-induced evening at the infamous Oasis in Florida, USA by Durran Jordan. The philosophy of Mongoid is to provide a familiar API to Ruby developers who have been using Active Record or Data Mapper, while leveraging the power of MongoDB's schemaless and performant document-based design, dynamic queries, and atomic modifier operations. This is the site for Mongoid 3 documentation, along with Origin and Moped. If you want the Mongoid 2 docs, please go here. class Artist include Mongoid::Document field :name, type: String embeds_many :instrumentsend class Instrument include Mongoid::Document field :name, type: String embedded_in :artistend syd = Artist.where(name: "Syd Vicious").between(age: 18..25).first syd.instruments.create(name: "Bass") syd.with(database: "bands", session: "backup").save!

Learning Ruby with the EdgeCase Ruby Koans Stupid Ruby Tricks Ruby Best Practices - Reading Ruby's Standard Library for Fun and Profit Note: This post is inspired by JEG2’s excellent code reading talk at MWRC 2009, called LittleBIGRuby. Go watch it if you have time, then come back and read this. You might also want to check out the Question 5 Ways interview at Pat Eyler’s “On Ruby” blog for more code reading goodness. We all need to hunt bugs and we all need to integrate our code with other systems. Some of us need to make use of undocumented libraries, and others need to examine code to perform security audits. Why is it then, that so many developers suck at reading code? Almost a decade ago, Joel Spolsky would have told you it’s harder to read code than it is to write it , and that was probably true at one point. Beginners and even intermediate developers may need a lot of hand holding at first, that’s only to be expected. But where should you start? How I Read Code I’m going to walk through the process I generally follow when I’m reading code for the purpose of understanding its implementation. if defined?

Ruby Programming/Unit testing - Wikibooks, collection of open-content textbooks Unit testing is a great way to catch errors early in the development process, if you dedicate time to writing appropriate and useful tests. As in other languages, Ruby provides a framework in its standard library for setting up, organizing, and running tests called Test::Unit. There are other very popular testing frameworks, rspec and cucumber come to mind. Specifically, Test::Unit provides three basic functionalities: A way to define basic pass/fail tests.A way to gather like tests together and run them as a group.Tools for running single tests or whole groups of tests. A Simple Introduction[edit] First create a new class. # File: simple_number.rb class SimpleNumber def initialize(num) raise unless num.is_a? Let's start with an example to test the SimpleNumber class. Which produces >> ruby tc_simple_number.rb Loaded suite tc_simple_number Started . So what happened here? Let's try a more complicated example. >> ruby tc_simple_number2.rb Loaded suite tc_simple_number2 Started F.. Exercises[edit]

Iterate over a cartesian product. 2010/9/15 Jörg W Mittag removed_email_address@domain.invalid: This looks nice. How did you do the formatting? By hand 14:09:29 ~$ gem19 install ‘By hand’ ERROR: could not find gem By hand locally or in a repository 14:09:58 ~$ Hm… => nil That’s nice. Unfortunately there is no #slice which has two return values. a,b = arr.slice 0,1 But we can do this to achieve the same (i.e. non destructively partitioning): irb(main):016:0> a=(1…5).to_a => [1, 2, 3, 4, 5] irb(main):017:0> y=(x=a.dup).slice! Well, I guess the simplest approach is still irb(main):001:0> a=(1…5).to_a => [1, 2, 3, 4, 5] irb(main):002:0> x,*y = a => [1, 2, 3, 4, 5] irb(main):003:0> x => 1 irb(main):004:0> y => [2, 3, 4, 5] So we can do Kind regards robert

Related: