Skip to content

Instantly share code, notes, and snippets.

View jasoares's full-sized avatar

João Soares jasoares

View GitHub Profile
@jasoares
jasoares / label-ns.yaml
Last active September 3, 2021 23:25 — forked from kvudata/label-ns.yaml
Use Helm hook to add labels to a namespace before chart installation
# This hook depends on helm creating the target namespace if it doesn't exist
# before the hook is called. This is the case on Helm v2.9.1
apiVersion: batch/v1
kind: Job
metadata:
name: label-ns
namespace: cicd
labels:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
@jasoares
jasoares / api_request_logs.txt
Created October 2, 2017 12:45
multiple extra requests api logs
[GET] Started GET "/v1/conferences/ws17/attendances?auth_token=eyJ0e...&per_page=250" for 213.233.132.168 at 2017-10-02 10:27:54 +0000
[GET] Started GET "/v1/conferences/ws17/timeslots?auth_token=eyJ0e..." for 213.233.132.168 at 2017-10-02 10:27:54 +0000
[GET] Started GET "/v1/conferences/ws17/me/appearances/popular?auth_token=eyJ0e...&q=pass" for 213.233.132.168 at 2017-10-02 10:27:54 +0000
[GET] Started GET "/v1/conferences/ws17/me/attendances/personalised?auth_token=eyJ0e...&q=pass" for 213.233.132.168 at 2017-10-02 10:27:55 +0000
[GET] Started GET "/v1/conferences/ws17/timeslot_locations?auth_token=eyJ0e..." for 213.233.132.168 at 2017-10-02 10:27:55 +0000
[GET] Started GET "/v1/conferences/ws17/me/attendances/popular?auth_token=eyJ0e...&q=pass" for 213.233.132.168 at 2017-10-02 10:27:55 +0000
[GET] Started GET "/v1/conferences/ws17/attendances?auth_token=eyJ0e...&per_page=250" for 213.233.132.168 at 2017-10-02 10:27:55 +0000
[GET] Started GET "/v1/conferences/ws17/me/appearances/popular?auth_token=eyJ0e.
@jasoares
jasoares / ssl_puma.sh
Created September 23, 2017 15:10 — forked from tadast/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@jasoares
jasoares / redis-inspect.rb
Created April 3, 2017 00:59
Redis Contents Describer
$redis = Redis.new
keys = $redis.keys('*')
keys_with_values = keys.inject({}) do |kwv, key|
type = $redis.type(key)
value = $redis.get(key) if type == 'string'
value = $redis.scard(key) if type == 'set'
value = $redis.hkeys(key) if type == 'hash'
value = $redis.llen(key) if type == 'list'
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the branch/status of the current git repository
# * the branch of the current subversion repository
# * the return value of the previous command
#
# USAGE:
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
###
Pokemon Go(c) MITM node proxy
by Michael Strassburger <codepoet@cpan.org>
This example just dumps all in-/outgoing messages and responses
###
PokemonGoMITM = require './lib/pokemon-go-mitm'
@jasoares
jasoares / disable-transparent-hugepages.sh
Created January 18, 2016 09:06
Bash script to setup /etc/init.d/disable-transparent-hugepages on multiple nodes
nodes=(rs0p rs0s)
for i in "${nodes[@]}"; do ssh -ti ~/.ec2/your_aws_key_pair.pem "ec2-user@$i.onliquid.com" 'sudo touch /etc/init.d/disable-transparent-hugepages && sudo bash -c "echo \"#!/bin/sh
### BEGIN INIT INFO
# Provides: disable-transparent-hugepages
# Required-Start: $local_fs
# Required-Stop:
# X-Start-Before: mongod mongodb-mms-automation-agent
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@jasoares
jasoares / better_mongos.js
Last active December 18, 2017 02:16
MongoDB Shell mongos helpers and custom prompt
/**
* MongoDB Shell mongos helper functions and custom prompt
*
* https://gist.github.com/jasoares/3b21af33a7d62263010f
*/
sh.getBalancerSummary = function(since) {
// 24 hours by default
since = since || new Date(ISODate().getTime() - 1000 * 60 * 60 * 24);
print("Printing Summary since " + since);
@jasoares
jasoares / balancer_scripts.js
Last active May 15, 2017 17:26
MongoDB Shard distribution and balancer scripts
var hugeCollections = db.chunks.aggregate([{ '$group': { _id: { ns: '$ns', shard: '$shard' }, count: { '$sum': 1 } } }, { '$match': { count: { '$gt': 100 } } }, { '$group': { _id: { ns: '$_id.ns' }, count: { '$max': '$count' } } }, { '$project': { _id: 0, coll: '$_id.ns', shard: '$_id.shard', count: '$count' } }, { '$sort': { count: -1 } }]); while(hugeCollections.hasNext()) { var coll = hugeCollections.next()['coll']; sh.enableBalancing(coll); }
var allCollections = db.collections.find(); while(allCollections.hasNext()) { var coll = allCollections.next()['_id']; sh.disableBalancing(coll); }
var allCollections = db.collections.find(); while(allCollections.hasNext()) { var coll = allCollections.next()['_id']; if(db.getSiblingDB('config').collections.findOne({ _id: coll }).noBalance == false) { print(coll + ': ' + db.getSiblingDB('config').collections.findOne({ _id: coll }).noBalance); } }
db.chunks.aggregate([{ '$match': { _id: /db_name/ } }, { '$group': { _id: { ns: '$ns', shard: '$shard' }, count: { '$sum':