Skip to content

Instantly share code, notes, and snippets.

View e2's full-sized avatar

Cezary Baginski e2

View GitHub Profile
@e2
e2 / stopping_backward_compatibility_madness.md
Last active April 8, 2020 05:30
How to stop the "Backward Compatibility Cult" before it kills Ruby.

How to stop the "Backward Compatibility Cult" before it kills Ruby.

  1. It's irresponsible to support Ruby < 2.2. A Ruby version is not "supported" if it's only getting security fixes. Because "support" means fixing bugs. And any Ruby version < 2.2 is rife with "never-to-be-fixed" bugs that can occur at any time. A minor OS upgrade, a minor gem upgrade ... and suddenly a new (or old) bug is triggered and Ruby crashes every time. At this point, the user may be forced to upgrade (at the most inconvenient time possible). The only other option is for everyone to implement some obscure workaround to side-step the bug in their outdated Ruby version. Ridiculous effort and costs just to keep a likely vulnerable (and definitely broken - even if it "works") version of Ruby around.

  2. Ruby 2.2.4 fixes an important vulnerability. There is a patch-level version of Ruby 2.0 (patch-level in code terms, not SemVer) and a minor of Ruby 2.1.9 to solve t

# HOW TO USE:
#
# 1) save this to /some_path/lib/minitests/autorun.rb
# 2) run your test with RSpec, e.g.
#
# $ RUBYLIB=/some_path/lib rspec -f d test/hello_test.rb
require 'rspec/core'
require 'rspec/matchers'
@e2
e2 / test_inotify.rb
Last active July 11, 2018 14:55
Script for testing inotify and listen on Linux
gem "rb-inotify"
require 'rb-inotify'
gem "listen"
require "listen"
dir = '.'
Listen.to(dir) do |modified, added, removed|
puts "listen: #{[added, modified, removed].inspect}!"
@e2
e2 / generate_relish_nav.rb
Created June 6, 2016 00:10
Create a Relish .nav file from a directory of *.feature files
require 'gherkin/parser'
require 'gherkin/pickles/compiler'
module RelishNav
class Collector
def initialize(feature_dir)
@feature_dir = feature_dir
@parser = Gherkin::Parser.new
end
@e2
e2 / compile_and_commit_assets.rb
Last active April 22, 2016 15:22
Simple script to help web designers work with and release compiled assets in the same git branch as the source assets.
#!/usr/bin/env ruby
#----------------------------------------------------------------------------
# INFO:
#
# Simple script for web designers working on git repositories where source
# assets and compiled assets have to be stored in the same branch.
#
# The goal: generating assets safely and into a separate commit.
#
set(TUP_LABEL $ENV{TUP_LABEL})
cmake_minimum_required(VERSION 3.2.2)
project(tup)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_TEMP_STORE=2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_THREADSAFE=0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_OMIT_LOAD_EXTENSION")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLUA_USE_MKSTEMP")
@e2
e2 / .travis.yml
Created February 28, 2012 11:07
Running PhantomJS tests on Travis
language: ruby
rvm:
- 1.9.3
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- bundle exec rackup ./test/config.ru 2>/dev/null &
- sleep 2
# encoding: utf-8
def test(a,b)
begin
result = ('テ'.encode(a) << 'テ'.encode(b)).encode('utf-8')
rescue Encoding::CompatibilityError
result = "FAILED!"
end
p "Example: #{a} + #{b}: #{result}"
end
@e2
e2 / gist:d58ec0374ce58e7c7495
Created April 16, 2015 20:43
Readline thread which didn't respond to kill
```
"NonBlockingInputStreamThread" daemon prio=10 tid=0x00007f55c4018800 nid=0x2294 in Object.wait() [0x00007f55fa726000] [153/516]
java.lang.Thread.State: WAITING (on object monitor) [152/516]
at java.lang.Object.wait(Native Method) [151/516]
- waiting on <0x00000000faca1e98> (a jline.internal.NonBlockingInputStream) [150/516]
at jline.internal.NonBlockingInputStream.run(NonBlockingInputStream.java:278)
@e2
e2 / guard
Last active August 29, 2015 14:13
Save this as bin/guard inside your projects
#!/usr/bin/env ruby
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= (Pathname(__FILE__).realpath + '../../Gemfile').to_s
require 'rubygems'
require 'bundler/setup'
while !system(Gem.bin_path('guard', 'guard')) && $?.exitstatus == 2
puts('Restarting guard...')