Skip to content

Instantly share code, notes, and snippets.

View colszowka's full-sized avatar

Christoph Olszowka colszowka

View GitHub Profile
colszowka / dns_check.rb
Last active October 12, 2022 10:39
Ruby DNS Check
require 'resolv'
class DnsCheck
attr_reader :host
def initialize(host)
@host = host
def a
@a ||=, Resolv::DNS::Resource::IN::A)
# Blocks while a client is connected, and does not time out automatically
require 'socket'
require 'etc'
Socket.unix_server_loop("/tmp/sock") do |socket|
login = Etc.getpwuid(socket.getpeereid.first).name
puts "#{login} connected"
input = socket.gets.strip
puts "#{login} sent #{input}"
colszowka / .rubocop
Created September 21, 2017 11:20
Rubocop Inline Disable Lint/RescueWithoutErrorClass Issue
# Migration Tool for Redmine issue and time entry comments from SVN revisions to Git (i.e. r1234 => commit:abcdef789)
# ==============================
# (c) 2009 Christoph Olszowka & Sebastian Georgi, Capita Unternehmensberatung
# We used this when we migrated two of our main repositories from svn to git (see
# and wanted to have our revision links in Redmine reflect that change, too.
colszowka / cov.rb
Last active December 18, 2015 19:00
Quick demo of the problem of resetting Ruby STDLIB's Coverage mid-way
# On "ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-linux]", but should be the same on all 1.9+
require 'coverage'
require './foo'
puts Coverage.result
# {"foo.rb"=>[1, 1, 0, nil, nil, 1, 0, nil, nil]}
puts Coverage.result
# Works as expected
$ rvm use 1.9.2
Using /Users/colszowka/.rvm/gems/ruby-1.9.2-p136
~ 1.9.2-p136 $ irb
>> "1.9".respond_to?(:encoding)
=> true
>> 7.123.round
=> 7
>> 7.123.round(2)
=> 7.12
# Migration tool from SVN to git
# ==============================
# (c) 2009 Christoph Olszowka, Capita Unternehmensberatung
# This is not meant for usage in an actual shell script - you're better off running
# each individual block (marked by the comments) separately and check the output to see if everything
# went right - this is more a writeup of the required steps so I can remember them rather than a
# shoot-and-forget-solution.
# Will find the rdoc paths of your local gems and generate a html index frameset which will let you select
# the desired gem's rdoc from a dropdown navigation...
# Specify your local gems installation's doc directory and the desired html output path, open the generated index.html
# in the output path in your favorite browser and add a boomark.
# You might want to add the script into your path for easy access or put it in a cron job.
# Tested on Ubuntu 8.10, but really should work anywhere with proper gem install path set
colszowka / heroku-shell
Created February 17, 2014 14:02
A very simple shell for the heroku CLI that allows you to avoid typing `heroku` and `--app app_name` all the time
#!/usr/bin/env ruby
require "readline"
unless APP_NAME
STDERR.puts "Usage: #{$0} HEROKU_APP_NAME"
exit 1