Skip to content

Instantly share code, notes, and snippets.

View e2's full-sized avatar

Cezary Baginski e2

View GitHub Profile
@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 / 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

@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 / 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...')
require 'rspec'
RSpec.configure do |config|
def stub_mod(mod, excluded)
mod.constants.each do |klass_name|
klass = mod.const_get(klass_name)
if klass.is_a?(Class)
unless klass == described_class
unless excluded.include?(klass)
class_double(klass.to_s).as_stubbed_const(transfer_nested_constants: true)
# 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 / tracking file and dir changes
Last active August 29, 2015 13:59
How to PROPERLY think about watching file and directories for changes
# (For developers) How to PROPERLY think about watching files and directories for changes
Goal: saving people the frustration of getting tools to "correctly" respond to
changes to files or directories.
## How to think about directories
Here's an example TODO file (/home/me/Documents/todo.txt):