Subscribe: Ruby Inside
http://feeds.feedburner.com/RubyInside
Added By: mmss Feedage Grade B rated
Language: English
Tags:
cobbled mail  code  method  mri  new  newsletter ruby  operator  rails  roundup ruby  rspec  ruby news  ruby  string  unary 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Ruby Inside

Ruby Inside





Updated: 2014-10-21T13:20:59Z

 



Raptor: A Forthcoming Ruby Web Server for Faster App Deployment

2014-10-21T13:20:59Z

Raptor bills itself as a new Ruby "app server” and it claims to blow everything else out of the water performance-wise (by between 2-4x!) whether that’s Unicorn, Puma, Passenger, or even TorqueBox on JRuby. The bad news for now is there’s no source or repo yet and only a handful of people (including me) have been given a sneak peek, although a public beta is promised on November 25th. The history of Ruby webapp deployment The deployment of Ruby (and therefore Rails) webapps was a painful mess for years, a state I lamented 7 years ago in No True ‘mod_ruby’ is Damaging Ruby’s Viability on the Web. Read More Raptor bills itself as a new Ruby "app server” and it claims to blow everything else out of the water performance-wise (by between 2-4x!) whether that’s Unicorn, Puma, Passenger, or even TorqueBox on JRuby. The bad news for now is there’s no source or repo yet and only a handful of people (including me) have been given a sneak peek, although a public beta is promised on November 25th. The history of Ruby webapp deployment The deployment of Ruby (and therefore Rails) webapps was a painful mess for years, a state I lamented 7 years ago in No True ‘mod_ruby’ is Damaging Ruby’s Viability on the Web. Thankfully, shortly thereafter a number of projects came out to make life easier, the most famous being Phusion Passenger (then known as mod_rails) in April 2008. Things have continued to improve gradually over the years, with Passenger getting consistently better, and new approaches such as those offered by Unicorn and Puma, using JRuby, as well as proxying through Nginx, coming into the picture. Enter Raptor Raptor, a new entry to the burgeoning world of Ruby Web servers, boasts some compelling features. "Visibility" is cited as a key feature so that you can look ‘into’ your app and analyze its performance as easily as possible using a JSON API (so building your own tools around the API should be simple). Raptor also uses the HTTP parser from Node which itself was derived from Nginx’s HTTP parser; both are renowned for their speed and stability. Raptor boasts a zero-copy, concurrent, evented architecture which makes it efficient memory and IO-wise - so even if you have slow clients or a slow network, these won’t bring your app server to a stuttering standstill. Another feature that jumped out at me is integrated caching. Raptor doesn’t rely on an external services like memcached or Redis at all, but is truly internal and optimized specifically for Web workloads. If you’ve never set up caching before, this could provide a big boost as with Raptor it’ll be available “out of the box”. The initial results seem promising. Fabio Akita has already shared some early benchmark results which broadly mirror my own experience (disclaimer: as someone with rather little experience and authority in benchmarking, my benchmarks are oriented around Raptor’s own benchmarking suite) but, as always, YMMV and such benchmarks are often criticized. The waiting game.. The team behind Raptor promise they’ll be releasing some interesting blog posts soon about the technology behind it, including how the cache is implemented and has been optimized, how the zero-copy system works and how it’ll benefit your code, and similar things. So keep an eye on rubyraptor.org, especially around November 25th. [...]



Ruby’s Unary Operators and How to Redefine Their Functionality

2014-10-16T09:34:33Z

