background preloader

Ruby User's Guide

Ruby User's Guide
Related:  PL

bbatsov/ruby-style-guide 19 Rails Tricks Most Rails Coders Don’t Know New to Rails 3? Check out the Ruby on Rails 3 Tutorial book and screencast. A book and screencast series showing you how to develop and deploy industrial-strength Rails apps in a direct, step by step way. The screencast series includes 12 lessons over more than 15 hours! Get the best "over the shoulder" experience of following what a top Rails 3 developer does when building an app today. Please note that this post is over four years old - it's from 2006! When looking at my own Rails code and that of the community as a whole, I often see places where certain Rails techniques could have been used, but weren't. Benchmark logic in your controller actions - It's really easy. User.benchmark("adding and deleting 1000 users") do 1000.times do User.create(:name => 'something') x = User.find_by_name('something') x.destroy endend Of course, your code would be a lot better ;-) The regular SQL logs are not shown when within the benchmark sections. You can learn a little more here.

PHP coding standards - tech.tmw.co.uk Coding Standards and Best Programming Practices for PHP Contents Naming Conventions and Standards Code Indentation Generally you should use the Allman style ( of indenting code. <? This will differ slightly from the indentation style mainly used for Javascript (like K&R), but there are valid cases where the Allman style would cause syntactic differences in code execution (such as implied return values in Javascript because the semicolon is optional). <? Also, tabs should be used to indent code rather than spaces. Brace Usage If your if() or loop only contains one executable statement, the containing braces are optional, and should be omitted: <? The statement should still be indented as usual, and kept on a separate line for readability. Trailing Whitespace Avoid this if you can. Naming Conventions <? But the following are not: <? <? Code Commenting Below is an example: <? String Concatenation <? Good Programming Practices KISS Principles <? <? <? <? <? <? <?

74 Quality Ruby on Rails Resources and Tutorials Learning Rails from scratch can be a pain. But don't fret, this guide provides the best Rails resources the Web has to offer. Ruby on Rails is quickly becoming one of the most popular modern programming language framework combinations. Specifically, Ruby is a programming language that has been around for a few years and Rails is a framework for Ruby that is a bit newer and is just about the hottest thing in application and web development right now. Rails' seamless integration into web servers and databases and its elegant framework make it the ideal candidate for every programmer wishing to develop the latest and greatest web application. Related Articles: Fortunately for you, we've compiled a list of the best Rails resources the Web has to offer. Installation Sometimes, the most time consuming part of learning a new programming language is simply installing a working version of the software. Manual Installation Ruby – First you need to download Ruby. Tutorials Beginner Tutorials Try Ruby!

gui2py - Simple and powerful GUI framework for agile development InformacionGeneral - GuiaInstalacion (Español) gui2py is a GUI framework for building cross-platform "visual" desktop applications on Windows, Mac OS X, and Linux, using the Python language and the wxPython toolkit. Its objetive is to evolve PythonCard with web2py's phylosophy and facilities with the following goals: KISS compact structure: easy to learn, complete and powerful GUI Framework for Rapid Application Development Visual Tools: designer, inspector and property editor, embeddables into IDEs (see rad2py screenshot) HTML/Javascript-like capabilities (i.e. events, layout): reusing and/or adapting gluon (web2py framework) + automatic flow mechanism Features Currently, gui2py supports the following components: Visual Tools For quick Point-and-Click visual design of user interfaces, gui2py includes: a designer, a toolbox, an inspection tool and a property editor: Screenshots For more screenshots, browse the screenshots folder in the repo. Compatibility Notes: Installation News

A MiniTest::Spec Tutorial: Elegant Spec-Style Testing That Comes With Ruby Despite RSpec's awesomeness, Test::Unit remains the most popular Ruby testing tool out there outside of Rails apps. I've recently been code walking through a lot of Ruby libraries for my Ruby Reloaded course and the typical arrangement is Test::Unit, sometimes coupled with Shoulda or Contest for some extra syntactic sweetness. Part of the reason for Test::Unit's enduring popularity is its presence in the Ruby standard library but, also, its general 'lightness' and speed. Enter MiniTest With Ruby 1.9, however, MiniTest entered the standard library. require 'test/unit' still works in Ruby 1.9 but it's provided through a compatibility layer on top of MiniTest, so if you're using require 'test/unit' in Ruby 1.9, you're really using MiniTest under the hood. Note: Ruby 1.8 users can run gem install minitest to get MiniTest too but it's not part of the standard library there. What Does MiniTest::Spec Look Like? Let's start with a ridiculously simplistic Test::Unit style test: Give It A Try

Votre Python aime les pip A partir des versions 2.7.9 et et 3.4, pip est fournit automatiquement avec Python. Si c’est votre cas, vous pouvez sauter la partie installation et aller directement à la partie usage de cet article. Pip install par-ci, pip install par là. “Pour installer cette lib, il vous suffit de faire pip install”. Mais merde, c’est quoi pip ? Python et les libs externes La beauté avec Python, c’est qu’on peut prendre une lib, la balancer dans le répertoire courant, et l’importer. Mais. Car oui, il y a toujours un mais (souvent après le mois de mars). Quand il faut mettre à jour ses libs, c’est chiant. Mais surtout, quand on a une lib qui a des parties en C à compiler comme les libs de crypto, d’accès à la base de données, de traitement XML, de parsing ou de sérialisation, de calculs scientifiques, etc. ça ne marche tout simplement pas. Là, il y a deux écoles. Et les mecs qui utilisent setuptools (et qui se retrouvent avec encore d’autres problèmes, mais c’est mieux parce que je le dis).

21 Ruby Tricks You Should Be Using In Your Own Code Writing for Ruby Inside, I get to see a lot of Ruby code. Most is good, but sometimes we forget some of Ruby's shortcuts and tricks and reinvent the wheel instead. In this post I present 21 different Ruby "tricks," from those that most experienced developers use every day to the more obscure. Whatever your level, a refresh may help you the next time you encounter certain coding scenarios. Note to beginners: If you're still learning Ruby, check out my Beginning Ruby book. 2009 Update: This post was written in early 2008 and looking back on it, there are a couple of tricks that I wouldn't recommend anymore - or to which extra warnings need to be added. 1 - Extract regular expression matches quickly A typical way to extract data from text using a regular expression is to use the match method. email = "Fred Bloggs <fred@bloggs.com>"email.match(/<(.*?) Ultimately, using the String#[] approach is cleaner though it might seem more "magic" to you. x = 'this is a test' x[/[aeiou].+? puts x == 10 ?

Related: