Skip to content

Instantly share code, notes, and snippets.

View DAddYE's full-sized avatar

Davide D'Agostino DAddYE

  • Endor Labs
  • San Francisco
View GitHub Profile
@DAddYE
DAddYE / script.sh
Last active December 14, 2015 05:29
Open SSL problem with Ruby 2.0 ?
# Previous one is unsafe
you should take a look at this: https://github.com/raggi/openssl-osx-ca
@DAddYE
DAddYE / GC.rb
Created February 25, 2013 00:16
# Ruby 1.9
4.2.object_id == 4.2.object_id # => false
# Ruby 2.0
warn "Optimization only on 64 bit systems" unless 42.size * 8 == 64
4.2.object_id == 4.2.object_id # => true (4.2 is immediate)
4.2e100.object_id == 4.2e100.object_id # => false (4.2e100 isn't)
@DAddYE
DAddYE / Emojis
Last active June 7, 2017 14:35
See comments!
@DAddYE
DAddYE / soda.vim
Last active December 11, 2015 14:59
" moved to https://github.com/DAddYE/soda.vim
export CONFIGURE_OPTS="\
--disable-install-doc \
--with-readline-dir=$(brew --prefix readline) \
--with-openssl-dir=$(brew --prefix openssl)
--with-yaml-dir=$(brew --prefix yaml) \
--with-gdbm-dir=$(brew --prefix gdbm) \
--with-libffi-dir=$(brew --prefix libffi)"
module Async
class Queue
attr_reader :worker, :concurrency
attr_accessor :saturated,
:drain
def initialize(concurrency, &block)
@worker = block
@workers = 0
@concurrency = concurrency
@DAddYE
DAddYE / application_controller.rb
Created January 2, 2013 19:02
Performance tips for rails
class ApplicationController < ActionController::Base
around_filter :disable_gc
private
def disable_gc
GC.disable
begin
yield
ensure
#!/usr/bin/env ruby
if ARGV[0]
signal =
case ARGV[0]
when 'wait' then :USR1
when 'restart' then :USR2
end
Process.kill(signal, ARGV[1].to_i)
@DAddYE
DAddYE / simple_fiber_concurrency.rb
Created November 26, 2012 19:55
Simple example of concurrency in Ruby with Fiber.
require "fiber"
f1 = Fiber.new do |f2|
while true
puts "A"
sleep 2
f2.transfer
end
end
module EventMachine
def self.system3(cmd, *args, &cb)
cb ||= args.pop if args.last.is_a? Proc
init = args.pop if args.last.is_a? Proc
# merge remaining arguments into the command
cmd = ([cmd] + args.map{|a|a.to_s.dump}).join(' ')
new_stderr = $stderr.dup