In math, a unary operation is an operation with a single input. In Ruby, a unary operator is an operator which only takes a single 'argument' in the form of a receiver. For example, the - on -5 or ! on !true. In contrast, a binary operator, such as in 2 + 3, deals with two arguments. Here, 2 and 3 (which become one receiver and one argument in a method call to +). Ruby only has a handful of unary operators, and while it's common to redefine binary operators like + or [] to give your objects some added syntactic sugar, unary operators are less commonly redefined. Read MoreIn math, a unary operation is an operation with a single input. In Ruby, a unary operator is an operator which only takes a single 'argument' in the form of a receiver. For example, the - on -5 or ! on !true. In contrast, a binary operator, such as in 2 + 3, deals with two arguments. Here, 2 and 3 (which become one receiver and one argument in a method call to +). Ruby only has a handful of unary operators, and while it's common to redefine binary operators like + or [] to give your objects some added syntactic sugar, unary operators are less commonly redefined. In my experience, many Rubyists aren't aware that unary operators can be redefined and.. technically you can't "redefine an operator" but Ruby's operators frequently use specially named methods behind the scenes, and as you'll know.. redefining a method is easy in Ruby! A Quick Example with -@ Let's ease into things with the - unary operator. The - unary operator is not the same thing as the - binary operator (where a binary operator has two operants). By default, the - unary operator is used as notation for a negative number, as in -25, whereas the - binary operator performs subtraction, as in 50 - 25. While they look similar, these are different concepts, different operators, and resolve to different methods in Ruby. Using the - unary operator on a string in irb: > -"this is a test" NoMethodError: undefined method `-@' for "this is a test":String The String class doesn't have unary - defined but irb gives us a clue on where to go. Due to the conflict between the unary and binary versions of -, the unary version's method has a suffix of @. This helps us come up with a solution: str = "This is my STRING!" def str.-@ downcase end p str # => "This is my STRING!" p -str # => "this is my string!" We've defined the unary - operator by defining its associated -@ method to translate its receiving object to lower case. Some Other Operators: +@, ~, ! (and not) Let's try a larger example where we subclass String and add our own versions of several other easily overridden unary operators: class MagicString < String def +@ upcase end def -@ downcase end def ! swapcase end def ~ # Do a ROT13 transformation - http://en.wikipedia.org/wiki/ROT13 tr 'A-Za-z', 'N-ZA-Mn-za-m' end end str = MagicString.new("This is my string!") p +str # => "THIS IS MY STRING!" p !str # => "tHIS IS MY STRING!" p (not str) # => "tHIS IS MY STRING!" p ~str # => "Guvf vf zl fgevat!" p +~str # => "GUVF VF ZL FGEVAT!" p !(~str) # => "gUVF VF ZL FGEVAT!" This time we've not only redefined -/-@, but the + unary operator (using the +@ method), ! and not (using the ! method), and ~. I'm not going to explain the example in full because it's as simple as I could get it while still being more illustrative than reams of text. Note what operation each unary operator is performing and see how that relates to what is called and what results in the output. Special Cases: & and * & and * are also unary operators in Ruby, but they're special cases, bordering on 'mysterious syntax magic.' What do they do? & and to_proc Reg Braithwaite's The unary ampersand in Ruby post gives a great explanation of &, but in short & can turn objects into procs/blocks by calling the to_proc method upon the object. For example: p ['hello', 'world'].map(&:reverse) # => ["olleh", "dlrow"] Enumerable#map usually takes a block ins[...]



This Month in Ruby: PeepCode Acquired, Rails 3.2.14, And More

2013-07-25T20:16:48Z

