Skip to content

Instantly share code, notes, and snippets.

View fernandoalmeida's full-sized avatar

Fernando Almeida fernandoalmeida

View GitHub Profile
@fernandoalmeida
fernandoalmeida / atena-api-doc.json
Created March 17, 2020 18:39
Swagger API doc test
{"info":{"description":"Poliedro API","title":"Atena API","version":"0.1.0"},"openapi":"3.0.0","paths":{"/api/v1/schools":{"get":{"description":"","parameters":[{"description":"","in":"header","name":"content-type","required":false,"schema":{"type":"string"}},{"description":"","in":"header","name":"accept","required":false,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/vnd":{"schema":{"properties":{"data":{"description":"","type":"string"},"jsonapi":{"description":"","type":"string"}},"type":"object"}}},"description":"index/1 returns a list of schools that the user has access","headers":{"cache-control":{"schema":{"type":"string"}},"content-type":{"schema":{"type":"string"}},"x-request-id":{"schema":{"type":"string"}}}}},"summary":""}}}}
@fernandoalmeida
fernandoalmeida / gist:d5b21553bd5b5ab0c21dc371d1dababd
Last active November 29, 2022 21:18
How to limit cpu/memory usage of applications using cgroups on Debian Jessie
##################################################
$ sudo apt-get install cgroup-tools
##################################################
# /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet cgroup_enable=memory swapaccount=1"
##################################################
@fernandoalmeida
fernandoalmeida / Gemfile
Last active August 29, 2015 14:02
Costom Rails Log
gem "lograge"
@fernandoalmeida
fernandoalmeida / application.rb
Last active December 20, 2015 11:59
Rails multi-tenant / multi-database with subdomains using a control database
# config/application.rb
module MyApp
class Application < Rails::Application
def config.database_configuration
config = super
ActiveRecord::Base.establish_connection(config["control"])
@fernandoalmeida
fernandoalmeida / application_controller.rb
Last active March 7, 2022 01:23
Rails multi-tenant / multi-database with subdomains using database.yml
before_filter :select_database
def select_database
if Rails.env == "production"
unless request.subdomain.empty?
begin
subdomain = request.subdomains.first
config = ActiveRecord::Base.configurations[subdomain]
if config
ActiveRecord::Base.establish_connection(config)
@fernandoalmeida
fernandoalmeida / .gitconfig
Created January 11, 2012 02:59
Git Config
[user]
name = Fernando Almeida
email = fernando@fernandoalmeida.net
[color]
ui = auto
[core]
editor = vim
excludesfile = .gitignore-global
[alias]
br = branch