background preloader

Rubular: a Ruby regular expression editor and tester

Ruby on Rails Tutorial: Learn Rails by Example book and screencasts by Michael Hartl | Modeling And Viewing Users Two Michael Hartl Contents Foreword My former company (CD Baby) was one of the first to loudly switch to Ruby on Rails, and then even more loudly switch back to PHP (Google me to read about the drama). Though I’ve worked my way through many Rails books, this is the one that finally made me “get” it. The linear narrative is such a great format. Enjoy! Derek Sivers (sivers.org) Founder, CD Baby Acknowledgments The Ruby on Rails Tutorial owes a lot to my previous Rails book, RailsSpace, and hence to my coauthor Aurelius Prochazka. I’d like to acknowledge a long list of Rubyists who have taught and inspired me over the years: David Heinemeier Hansson, Yehuda Katz, Carl Lerche, Jeremy Kemper, Xavier Noria, Ryan Bates, Geoffrey Grosenbach, Peter Cooper, Matt Aimonetti, Gregg Pollack, Wayne E. About the author Michael Hartl is the author of the Ruby on Rails Tutorial, the leading introduction to web development with Ruby on Rails. Copyright and license Welcome to the Ruby on Rails Tutorial.

Area Criações - Web e Design Blocos em Ruby( lambda, proc, yield e tudo mais) Seguindo a linha do último tutorial de ruby, hoje vamos falar de blocos. Vou tentar explicar de forma resumida e com exemplos o que são blocos e como usar. Lembro a primeira vez que vi um bloco em Ruby fiquei totalmente perdido pois ainda não tinha visto nada com uma sintaxe parecida em outras linguagens ( ex.: { |item| puts item } ). Um bloco é um trecho de código Ruby que deve ser executado: ["daniel","lopes"].each {|item| puts item} # => resultado sera:# => daniel# => lopes No exemplo acima, tenho um array e este array possui o método each. Nosso bloco é formado por chaves que delimitam o inicio e o fim do bloco, um parâmetro ( |item| ) e sentença a ser executada ( puts item ). No exemplo passamos o bloco para o método each e ele executou este bloco várias vezes, também optamos por passar um parâmetro para o bloco, mas podemos passar quantos parâmetros precisarmos. meu_hash = {:nome=>"daniel",:sobrenome=>"lopes"}meu_hash.each {|index,item| puts "chave #{index},valor #{item}"}

