Skip to content

Instantly share code, notes, and snippets.

View naxhh's full-sized avatar
💻
Devoping

Ignacio Tolstoy naxhh

💻
Devoping
  • Barcelona
View GitHub Profile
@marwei
marwei / how_to_reset_kafka_consumer_group_offset.md
Created November 9, 2017 23:39
How to Reset Kafka Consumer Group Offset

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)
@javierarques
javierarques / protractorAPICheatsheet.md
Last active March 3, 2025 17:08
Protractor API Cheatsheet
@alexei-led
alexei-led / fix_boot2docker_tsl
Created July 9, 2015 08:19
Fix boot2docker TSL error: "...certificate is valid for 127.0.0.1, 10.0.2.15, not ..." for IP
# SSH to Boot2Docker with `boot2docker ssh`
# add your IP to command bellow, run this command as superuser
/usr/local/bin/generate_cert --host=boot2docker,127.0.0.1,10.0.2.15,192.168.59.103 --ca=/var/lib/boot2docker/tls/ca.pem --ca-key=/var/lib/boot2docker/tls/cakey.pem --cert=/var/lib/boot2docker/tls/server.pem --key=/var/lib/boot2docker/tls/serverkey.pem
@trikitrok
trikitrok / Rock-paper-scissorsKata.md
Last active August 29, 2015 14:08
Unconditional Rock-paper-scissors kata

In this kata we'll use TDD to develop an object-oriented solution for the Rock-paper-scissors game.

The catch is that we can't use any conditionals, that is, if, switch, ternary operator or any other type of conditionals are not allowed.

It's an introductory kata which will help you to hone your OO skills.

This would be the initial code in Ruby:

class RockPaperScissors
# Description:
# Control marathon via hubot
#
# Configuration:
# HUBOT_MARATHON_HOST=marathon.yourcompany.com:8080
#
# Commands:
# hubot marathon - show the instances of all apps
# hubot marathon <id> - show the number of instances for app <id>
# hubot scale <id> <number> - scale app ID to <number> instances
@dhrrgn
dhrrgn / gist:10125477
Last active February 26, 2021 18:42
Upgrade Ubuntu OpenSSL to patch Heartbleed
sudo apt-get update
sudo apt-get install -y libssl1.0.0 openssl
# Confirm Build Date is at least Aril 7th 2014
openssl version -a
# Restart all services listed by this command:
sudo lsof -n | grep ssl | grep DEL
function onlyStatic (middleware) {
return function (req, res, next) {
var match = /(\.css|\.eot|\.gif|\.html|\.js|\.png|\.svg|\.ttf|\.woff|\.jpg)($|\?.*$)/ig.exec(req.originalUrl);
if (!match) return next();
middleware(req, res, next);
};
}
//usage
this.use(onlyStatic(express.static(__dirname + "/public")));
server {
# Redirect any subdomain to the root domain
# to be captured by next server block
server_name *.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
root /var/www;
index index.html index.htm;
@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active March 27, 2025 04:09
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost