Skip to content

Instantly share code, notes, and snippets.

View simsalabim's full-sized avatar

Alexander Kaupanin simsalabim

View GitHub Profile
@simsalabim
simsalabim / kafka_topic_which_consumer_group.sh
Created September 13, 2021 14:50
Find which consumer group a Kafka topic belongs to. `TOPIC=my.topc.name ./kafka_topic_which_consumer_group.sh`
#!/bin/bash
counter=0;
for i in $(./kafka-consumer-groups.sh --list --bootstrap-server localhost:9092); do
printf '\r%3d'$counter;
if [[ $(./kafka-consumer-groups.sh --describe --group $i --bootstrap-server localhost:9092 2>/dev/null | grep $TOPIC) ]]; then
echo " " + $i
fi;
((counter++))
done
@simsalabim
simsalabim / .vimrc
Last active March 6, 2019 18:02
vimrc
" be iMproved
set nocompatible
" Vundle setup
" Plugin manager
"
" Brief help:
" :PluginList - list configured bundles
" :PluginInstall(!) - install(update) bundles
" :PluginSearch(!) foo - search(or refresh cache first) for foo
@simsalabim
simsalabim / rails_controller_params_bug_report.rb
Created March 2, 2016 04:13
Rails parses nested params incorrectly
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
def require_persistently(gem_name)
begin
require gem_name
rescue LoadError
puts "Installing #{gem_name}..."
`gem install #{gem_name}`
Gem.clear_paths
retry
ensure
require gem_name
@simsalabim
simsalabim / pickle_as_paranoid.rb
Last active December 28, 2015 07:49
Making pickle find models deleted with paranoid.
# https://github.com/ianwhite/pickle
# https://github.com/goncalossilva/acts_as_paranoid
#
# Given you created a 'deleted' factory
# And then you want to match it in steps with #{capture_model} like followiwng:
#
# Given a deleted user "Turanga Leela" exists
# Then /^(?:|I )select #{capture_model} from the table$/ do |user|
# model!(user)
# end
@simsalabim
simsalabim / console_log.js
Last active December 27, 2015 12:19
Advanced logging in JavaScript
// add some spice
console.log = function() {
window.alert(Array.prototype.slice.call(arguments, 0).join(' '));
}
@simsalabim
simsalabim / deviant_art_steps.rb
Last active December 27, 2015 06:39
How to stub Capybara's `page#source`
# First, there is another (simple) way to accomplish the task and I would suggest to never use approach shown below. I mean stub page#source.
#
# Given there are several steps which rely on `page#source`, for instance checking contents of downloaded CSV file.
# And we decided to store several CSV files in the cloud
# And we still want to test their contents
# Then we test output of file generators
# But we want to reuse and DO NOT TOUCH existing steps checking CSV files contents
# Then we decide to stub page#source
# Simple solution, nothing interesting here, you can skip it.
@simsalabim
simsalabim / ptchk.rb
Created August 3, 2012 10:08
Frd dtctr
class Ptchk; def prns?; Date.today.friday? end; end; Ptchk.new.prns?
@simsalabim
simsalabim / gist:913442
Created April 11, 2011 12:38
Template to list UL/OL in columns
{* @param Array $items collection of items to list *}
{* @param int $columnsCount quantity of colums in list representation *}
<ul style="white-space: nowrap;">
{assign var=itemsCount value=$items|@count}
{assign var=inColumn value=$itemsCount/$columnsCount|@ceil}
{foreach from=$items item=item key=key}
{if $key%$inColumn==0}
<ul style="width:250px;display:inline-block;vertical-align:top;">