Welcome to a roundup of Ruby news, articles, videos, and more, for July 2013 cobbled together from my e-mail newsletter, Ruby Weekly. Highlights include: PeepCode acquired by Pluralsight, Practicing Ruby archives made public, Rails 3.2.14, and an interesting interview with Matz. Featured The First Four Volumes of Practicing Ruby, Now Available Online Practicing Ruby is a high quality, paid Ruby journal run by Gregory Brown, but he's made archives of over 60 articles available to the public. There's a ton of stuff to enjoy here. PeepCode Acquired by Pluralsight Ruby and Rails screencasting pioneer Geoffrey Grosenbach has announced he has sold Peepcode to Pluralsight, a large online training provider. Read MoreWelcome to a roundup of Ruby news, articles, videos, and more, for July 2013 cobbled together from my e-mail newsletter, Ruby Weekly. Highlights include: PeepCode acquired by Pluralsight, Practicing Ruby archives made public, Rails 3.2.14, and an interesting interview with Matz. Featured The First Four Volumes of Practicing Ruby, Now Available Online Practicing Ruby is a high quality, paid Ruby journal run by Gregory Brown, but he's made archives of over 60 articles available to the public. There's a ton of stuff to enjoy here. PeepCode Acquired by Pluralsight Ruby and Rails screencasting pioneer Geoffrey Grosenbach has announced he has sold Peepcode to Pluralsight, a large online training provider. The Plan for RSpec 3 RSpec 2.0 was released in October 2010 and RSpec 2.14 will be the last RSpec 2 feature release. Work on RSpec 3 has begun and Myron Marston shares what's going to be involved. Rails 3.2.14 RC1 and RC2 Released A variety of bug fixes for Rails 3.2 arrived in 3.2.14 RC1 with one minor regression fixed in RC2. Final due soon. Rails 3.2.14 Released The Future of Computing - An Interview with Matz Last year, Ruby's creator Yukihiro 'Matz' Matsumoto released a book called The Future of Computing (only in Japanese, I believe) and did an interview with a Chinese publisher. Fred Wu has translated it into English. RSpec 2.14 Released Myron Marston unveils the last 2.x feature release of the popular spec framework and announces work is well underway for the future RSpec 3. 2.14 includes a new feature called 'spies' which is shown off here. Functional Programming and Ruby At GoRuCo 2013, Pat Shaughnessy gave a 40 minute talk comparing Haskell (a functional language) to Ruby and looked at how to implement common functional patterns in Ruby. Well explained and backed by good slides. Reading Streaming with Rails 4 Saurabh Bhatia looks at Rails 4's support for live streaming (the ability to send partial requests out to the client on the fly). Reading the Ruby Source to Understand Rails Idiosyncrasies I'm not sure you always need to dig quite so deep but Eno Compton takes an interesting journey through MRI's source code to see the difference between Range#cover? and Range#include? Speed Up Heroku Deploys Alex MacCaw was suffering from slow deploys to Heroku but he found a workaround. Managing Ruby Environments on OS X: Getting Started with rbenv Shoes 4 – A Progress Report Shoes was a graphical toolkit put together by Why the Lucky Stiff that made it simple to create GUI apps in Ruby. Since Why disappeared, others have picked up work on it, and Shoes 4 is set to be a complete rewrite. Put Yourself on Rails with A Push of A Button A technique for quickly bringing up a workspace for doing Rails work (including terminals, a Rails console, a Rails server, etc.) Automatically Scaling Heroku Workers Multitenancy with Rails: An E-book by Ryan Bigg Ryan Bigg, of Rails in Action fame, is writing an e-book about building a multi-tenanted Rails app. Incremental Redesign with Rails Lars Klevan shows how to use prepend_view_path to make in-progress redesigns on a production codebase simpler. How to Declutter Your 'lib' Directory If you have an established Rails project, its 'lib' folder might be getting a little full.[...]



Does the GIL Make Your Ruby Code Thread-Safe?

2013-06-29T17:16:29Z

This is a guest post by Jesse Storimer. He teaches the Unix fu workshop, an online class for Ruby developers looking to do some awesome systems hacking in Ruby and boost their confidence when it comes to their server stack. Spots are limited, so check it out the class while there's still room. He's also the esteemed author of Working with Unix Processes, Working with TCP Sockets and Working with Ruby Threads. There are some misconceptions in the Ruby community about this question surrounding MRI's GIL. If you only take one thing away from this article today, let it be this: The GIL does not make your Ruby code thread-safe. Read MoreThis is a guest post by Jesse Storimer. He teaches the Unix fu workshop, an online class for Ruby developers looking to do some awesome systems hacking in Ruby and boost their confidence when it comes to their server stack. Spots are limited, so check it out the class while there's still room. He's also the esteemed author of Working with Unix Processes, Working with TCP Sockets and Working with Ruby Threads. There are some misconceptions in the Ruby community about this question surrounding MRI's GIL. If you only take one thing away from this article today, let it be this: The GIL does not make your Ruby code thread-safe. But you shouldn't take my word for it. This series started off just trying to understand what the GIL is at a technical level. Part 1 explained how race conditions could occur in the C code that's used to implement MRI. Yet, the GIL seemed to eliminate that risk, at least for the Array#<< method we looked at. Part 2 confirmed that the GIL did, in fact, make MRI's native C method implementations atomic. In other words, these native implementations were free from race conditions. These guarantees only applied to MRI's native C functions, not to the Ruby that your write. So we were left with a lingering question: Does the GIL provide any guarantee that your Ruby code will be thread-safe? I've already answered that question. Now I want to make sure that the misconception doesn't go any further. Race conditions redux Race conditions exist when some piece of data is shared between multiple threads, and those threads attempt to act on that data at the same time. When this happens without some kind of synchronization, like locking, your program can start to do unexpected things and data can be lost. Let's step back and recap how such a race condition can occur. We'll use the following Ruby code example for this section: class Sheep def initialize @shorn = false end def shorn? @shorn end def shear! puts "shearing..." @shorn = true end end This class definition should be nothing new. A Sheep is not shorn when initialized. The shear! method performs the shearing and marks the sheep as shorn. sheep = Sheep.new 5.times.map do Thread.new do unless sheep.shorn? sheep.shear! end end end.each(&:join) The bit of code creates a new sheep and spawns 5 threads. Each thread races to check if the sheep has been shorn? If not, it invokes the shear! method. Here's the result I see from running this on MRI 2.0 several times. $ ruby check_then_set.rb shearing... $ ruby check_then_set.rb shearing... shearing... $ ruby check_then_set.rb shearing... shearing... Sometimes the same sheep is being shorn twice! If you were under the impression that the GIL made your code 'just work' in the presence of multiple threads, this should dispel that. The GIL can make no such guarantee. Notice that the first time running the file, the expected result was produced. In subsequent runs, unexpected output was produced. If you continued running the example, you'll see still different variations. These unexpected results are due to a race condition in your Ruby code. It's actually a common enough race condition that there's a name to describe this pattern: a check-then-set race condition. In a check-then-set race condition, two or more threads check a value, then set some sta[...]



