Skip to content

Instantly share code, notes, and snippets.

View brainopia's full-sized avatar

Ravil Bayramgalin brainopia

View GitHub Profile
@denisdefreyne
denisdefreyne / allocations.d
Last active December 15, 2015 18:29
This is a DTrace script for Ruby 2.0 that profiles object allocations.
#pragma D option dynvarsize=100m
dtrace:::BEGIN
{
self->depth = 0;
}
ruby*:::method-entry
{
self->depth++;
@somebody32
somebody32 / gist:5232120
Last active October 4, 2022 08:19
Список литературы для ознакомления с concurrent programming и реализацией этих принципов и подходов на ruby. Огромное спасибо @brainopia за составление.

Введение

Начать стоит отсюда. Не пугайтесь то, что это книга по незнакомой OS, эти термины практически везде одинаковые и здесь они изложены в понятной для начинающих форме.

http://www.qnx.com/developers/docs/6.4.1/neutrino/getting_started/s1_procs.html

Прочесть нужно треть главы до подраздела "Starting a process", если С не пугает, читайте полностью. После прочтения вы будете понимать, что такое process, thread, mutex, priorites, semaphores, scheduler, contex-switch, kernel states.

Ruby

@headius
headius / 1_chart.png
Last active December 14, 2015 13:58
Benchmark of various method definition forms
1_chart.png

References in Ruby

Just for fun, I decided to add references to Ruby.

I decided to use Perl's backslash syntax, so for example you'd write \foo to take a reference to the local variable foo. You can also take a reference to instance variables, class variables and globals.

I have attached a patch in this gist if you're interested in the implementation or you want to try it out on your own copy of Ruby.

This was just a fun little exercise for me - I don't expect that this would ever be merged in to Ruby itself.

@coldnebo
coldnebo / rails_trace.rb
Last active December 1, 2018 08:10
This Rack middleware for Rails3 lets you see a call-trace of the lines of ruby code in your application invoked during a single request. Only code within your app is considered (i.e. in the /app folder). This expands on my previous attempt (https://gist.github.com/3077744). Example of output in comments below.
require 'singleton'
# outputs a colored call-trace graph to the Rails logger of the lines of ruby code
# invoked during a single request.
#
# Example:
#
# 1) Make sure this file is loaded in an initializer
#
# 2) Add the following to your application.rb in Rails3:
@pbrisbin
pbrisbin / remote-test.rb
Created December 12, 2012 17:02
Remote test runner
#!/usr/bin/env ruby
#
# Vagrant users are constantly switching between a local editor and a
# terminal into their VM to work on code then run the tests.
#
# This script (when used as a server) listens on a TCP port inside the
# VM for test commands to execute. The script (when used as a client)
# also handles sending the appropriate "run this test" command to that
# same port on the VM.
#
@funny-falcon
funny-falcon / changes.md
Last active March 23, 2024 05:53
Performace patch for ruby-1.9.3-p327

Changes:

  • this version includes backport of Greg Price's patch for speedup startup http://bugs.ruby-lang.org/issues/7158 .

    ruby-core prefers his way to do thing, so that I abandon cached-lp and sorted-lf patches of mine.

  • this version integrates 'array as queue' patch, which improves performance when push/shift pattern is heavily used on Array.

    This patch is accepted into trunk for Ruby 2.0 and last possible bug is found by Yui Naruse. It is used in production* for a couple of months without issues even with this bug.

@josevalim
josevalim / 0_README.md
Created September 13, 2012 21:52
Sinatra like routes in Rails controllers

Sinatra like routes in Rails controllers

A proof of concept of having Sinatra like routes inside your controllers.

How to use

Since the router is gone, feel free to remove config/routes.rb. Then add the file below to lib/action_controller/inline_routes.rb inside your app.

@jferris
jferris / surprise.rb
Created August 23, 2012 21:16
Principle of enjoyable surprises
test = test
# => nil
@test = @test
# => nil
$test = $test
# => nil
@@test = @@test
# NameError: uninitialized class variable @@test in Object
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@