Those of you who are already familiar with JITs and how they work might want to skip directly to the interview, the rest of us are going to hang out for a minute and learn about how things presently work in Ruby, and what it is exactly that the MJIT would change. How does a … Continue reading MJIT: A Method Based Just-in-time Compiler for Ruby
Ruby
class << self in Ruby
First, the class << foo syntax opens up foo's singleton class (eigenclass). This allows you to customize the behavior of methods called on that specific object. a = 'foo' class << a def inspect '"bar"' end end a.inspect # => "bar" a = 'foo' # new object, new singleton class a.inspect # => "foo" ow, … Continue reading class << self in Ruby
define_method in Ruby
define_method is a (private) method of the object Class. You are calling it from an instance. define_method(:my_method) do |foo, bar| # or even |*args| # do something end or, you could even use string interpolation in the method name, such as define_method("#{attribute}=") do |unencrypted_password| if unencrypted_password.nil? self.send("#{attribute}_digest=", nil) elsif !unencrypted_password.empty? instance_variable_set("@#{attribute}", unencrypted_password) cost = ActiveModel::SecurePassword.min_cost … Continue reading define_method in Ruby
What is gemfile in a Ruby or Rails application
Ruby developers use Gemfiles all the time, and most of us know how to do the basics. In this post I want to dive deep into everything we can do with a Gemfile. What is a Gemfile? A Gemfile is a file we create which is used for describing gem dependencies for Ruby programs. A … Continue reading What is gemfile in a Ruby or Rails application
How to make a custom build version (e.g., Ruby, Python, etc.) in Sublime Text 3
It looks like Sublime Text 3 uses OSX-default version of Ruby in build mode. I would like to change the version, since I'm using a newer one. I found some answers for privious version of sublime: How to edit a native build system in Sublime Text 2? Setting and changing build systems in Sublime Text … Continue reading How to make a custom build version (e.g., Ruby, Python, etc.) in Sublime Text 3
How Ruby block works
Blocks are one of the most powerful and often overlooked feature of ruby. I must confess that it took me a while to figure out how ruby blocks work and how they can be useful in practice. There is something about yield that makes blocks very hard to understand at first. I’m going to talk … Continue reading How Ruby block works
What does if __name__ == “__main__”: do?
A module's __name__ Every module has a name and statements in a module can find out the name of its module. This is especially handy in one particular situation - As mentioned previously, when a module is imported for the first time, the main block in that module is run. What if we want to … Continue reading What does if __name__ == “__main__”: do?
Why Rails 4 Live Streaming is a big deal
TLDR: Rails Live Streaming allows Rails to compete with Node.js in the streaming arena. Streaming requires application servers to support either multi-threaded or evented I/O. Most Ruby application servers are not up for the job. Phusion Passenger Enterprise 4.0 (a Ruby app server) is to become hybrid multi-processed, multi-threaded and evented. This allows seamless support … Continue reading Why Rails 4 Live Streaming is a big deal
Authentication with Warden, without Devise
For most of us, using warden means using devise. Devise served me well but it's big and there's a lot of convention that you need to abide by. Getting up & running with devise is fairly simple. Warden needs a little bit more to get started and I'm going to show you how to implement … Continue reading Authentication with Warden, without Devise