This Week in Ruby: Matz on Ruby 2.0, Numerous Conference CFPs, Tenderlove on define_method

2013-03-07T12:44:43Z

Welcome to this week’s roundup of Ruby news, articles, videos, and more, cobbled together from my e-mail newsletter, Ruby Weekly. Sorry these roundups have been missing for a couple of months, I've been focusing very heavily on the e-mail newsletters which are continuing to grow like crazy! :-) I hope to get back into blogging more soon. Matz on Ruby 2.0 Matz spoke about Ruby 2.0 ('the happiest release ever') for 30 minutes at the Heroku Waza event a week ago and the video is already available to watch. He stresses that "Ruby 1.8 will die soon" and encourages everyone to upgrade. Read MoreWelcome to this week’s roundup of Ruby news, articles, videos, and more, cobbled together from my e-mail newsletter, Ruby Weekly. Sorry these roundups have been missing for a couple of months, I've been focusing very heavily on the e-mail newsletters which are continuing to grow like crazy! :-) I hope to get back into blogging more soon. Matz on Ruby 2.0 Matz spoke about Ruby 2.0 ('the happiest release ever') for 30 minutes at the Heroku Waza event a week ago and the video is already available to watch. He stresses that "Ruby 1.8 will die soon" and encourages everyone to upgrade. Dynamic Method Definitions Aaron 'tenderlove' Patterson says that "depending on your app, using define_method is faster on boot, consumes less memory, and probably doesn’t signigicantly impact performance" compared to eval-based techniques. (And he has the numbers to prove it.) Steel City Ruby Conference 2013 CFP Now Open Steel City Ruby takes places in Pittsburgh, PA on August 16-17 and the CFP is now open if you want to submit a talk. The Burlington Ruby Conference has a CFP open too, as does RubyConf India. RubyGems 2.0.1 Released: A Bug-Fix Release Reading Inspecting Rails 4 using Ruby 2.0 and TracePoint Matt Aimonetti shows off a practical use for Ruby 2.0's TracePoint execution tracing functionality. Visualizing Memory Leaks in Ruby 1.9 Conrad Irwin on some clever work to extend ObjectSpace with a new find_references method to perform better analysis on object and memory usage on Ruby 1.9. Parsing TOML in Ruby with Parslet Recently, GitHub founder Tom Preston-Werner created an interesting INI-influenced 'TOML' format. In this series of posts, Nathan Witmer looks at what's involved in building a parser for TOML using the Parslet PEG parser construction library. Introducing Ress: A System for Building Mobile Optimized Rails Apps Matthew Robertson introduces his new system for building mobile-optimized Rails applications using semantic, media query-based device detection and server side component optimization. Ruby 2.0 Walkthrough: The Best Bits Some slides from my yet-to-be-released 'Ruby 2.0 Walkthrough' that quickly skim through what I consider to be the 'best bits' (and not just the headline features). A Practical Guide to Using Signed Ruby Gems - Part 1: Bundler Rails + Ember An introduction to the open source Ember JavaScript app framework for Rails developers. Effective Rails, Part 2: Hiding ActiveRecord Watching and Listening Sinatra in SIX Lines: How to Do Crazy Stuff with Ruby A talk by Konstantin Haase at Ruby Australia. Libraries and Code Phusion Passenger 4.0 Release Candidate 4 Leading Rack-based app deployment tool Passenger gets yet another step closer to the 4.0 release. time-lord: A Human DSL for Time Expressions A gem that gives you more human like expressions for time and space math. Get fun like 1.hour.ago.to_range and 200.minutes.ago.to_words identity_cache: Opt-in Read-through ActiveRecord Caching, From Shopify IdentityCache lets you specify how you want to cache your model objects, at the model level, and adds a number of convenience methods for accessing those objects through the cache. Uses Memcached as the backend cache store. neg 1.1.0: A Small PEG Parser Library "One could say it’s a small brother of Parslet." Gridhook: A Rails Engine to Provide An Endpoint f[...]



A Simple Tour of the Ruby MRI Source Code with Pat Shaughnessy

2012-12-02T17:03:26Z

I'm not in Ruby core or, well, even a confident C coder anymore, but I've long enjoyed digging in the Ruby MRI source code to understand weird behavior and to pick up stuff for my Ruby course. Pat Shaughnessy is also a fan of digging around in Ruby's internals and has written some great posts like How Ruby Executes Your Code, Objects, Classes and Modules, and Exploring Ruby's Regular Expression Algorithm. When Pat released his Ruby Under a Microscope book, I knew it would be right up my street! He digs into how objects are represented internally, why MRI, Rubinius and JRuby act in certain ways and, of course, "lots more." I invited Pat to take a very high level cruise through the MRI codebase with me so we could share that knowledge with Ruby programmers who haven't dared take a look 'under the hood' and to show it's not as scary or pointless as it may seem. Read More width="640" height="360" src="http://www.youtube.com/embed/0npv906IQag" frameborder="0" allowfullscreen> I'm not in Ruby core or, well, even a confident C coder anymore, but I've long enjoyed digging in the Ruby MRI source code to understand weird behavior and to pick up stuff for my Ruby course. Pat Shaughnessy is also a fan of digging around in Ruby's internals and has written some great posts like How Ruby Executes Your Code, Objects, Classes and Modules, and Exploring Ruby's Regular Expression Algorithm. When Pat released his Ruby Under a Microscope book, I knew it would be right up my street! He digs into how objects are represented internally, why MRI, Rubinius and JRuby act in certain ways and, of course, "lots more." I invited Pat to take a very high level cruise through the MRI codebase with me so we could share that knowledge with Ruby programmers who haven't dared take a look 'under the hood' and to show it's not as scary or pointless as it may seem. It's 100% free so enjoy it above or on YouTube in 720p HD. P.S. Pat is happy to do another video digging deeper into how Ruby actually takes your code and executes it and he's able to walk through the actual virtual machine for us. If the reaction to this video is good, we'll sit down again and see if we can do it! :-) [...]



The Last Week in Ruby: A Great Ruby Shirt, RSpec Team Changes and a Sneaky Segfault Trick

2012-12-02T01:48:08Z

Welcome to this week's roundup of Ruby news cobbled together from my e-mail newsletter, Ruby Weekly. Highlights include: A time-limited Ruby shirt you can order, a major change in the RSpec project, how to make Ruby 1.9.3 a lot faster with a patch and compiler flags, a sneaky segmentation fault trick, several videos, and a few great jobs. Featured The 'Ruby Guy' T-Shirt Grab a t-shirt with a cute 'Ruby Guy' mascot on the front in time for Christmas. Comes in both male and female styles in varying sizes. Only available till Thursday December 6 though as it's part of a temporary Teespring campaign (Note: I have no connection to this, it just looks cool.) David Chelimsky Hands Over RSpec to New Project Leads After several years at the helm, David Chelimsky is handing over the reins to Myron Marston and Andy Lindeman for RSpec and rspec-rails respectively. Read MoreWelcome to this week's roundup of Ruby news cobbled together from my e-mail newsletter, Ruby Weekly. Highlights include: A time-limited Ruby shirt you can order, a major change in the RSpec project, how to make Ruby 1.9.3 a lot faster with a patch and compiler flags, a sneaky segmentation fault trick, several videos, and a few great jobs. Featured The 'Ruby Guy' T-Shirt Grab a t-shirt with a cute 'Ruby Guy' mascot on the front in time for Christmas. Comes in both male and female styles in varying sizes. Only available till Thursday December 6 though as it's part of a temporary Teespring campaign (Note: I have no connection to this, it just looks cool.) David Chelimsky Hands Over RSpec to New Project Leads After several years at the helm, David Chelimsky is handing over the reins to Myron Marston and Andy Lindeman for RSpec and rspec-rails respectively. Thanks for all your hard work, David. Upgrading to Rails 4: A Forthcoming Book (in Beta) Andy Lindeman of the RSpec core team is working on a new book designed to bring you up to speed with Rails 4. It's in beta so you can support him now, if you like. Reading Making Your Ruby Fly Andrei Lisnic demonstrates a few compile time 'tricks' you can use to make your MRI Ruby 1.9.3 faster. The benchmark results are compelling. Avoiding the Tar Pits of Localization Jeff Casimir gave a talk on the 'Ruby Hangout' about the trickiness of handling internationalization and localization and some tools and libraries you can use to help. Lots of notes here or you can watch the video. Recovering From Segfaults in Ruby, The Sneaky Way We've probably all seen the dreaded 'segmentation fault' from Ruby before. Charlie Somerville demonstrates a rather clever but sneaky way you can 'recover' from them in plain Ruby. As he says, you probably don't want to use this trick seriously. Use Rails Until It Hurts Evan Light pushes back a little against the recent wave of OO purity and, as DHH calls it, 'pattern vision.' Speeding Things Up With jRuby MRI's global interpreter lock prevents running code in parallel without forking the Ruby process. That's where JRuby can help. Try RubyGems 2.0 Michal Papis demonstrates how you can give the forthcoming RubyGems 2.0 a spin using RVM. Your Objects, the Unix Way: Applying the Unix Philosophy to Object-Oriented Design Everything You Ever Wanted to Know About Constant Lookup in Ruby Simple Authorization in Ruby On Rails Apps Improve Your Ruby Workflow by Integrating vim, tmux and pry Watching and Listening Rapid Programming Language Prototypes with Ruby and Racc At RubyConf 2012, Tom Lee demonstrated how you can use Racc, a LALR(1) parser generator that emits Ruby code from a grammar file, in the process of creating a simple programming language of your own. A Tour Into An Oddity With Ruby's Struct Class In which I look into why Struct.new(:foo?).new(true).foo? doesn't work, even though the Struct-produced class and its instances are valid. I dive into the MRI source code a bit to get to the bot[...]



The Split is Not Enough: Unicode Whitespace Shenigans for Rubyists

2012-11-26T07:24:36Z

That code is legal Ruby! If you ran it, you'd see 8. How? There's a tale to tell.. The String with the Golden Space I was on IRC in #nwrug enjoying festive cheer with fellow Northern Rubyists when ysr23 presented a curious problem. He was using a Twitter library that returned a tweet, "@twellyme film", in a string called reply. The problem was that despite calling reply.split, the string refused to split on whitespace. Yet if he did "@twellyme film".split in IRB, that was fine. International man of mystery Will Jessop suggested checking $; (it's a special global variable that defines the default separator for String#split). Read More That code is legal Ruby! If you ran it, you'd see 8. How? There's a tale to tell.. The String with the Golden Space I was on IRC in #nwrug enjoying festive cheer with fellow Northern Rubyists when ysr23 presented a curious problem. He was using a Twitter library that returned a tweet, "@twellyme film", in a string called reply. The problem was that despite calling reply.split, the string refused to split on whitespace. Yet if he did "@twellyme film".split in IRB, that was fine. International man of mystery Will Jessop suggested checking $; (it's a special global variable that defines the default separator for String#split). It was OK. In an attempt to look smarter than I am, I suggested reply.method(:split).source_location to see if the String class had been monkey-patched by something annoying. Nope. (Though this is a handy trick if you do want to detect if anyone's tampered with something.) Someone suggested Mr. Ysr23 show us reply.codepoints.to_a: # reply.codepoints.to_a => [64, 116, 119, 101, 108, 108, 121, 109, 101, 160, 102, 105, 108, 109] Something leapt out at me. Where was good old 32!? Instead of trusty old ASCII 32 (space) stood 160, a number alien to my ASCII-trained 1980s-model brain. From Google with Love To the Google-copter! Aha! Non-breaking space. That's why split was being as useful as a chocolate teapot. After an intense 23 seconds of discussion, we settled on a temporary solution for Mr. Ysr23 who, by this time, was busy cursing Twitter and all who sailed upon her: reply.gsub(/[[:space:]]/, ' ').split The solution is simple. Use the the Unicode character class [[:space:]] to match Unicode's idea of what whitespace is and convert all matches into vanilla ASCII whitespace. reply.split(/[[:space:]]+/) is another more direct option - we just didn't think of it at the time. Quantum of Spaces Solving an interesting but trivial issue wasn't where I wanted to end my day. I'd re-discovered an insidious piece of Unicode chicanery and was in the mood for shenanigans! Further Googling taught me you can type non-breaking spaces directly on OS X with Option+Space. (You can do the homework for your own platform.) I also knew Ruby 1.9 and beyond would let you use Unicode characters as identifiers if you let Ruby know about the source's encoding with a magic comment, so it was time for shenanigans to begin! My first experiment was to try and use non-breaking spaces in variable names. Cool! So what about variable names and method names? What about without any regular printable characters in the identifiers at all? And so we're back to where we started. A hideous outcome from a trivial weekend on IRC. But fun, nonetheless. Stick it in your "wow, nice, but totally useless" brain box. A Warning Please don't use this in production code or the Ruby gods will come and haunt you in your sleep. But.. if you want to throw some non-breaking spaces into your next pair programming session, conference talk, or job interview, just to see if anyone's paying attention, I'll be laughing with you. (And if you're a C# developer too, Andy Pike tells me that C# supports these shenanigans too.) P.S. My Ruby 2.0 Walkthrough Kickstarter only has about 12 hours to go! Check it out if Ruby 2.0 is on your radar or you wa[...]



