Skip to content

Instantly share code, notes, and snippets.

View fforbeck's full-sized avatar

Felipe Forbeck fforbeck

View GitHub Profile
@fforbeck
fforbeck / gist:cad4cc5049c19d2958b6464b7a88e15c
Created February 2, 2018 16:15 — forked from mmdemirbas/gist:3656288
Aggresive MySql Stored Procedure Debugging
DECLARE E INT DEFAULT 0;
DECLARE M TEXT DEFAULT NULL;
DECLARE CONTINUE HANDLER FOR 1000 SET E='1000', M="hashchk";
DECLARE CONTINUE HANDLER FOR 1001 SET E='1001', M="isamchk";
DECLARE CONTINUE HANDLER FOR 1002 SET E='1002', M="NO";
DECLARE CONTINUE HANDLER FOR 1003 SET E='1003', M="YES";
DECLARE CONTINUE HANDLER FOR 1004 SET E='1004', M="Can't create file '%s' (errno: %d)";
DECLARE CONTINUE HANDLER FOR 1005 SET E='1005', M="Can't create table '%s' (errno: %d)";
DECLARE CONTINUE HANDLER FOR 1006 SET E='1006', M="Can't create database '%s' (errno: %d)";
@fforbeck
fforbeck / wt-wttr-in.js
Last active November 3, 2017 18:34
Simple webtask I created to retrieve the current weather from Slack with command: `/wt wttr-in <city-name>`.
const got = require('got');
module.exports = (ctx, cb) => {
var weatherForCity = 'http://api.openweathermap.org/data/2.5/weather?&units=metric&APPID=8b49f82415341963f8768cce938de042&q=' + ctx.body.text;
got(weatherForCity)
.then(response => {
var json = JSON.parse(response.body);
var weather = json.weather[0].description + ', ' + json.main.temp + ' celcius';
cb(null, { text: weather});
})
@fforbeck
fforbeck / keybase.md
Created November 27, 2016 23:33
keybase

Keybase proof

I hereby claim:

  • I am fforbeck on github.
  • I am fforbeck (https://keybase.io/fforbeck) on keybase.
  • I have a public key ASCsk2AV2WsPAhosHTW23A9I0NuwzfIHdSzpSnKYRaCUUgo

To claim this, I am signing this object:

@fforbeck
fforbeck / hashtag_filter.json
Created July 13, 2016 18:42
ES Template config to preserve hashtag and mentions from tweets, so they can be queried.
"settings": {
"analysis": {
"filter": {
"hashtag_filter": {
"type": "word_delimiter",
"type_table": [
"# => ALPHA",
"@ => ALPHA"
]
}
@fforbeck
fforbeck / set_msg_size_policy.sh
Created June 7, 2016 21:43
Increase RabbitMQ message size for a queue using policy
sudo rabbitmqctl set_policy -p host --apply-to queues max-msg-size "^queue.name.pattern$" '{"max-length-bytes":100000000}'
@fforbeck
fforbeck / csr_conf.template
Last active May 24, 2016 18:30
Script to generate csr, key and crt
[ req ]
distinguished_name="req_distinguished_name"
prompt="no"
[ req_distinguished_name ]
C="<country>"
ST="<state>"
L="1234"
O="1234"
CN="{DOMAIN}"
@fforbeck
fforbeck / purge_queue.sh
Last active March 8, 2016 16:26
RabbitMQ - Purge Queue
rabbitmqctl purge_queue "<target.queue>" -p <vhost>
@fforbeck
fforbeck / configure_queues.sh
Created February 25, 2016 14:19
RabbitMQ - Command Line Setup. Create queue, bindings, exchanges with rabbitmqadmin and rabbitmqctl
#!/usr/bin/env bash
URL="http://localhost:15672/cli/rabbitmqadmin"
VHOST="<>"
USER="<>"
PWD="<>"
QUEUE="<>"
FAILED_QUEUE="<>"
@fforbeck
fforbeck / move_messages.sh
Created February 25, 2016 14:10
RabbitMQ - Shovel Plugin: Move messages from one queue to another via command line
# The command deletes the parameter after all messages are moved origin to target queue
rabbitmqctl set_parameter -p <vhost> shovel "<origin.queue.name>" '{"src-uri":"amqp://<user>:<pwd>@/<vhost_name>","src-queue":"<origin.queue.name>","dest-uri":"amqp://<user>:<pwd>@/<vhost_name>","dest-exchange":"<target.queue.name>","prefetch-count":1,"reconnect-delay":5,"add-forward-headers":false,"ack-mode":"on-confirm","delete-after":"queue-length"}'
@fforbeck
fforbeck / allocate_unassigned_shard.sh
Last active March 10, 2016 19:54
Allocate unassigned shard from Elasticsearch node
##
# http://stackoverflow.com/questions/19967472/elasticsearch-unassigned-shards-how-to-fix
##
NODE="YOUR NODE NAME"
IFS=$'\n'
for line in $(curl -s 'localhost:9200/_cat/shards' | fgrep UNASSIGNED); do
INDEX=$(echo $line | (awk '{print $1}'))
SHARD=$(echo $line | (awk '{print $2}'))
curl -XPOST 'localhost:9200/_cluster/reroute' -d '{