Skip to content

Instantly share code, notes, and snippets.

View jasoares's full-sized avatar

João Soares jasoares

View GitHub Profile
@gottfrois
gottfrois / Dockerfile
Created September 6, 2018 09:06
medium-multi-stage-dockerfile-final-dockerfile
###############################
# Stage wkhtmltopdf
FROM madnight/docker-alpine-wkhtmltopdf as wkhtmltopdf
######################
# Stage: ruby
FROM ruby:2.5.1-alpine3.7 as ruby
LABEL description="Base ruby image used by other stages"
######################
@kvudata
kvudata / label-ns.yaml
Created June 27, 2018 20:20
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: kube-system
labels:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
###
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 / 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);
@lmmendes
lmmendes / 003-mongo-retry.rb
Created May 24, 2015 10:03
Monkey patch for Mongoid 4.x "Could not connect to a primary node for replica set"
#==================================================================================================
# Monkey Patch (lmmendes)
# MongoDB or in this case Mongoid and it's driver Moped have problems running some commands
# when the Primary node goes down and Moped tries to write to the database before
# refreshing the cluster info or at least trying the same command on each node before failing.
# From GitHub:
# Moped::Errors::ConnectionFailure: Could not connect to a primary node for replica set
# https://github.com/mongoid/moped/issues/348
#==================================================================================================
@jasoares
jasoares / mongod
Created February 11, 2015 02:58
Custom mongod init script with minor changes on runlevels and paths
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 2345 85 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod
# config: /etc/mongod.conf
# pidfile: /var/run/mongodb/mongod.pid
@tadast
tadast / ssl_puma.sh
Last active January 29, 2024 04:41 — forked from trcarden/gist:3295935
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
echo deb http://apt.newrelic.com/debian/ newrelic non-free >> /etc/apt/sources.list.d/newrelic.list
wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add -
apt-get update
apt-get install newrelic-sysmond
nrsysmond-config --set license_key=YOUR_LICENSE_KEY
/etc/init.d/newrelic-sysmond start
@jasoares
jasoares / default_object_to_s.rb
Last active December 11, 2015 22:19
Override default Object#to_s preserving class and encoded id like #<Nokogiri::XML::Element:0x11ab674 @var="123" ...
# This reimplementation produces the following sample result
# => #<Object:0x000000018436d0 @var=3>
def to_s
"#<%s:%#0.14x @var=%s>" % [self.class, self.__id__.abs*2, var]
end
# It is also possible to minify it by tweaking precision an getting rid
# of all those zeros like so:
# => #<Object:0x18436d0 @var=3>
def to_s
@jasoares
jasoares / ubuntu java sun installation.md
Created December 12, 2012 23:36
Installation guide for Sun's JDK in Ubuntu

Installing Sun JDK 6 on Ubuntu 12.04:

Download the sun jdk 6 bin

Make the bin file executeable:

chmod +x jdk-6u32-linux-x64.bin

Extract the bin file:

./jdk-6u32-linux-x64.bin