Ruby Quiz - metakoans.rb (#67) metakoans.rb (#67) by ara.t.howard [ Editors note: This quiz file can be downloaded: metakoans.rb Partial solutions are welcome. ruby module MetaKoans def koan_1 c = Class::new { attribute 'a' o = c::new assert{ not o.a? assert{ o.a = 42 } assert{ o.a == 42 } assert{ o.a? end def koan_2 class << self assert{ not c.a? assert{ c.a = 42 } assert{ c.a == 42 } assert{ c.a? def koan_3 m = Module::new { assert{ not m.a? assert{ m.a = 42 } assert{ m.a == 42 } assert{ m.a? def koan_4 include m extend m def koan_5 o = Object::new class << o def koan_6 attribute 'a' => 42 assert{ (o.a = nil ) == nil } def koan_7 attribute( 'a' ){ fortytwo } def fortytwo def koan_8 b = Class::new { attribute( 'b' ){ a } c = Class::new b assert{ (c.a = nil ) == nil } def koan_9 include Module::new { assert{ c.a = 'forty-two' } assert{ c.a == 'forty-two' } assert{ b.a == 42 } def assert() bool = yield class MetaStudent def initialize knowledge require knowledge def ponder koan begin send koan true rescue => e false class MetaGuru require "singleton" include Singleton else

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

Rails Это руководство охватывает открытые для пользователя функции роутинга Rails. После прочтения этого руководства вы узнаете: Как интерпретировать код в routes.rbКак создавать свои собственные маршруты, используя или предпочитаемый ресурсный стиль, или метод matchКакие параметры ожидает получить экшн Как автоматически создавать пути и URL, используя маршрутные хелперы О продвинутых техниках, таких как ограничения и точки назначения Rack Роутер Rails распознает URL и соединяет их с экшном контроллера. Когда ваше приложение на Rails получает входящий запрос для: оно опрашивает роутер на предмет соответствия экшну контроллера. Также можно создавать пути и URL. и ваше приложение содержит код в контроллере: и такой в соответствующей вьюхе: тогда роутер создаст путь /patients/17. Ресурсный роутинг позволяет быстро объявлять все обычные маршруты для заданного ресурсного контроллера. Когда приложение на Rails получает входящий запрос для: оно просит роутер соединить его с экшном контроллера.

Brain.js: Neural Networks In JavaScript A neural network is “a mathematical model or computational model that tries to simulate the structure and/or functional aspects of biological neural networks” according to Wikipedia. Basically, a neural network carries out pattern recognition, very much like the human brain would. The user of the network trains it, and then it can be used with varying levels of accuracy depending on the amount of training that it has received. Heather Arthur has written an implementation of a neural network in JavaScript. This example trains the neural network with some simple patterns of input and output, then runs the neural network with an input. because yellow is most similar to orange. Heather has also provided a working demo that you can try out. You can check out the code on Github, the documentation here, and the color demo here.

pilu&#039;s web-app-theme at master - GitHub Mike Clark › Ruby Learning Test #1: Are You There, World? I truly have no idea where this is going or if it will scale. But I've been meaning to try it, and I'll let you judge whether it's worth it. Here's what I do know: It doesn't cost you anything to come along for the ride. How I Learned Ruby A couple years back I flipped open the first edition of Dave and Andy's wonderful book Programming Ruby. But it was at that very moment when I asked Ruby a question and it responded with the answer that I learned more than Ruby. There was just one problem: I didn't yet know enough about Ruby to write a test. [~/work/code/ruby/learn] $ ruby all_learning_tests.rb ruby all_learning_tests.rbLoaded suite all_learning_testsStarted.......................... That's pretty much everything I know about Ruby, give or take. But the real value of writing these tests was less about testing, and more about learning. So You Want To Learn Ruby? Perhaps you've been meaning to learn Ruby for fun or profit, but you just don't know where to start. Write a Learning Test

Installing Ruby and Rails on Mac OS X Updated: Mar. 11, 2014 All of our online courses start with comprehensive instructions for getting the required software installed and set up on your own computer. For the online Rails course, that means installing Ruby and Rails. During the course, you'll then write, refactor, and test your code directly on your own computer. Setting up a stable Ruby and Rails environment on your Mac has never been easier. Install Ruby 2 and Rails 4 The best way we've found to install Ruby and Rails on a Mac is using the Ruby Version Manager (RVM). Note that Mac OS X ships with a version of Ruby. First, find the Terminal application (it's under the Applications -> Utilities directory) and drag it onto your dock. Now you have the latest versions of Ruby and Rails installed! Create An Example Rails App Now that we have all the required software installed, let's create your first Rails app to make sure everything is working in harmony. Next Steps That's all there is to it!

Learn Ruby with the Neo Ruby Koans CodeMirror Hoptoad How to Install Ruby on a Mac This one is tailor made for the Basix users among you. If you've been itching to try out Ruby and/or Rails, if the Terminal is somewhat new to you, you may find that even the process of installing it can generate countless confusing errors. This article will detail the exact steps you need to follow to get Ruby up and running on your Mac. Step 1 - RVM What you might be interested to know is that Ruby comes preinstalled on your Mac. Likely, the version number will return 1.8.7. Old versions of the OS shipped with a buggy version of Ruby RVM provides the flexibility to use any version of Ruby that you require. These days, RVM is the way the cool kids install Ruby, and that's what we'll use. "RVM lets you deploy each project with its own completely self-contained and dedicated environment--from the specific version of ruby, all the way down to the precise set of required gems to run your application. Open the Terminal, and type: Step 2 - Load RVM into the Shell Step 3 - Restart Terminal

Ruby-Doc.org: Documenting the Ruby Language

Related: