RubyFlow : The Ruby Community Blog

Home   Submit   Sign Up   Log In   leaders   Twitter   RSS Feed  
 

jstorimer — 28 posts

http://jstorimer.com

This post explains the only safe way to handle Unix signals in the face of waiting on file descriptors (eg. sockets, pipes). This technique is used by awesome server software like Unicorn, Passenger, Foreman, and non-Ruby projects like nginx. Give it a read on RubySource.
I recorded a conversation with Daniel Huckstep about two topics that always arouse discussion: Ruby's stdlib and the Go programming language. Have a listen or check out the transcript.
This is an important question for anyone using multiple threads on MRI. In the last part of my series on the GIL, I try to dispel this common misconception. Find out for yourself.
In this follow up, I actually take you down into MRI to see how the GIL is implemented, and what effect it has on your code. Read it here and look for part 3 to wrap things up next week.
I started writing about how MRI implements its global interpreter lock (GIL), but ended up with an introduction to thread safety in Ruby. Check it out and look for the followup about the GIL tomorrow.
MonoLogger is a "lock-free logger for Ruby 2.0". It's actually the exact same as Ruby's Logger, minus the lock. I wasn't sure if this was safe, so I did some research. Turns out MonoLogger does the right things to ensure that log messages aren't interleaved even in the face of multiple threads. Warning: you might learn a thing or two about working with Unix file descriptors!
I just published my interview with Brian Shirai (of the Rubinius project) about multi-threaded concurrency in Ruby, myths about the GIL, and the upcoming Rubinius 2.0 release.
Interacting with core classes (like Array and Hash) appears to be thread-safe with MRI because of the global lock. There are no such guarantees on the truly multi-threaded implementations like JRuby and Rubinius. I wrote about the effect of the global lock, and how to protect your data with mutexes.
Everyone seems to be talking about using threads to speed up and parallelize our code. I just published a blog post about a few ways that MRI uses threads internally to organize code, rather than to optimize code.
I wrote down some of my thoughts/observations from Rubyconf 2012 around threading and the GVL. A few of the speakers actually called this out as an issue and Matz addressed some of the questions in his Q&A. Read all about it.
In this screencast I show a really high level wrapper that Ruby provides for making TCP servers. I take 3 lines of high level code and break them down into 25 lines of lower level code. The pretty 3-liner won't work in all cases, so I walk you through the layers of abstractions until we go as low as we can (in Ruby).
I've been delving into Ruby's IO system lately and finding out lots of neat things. So I decided to share a few. The whole thing is less than 10 minutes long and demonstrates a bunch of nuances about working with File and Socket in Ruby.
Over the last few months I've started using ri more and more. I put together a list of the compelling reasons that I prefer it over Google Search.
Socket programming is at the heart of what we do everyday. Whether you're working on web apps, desktop apps, or anything in between you're going to be communicating with web servers, database servers, and probably a dozen other endpoints. But few of us are well versed with our infrastructure at this level.

Hence I've been working on a book about the fundamentals of socket programming using Ruby called Working With TCP Sockets.

The book is still a work-in-progress and will be available for purchase at some point in the coming months. Visit the website if you want to see what's covered, and sign up to receive updates and an exclusive discount code.
I wrote an article about passing around open files (eg. live TCP connections) using UNIX sockets in Ruby. One person described it as "pretty slick in an old school deep unix geeky kinda way".
I just published the fourth article in a series where I implement a Unix shell in pure Ruby code. This time it covers shell pipelines.
usp.ruby is "a text-only mailing list for Unix systems programming in Ruby". The content is written by Eric Wong (author of Unicorn) and is a great resource to learn about Unix programming without digging into C code. I took the plain text content and formatted it for iPads, Kindles and the like. You can grab your format of choice on Github.
In continuing my series on implementing a Unix shell in pure Ruby code this article covers everything you need to know about environment variables and the search path. Read it.
I just published the second article in a series where I implement a Unix shell in pure Ruby code. This time it covers builtin commands.
I just published the first article in a series where I implement a Unix shell in pure Ruby code.
I just launched a big update to Working With Unix Processes, an eBook addressing Unix programming specifically for Ruby developers. The book was released back in December but it never got a mention here on Rubyflow. To mark the release the book is selling for 25% off today only.

The update includes ~20 pages of new content covering stuff like zombie processes, preforking servers, and environment variables. You can read a sample chapter on Daemon Processes.
The rails command is just a thin wrapper around exec(2). Read the article to find out what exec(2) is, why the rails command uses it, and how you can skip it altogether.
In this article I demonstrate how to make colorized output configurable using OptionParser. This is a followup to my last post about writing pipeline-aware Ruby scripts. I also add a few other configurable options and show some best practices.
Want to write a Ruby program that behaves like grep, cat, or tail? I wrote an article showing how you can make your Ruby scripts accept input via command line arguments or pipes. I show you how to differentiate your output so that you can output nicely formatted text for terminals, but always send plain text when you're being piped to another program.
I just released a testing tool that I've been using for the past few months. It really sped up my workflow, especially on large Rails projects. Check out the README.
Put `rake db:migrate` on auto-pilot.
delayed_paperclip is a rubygem that lets you easily process your Paperclip attachments (such as resizing images) in the background with delayed_job.
Jekyll on Heroku  jstorimer.com
I wrote this post about how I publish my Jekyll blog on Heroku. Give it a look if you are a fellow Jekyll publisher.