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 / 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
###
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'
# uber-hacky dynamic collection names for MongoID models:
#
# class MyModel
# include Mongoid::PrefixableDocument # ...instead of Mongoid::Document
# include Mongoid::Timestamps
#
# field :foobar, :type => Integer
#
# def my_method; 123; end
#
If you want to use multiple dbs at once there are several different ways...
1) If you want to do this on a per-model level, use .store_in (This is for all threads):
class Band
include Mongoid::Document
store_in database: "secondary" # This can be any name you want, no need to put it in the mongoid.yml.
end
class Artist
# migrate all images to S3
namespace :paperclip_migration do
desc "migrate files from filesystem to s3"
task :migrate_to_s3 => :environment do
local_filesystem_root = Rails.root.to_s + "/public/system"
# Fetch all models and find out which ones have paperclip attachments
Rails.application.eager_load!
models = ActiveRecord::Base.send(:descendants).select {|model| model.respond_to?(:attachment_definitions) }
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
# By Steve Leung
# steve@leungs.me
class ActiveRecord::Relation
# temporarily hack for allowing combining scopes with OR
# doesn't add the join tables so need to use .includes manually
# ie. Jobship.includes(:job).or(Jobship.accepted, Jobship.declined).count
def or(*scopes)
clauses = *scopes.map do |relation|
@jasoares
jasoares / README.markdown
Created October 26, 2012 01:15 — forked from marijn/README.markdown
List of countries in YAML, CSV and TXT format

#List of countries

It's time someone compiled a list of countries to use within a web application. This gist attempts to make a first move at that.

List of nationalities

I've also compiled a list of nationalities

@jasoares
jasoares / readme.txt
Created May 22, 2012 22:03
Cucumber reader for sublime2
Just follow these steps:
cd Library/Application Support/Sublime\ Text\ 2/Packages/ ## go to your own directory of sublime
git clone git://github.com/cucumber/cucumber-tmbundle.git Cucumber
cd Cucumber/Syntaxes/
rm Cucumber\ Plain\ Text\ Feature.tmLanguage
wget https://raw.github.com/gist/864839/8752ef038ecaab8c9f3174b6ec419ed6f391e0c3/Cucumber%20Plain%20Text%20Feature.tmLanguage
Restart Sublime Text 2.
Then choose view->syntax->cucumber->cucumber steps.