Skip to content

Instantly share code, notes, and snippets.

View strzibny's full-sized avatar
🏠
Working from home

Josef Strzibny strzibny

🏠
Working from home
View GitHub Profile
@strzibny
strzibny / gist:5108279
Created March 7, 2013 14:07
idn RubyGem patch for Ruby 2 which has standard encoding set to UTF-8 so you cannot count on comparison with standard strings
diff --git a/test/tc_Stringprep.rb b/test/tc_Stringprep.rb
index c7f15cb..bcdd401 100644
--- a/test/tc_Stringprep.rb
+++ b/test/tc_Stringprep.rb
@@ -60,7 +60,7 @@ class Test_Stringprep < Test::Unit::TestCase
def test_with_profile_STRINGPREP
TESTCASES_STRINGPREP.each do |key, val|
rc = Stringprep.with_profile(val[1], val[0])
- assert_equal(val[2], rc, "TestCase #{key} failed")
+ assert_equal(val[2].force_encoding('ASCII-8BIT'), rc, "TestCase #{key} failed")
SHELL = /bin/sh
# V=0 quiet, V=1 verbose. other values don't work.
V = 1
Q1 = $(V:1=)
Q = $(Q1:0=@)
ECHO1 = $(V:1=@:)
ECHO = $(ECHO1:0=@echo)
@strzibny
strzibny / gist:7136890
Created October 24, 2013 13:04
Patch for zzak's rdoc-4.0 branch of sdoc
From 3ee81e3239f4408c38f57b35344dbd424e7eab1d Mon Sep 17 00:00:00 2001
From: Josef Stribny <jstribny@redhat.com>
Date: Thu, 24 Oct 2013 14:48:46 +0200
Subject: [PATCH] Fix: Rename searchindex.rhtml file
---
lib/rdoc/generator/template/sdoc/search_index.rhtml | 8 ++++++++
lib/rdoc/generator/template/sdoc/searchindex.rhtml | 8 --------
2 files changed, 8 insertions(+), 8 deletions(-)
create mode 100644 lib/rdoc/generator/template/sdoc/search_index.rhtml
@strzibny
strzibny / gist:6505c3408e995f1e380f
Last active August 29, 2015 14:04
Check what kind of spec data are saved in Marshal.4.8.Z
#!/usr/bin/ruby
# Check what kind of spec data are saved in http://rubygems.org/Marshal.4.8.Z
require 'rubygems'
require 'pp'
# wget http://rubygems.org/Marshal.4.8.Z if needed
gems = Marshal.load(Gem.inflate(File.read("./Marshal.4.8.Z")))
SPEC_PARAMS = %w[ author authors name platform require_paths rubygems_version summary
license licenses bindir cert_chain description email executables
@strzibny
strzibny / gist:82c8c6e1608e1e40bea0
Last active August 29, 2015 14:23
gem-compare rake task example
# From Rakefile, expects :build task
task :clean do
`rm -rf pkg`
end
# Compare latest release with current git head
require 'rubygems/comparator'
task compare: [:clean, :build] do
git_version = VagrantPlugins::Registration::VERSION
#!/usr/bin/env ruby
require 'rubydns'
INTERFACES = [
[:udp, "0.0.0.0", 53],
[:tcp, "0.0.0.0", 53]
]
Name = Resolv::DNS::Name
IN = Resolv::DNS::Resource::IN
@strzibny
strzibny / unused_routes.rb
Created May 5, 2016 15:21
Find unused routes in Rails
#!/usr/bin/env ruby
# Extracted from traceroute gem + checking the presence of views as well
require_relative './config/environment.rb'
class Traceroute
def initialize(app)
@app = app
end
@strzibny
strzibny / routing.rb
Created May 10, 2016 18:25
Routing with Journey
#!/usr/bin/env ruby
require 'rails'
# App definition
class Application < Rails::Application
end
# Different application with directly defined routes that we can route to as well
class DifferentApplication < Rails::Application
routes.draw do
@strzibny
strzibny / middleware.rb
Created May 11, 2016 11:52
Rails default middleware
#!/usr/bin/env ruby
# http://guides.rubyonrails.org/v3.2.8/rails_on_rack.html
require 'rack'
require 'rails/all'
# Defaults are defined in railties/lib/rails/application/default_middleware_stack.rb
class Application < Rails::Application
routes.draw do
root to: Proc.new { [200, {'Content-Type' => 'text/html'}, ["Hello from app"]] }
end
@strzibny
strzibny / README.md
Created July 15, 2016 11:45 — forked from hofmannsven/README.md
My simply Git Cheatsheet