This Week in Ruby: Ruby 2.0 Refinements, Cost of GC::Profiler, and BritRuby Cancelled

2012-11-23T16:56:27Z

Welcome to this week’s roundup of Ruby news, articles, videos, and more, cobbled together from my e-mail newsletter, Ruby Weekly. If you've been celebrating Thanksgiving this week, I hope you're having a good break. Highlights include: Charles Nutter on Ruby 2.0 refinements, the cancellation of the British Ruby Conference, and DHH's latest object instantiation (thanks Doug Renn). Featured Refining Ruby (or The Best Study of Ruby 2.0 Refinements Yet) I've editorialized the title somewhat but this article by Charles Nutter is a great look into the world of 'refinements' in Ruby 2.0, what they're intended for, and all of the challenges they throw up, both for developers and language implementers. Read MoreWelcome to this week’s roundup of Ruby news, articles, videos, and more, cobbled together from my e-mail newsletter, Ruby Weekly. If you've been celebrating Thanksgiving this week, I hope you're having a good break. Highlights include: Charles Nutter on Ruby 2.0 refinements, the cancellation of the British Ruby Conference, and DHH's latest object instantiation (thanks Doug Renn). Featured Refining Ruby (or The Best Study of Ruby 2.0 Refinements Yet) I've editorialized the title somewhat but this article by Charles Nutter is a great look into the world of 'refinements' in Ruby 2.0, what they're intended for, and all of the challenges they throw up, both for developers and language implementers. The British Ruby Conference.. Cancelled It's a pretty long story but the British Ruby Conference, which I was getting rather excited about.. is no more. There's a statement as to why but if you want to join the melee of conversation, try here or here. Luckily other attempts are now afoot - news coming soon. DHH's Latest Project: Colt Heinemeier Hansson It's DHH's latest release :-) Congratulations to him and his growing family. And before anyone complains about having a human interest story here, cheer up a bit - it's Thanksgiving ;-) Edge Rails Now Tested on Ruby 2.0 with Travis CI Little to read but Ruby 2.0 is now most clearly on the edge Rails developers' radar. Reading Deploying Ruby Applications to AWS Elastic Beanstalk with Git Just last week, Amazon announced Ruby support for its AWS Elastic Beanstalk semi-automated deployment and scaling system. This tutorial by Loren Segal fills in all the blanks by walking us through using it from start to finish with a Rails app. Zen and The Art of Speaking at RubyConf 2012 - The dRuby Way An excellent story and walkthrough about both preparing a talk for RubyConf 2012 and what happened while the speaker was there. More articles like this please. The Cost of Ruby 1.9.3's GC::Profiler James Golick presents an examination of the flaws in Ruby 1.9.3's included garbage collector instrumentation in his typically punchy style. Luckily he presents a potential solution too: GC::BasicProfiler. Is Your Application Running with Ruby - Slow? Two developers moved a large Ruby webapp between two machines and experienced a 50% drop in performance. Why? Clue: It was something to do with RVM. A 2012 Mac Setup for Ruby development We see articles like this quite often but there are a lot of handy links here despite not being particularly Ruby focused. A Lightweight 'CMS' Using Ruby and Google Drive An interesting approach to content management. Let users enter text in a Google Drive spreadsheet, grab it with Ruby, and use the data to create your content or templates locally. A 'yield' Gotcha Every Ruby Developer Should Be Aware of It's not a true yield gotcha but is something you might trip over nonetheless regarding earlier than expected returns. Luckily, 'ensure' blocks help save the day. Profiling Ruby (or How I Made Rails Start Up Faster) Four steps: measure, find the problem, fix, and repeat. Riding Rails: The People Behind Rails 4 Concurrency[...]



This Week in Ruby: MRI 1.9.3-p327, Rails 3.2.9, Capybara 2.0, and the Fukuoka Ruby Award

2012-11-15T16:20:36Z

Welcome to this week’s roundup of Ruby news, articles, videos, and more, cobbled together from my e-mail newsletter, Ruby Weekly. Highlights include: MRI 1.9.3-p327, Rails 3.2.9, Capybara 2.0, and the Fukuoka Ruby Award. Featured Ruby 1.9.3-p327 Released: Fixes a Hash-Flooding DoS Vulnerability Carefully crafted strings can be used in a denial of service attack on apps that parse strings to create Hash objects by using the strings as keys. This new patch level release of 1.9.3 counters the issue. 2013 Fukuoka Ruby Award Competition Each year Matz and the Government of Fukuoka in Japan run an award for Ruby programs. Submit by November 30th to enter - it doesn't have to be an all new app either. Read MoreWelcome to this week’s roundup of Ruby news, articles, videos, and more, cobbled together from my e-mail newsletter, Ruby Weekly. Highlights include: MRI 1.9.3-p327, Rails 3.2.9, Capybara 2.0, and the Fukuoka Ruby Award. Featured Ruby 1.9.3-p327 Released: Fixes a Hash-Flooding DoS Vulnerability Carefully crafted strings can be used in a denial of service attack on apps that parse strings to create Hash objects by using the strings as keys. This new patch level release of 1.9.3 counters the issue. 2013 Fukuoka Ruby Award Competition Each year Matz and the Government of Fukuoka in Japan run an award for Ruby programs. Submit by November 30th to enter - it doesn't have to be an all new app either. The grand prize is 1 million yen (about $12,000). Capybara 2.0.0 Released: The Acceptance Test Framework for Webapps Not backwards compatible with Capybara 1.x so be careful and read the notes. It also drops support for Ruby 1.8. LA Ruby Conf 2013: Call For Proposals Open Until Dec 10 Rails 3.2.9 Released Reading Printing 'Hello, World' in Style (Concurrently) Daniel Szmulewicz looks at what's involved in using Celluloid and two actors to print out 'Hello, World'. Matz Is Not A Threading Guy Jesse Storimer talks about the status of concurrency in Ruby and Matz's opinions in a Q+A session at RubyConf. Reinforcing the status quo, Matz said: 'Using multiple processes is the best way to do concurrency in MRI for the near future.' rspec-rails and Capybara 2.0: What You Need to Know Andy Lindeman of the RSpec core team talks about the new Capybara 2.0 release and what you need to be aware of when using it with RSpec and Rails. Why Ruby Class Methods Resist Refactoring Bryan Helmkamp demonstrates why he thinks class methods are much trickier to refactor than instance methods. Reference Graphs as Tools for Refactoring A quick look at using graphs of references in order to refactor Ruby code. Trick for Tolerance-based Test Assertions Using #ish Recurrent Neural Networks in Ruby Watching and Listening How I Set out to Benchmark an Algorithm and Ended Up Fixing Ruby Joshua Ballanco wanted to build a delegation library but got lured into the worlds of benchmarks and garbage collectors. Ten Things You Didn't Know You Could Do in Ruby A month ago, we linked to the slidedeck of James Edward Gray II's Aloha on Rails talk with 101 various Ruby tricks and code snippets. Now the video is available too! Enjoy. The Ruby Rogues on Documenting Code The Ruby Rogues tackle a sore subject: documentation. Libraries and Code ruby-lint: Static Code Analysis and Linter for Ruby Currently a prototype and work in progress so your mileage may vary. It makes it possible for developers to detect errors such as undefined or unused variables and the use of non existing methods. Spinel: A New, 'Ruby-Infused' Open Source Game Engine Spinel is a new open source game engine still under development that uses 'mruby' (the embeddable Ruby interpreter Matz is currently working on) as its scripting layer while leaning on speedy C/C++ under the hood. Version Cake: An Unobtrusive W[...]