Skip to content

Instantly share code, notes, and snippets.

View eduardodeoh's full-sized avatar
🏠
Working from home

Eduardo de Oliveira Hernandes eduardodeoh

🏠
Working from home
  • São José do Rio Preto / SP / Brasil
View GitHub Profile
@eduardodeoh
eduardodeoh / 1_create_products.rb
Last active August 26, 2015 18:04 — forked from hakanensari/1_create_products.rb
Sequel + uuid-ossp
Sequel.migration do
up do
run 'CREATE EXTENSION "uuid-ossp"'
create_table :products do
column :id, :uuid, :default => Sequel.function(:uuid_generate_v4), :primary_key => true
end
end
end
@eduardodeoh
eduardodeoh / ip-up
Last active August 29, 2015 13:59
Add custom route to mac os x after vpn connection
#!/usr/bin/env bash
MY_SERVER="192.168.0.150"
#Solution 1
#VPN_GW=$(ifconfig | grep -A2 ppp | grep inet | awk '{print $4}')
##Add route to host only
#sudo route add -host $MY_SERVER $VPN_GW
# Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source.
# Will include all hosts the playbook is run on.
# Inspired from http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-etchosts.html
- name: "Build hosts file"
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present
when: hostvars[item].ansible_default_ipv4.address is defined
with_items: groups['all']
#!/bin/sh
#
## This is called to back up the WAL files to the slave.
## This is on top of replication and is used as another
## method to secure data successfully transferring from one
## database server to another.
ARCHIVE_DIR_ON_SLAVE="/var/lib/postgresql/walfiles"
LOG=1
LOG_FILE="/tmp/postgres_wal_archiving.log"
@eduardodeoh
eduardodeoh / rom_mapper_hash_to_new_hash.rb
Last active September 23, 2015 12:18
Rom Mapper - Hash with keys with object to plain hash
class Parents
include Anima.new(:mother_name, :father_name)
end
person_hash = { name: "eduardo", :parents=>#<Parents mother_name="Mary" father_name="Joe"> }
class PersonHashToNewHash < ::ROM::Mapper
relation :person
register_as :person_to_new_hash
@eduardodeoh
eduardodeoh / gist:b15e15099c71e8b58fae
Created September 30, 2015 21:54 — forked from maetl/gist:4542fc2390eb8701284e
Using transproc to compose various hash transformations and mappings
require 'transproc/all'
require 'addressable/uri'
##
# Convert string keys to symbols
#
transform = Transproc(:symbolize_keys)
data = {
'name' => 'Mark Rickerby',
@eduardodeoh
eduardodeoh / statsd
Created October 26, 2012 17:56
Statsd Init Script
#!/bin/bash
#
# /etc/rc.d/init.d/is24-statsd
#
# Starts the is24 statsd daemon
#
# chkconfig: 2345 20 80
# description: Frontend aggregatation of messages destined for graphite daemon
# processname: is24-statsd
@eduardodeoh
eduardodeoh / gist:3964742
Created October 27, 2012 14:04 — forked from chalmerj/gist:1492384
Init script for Graphite carbon-cache
#! /bin/sh
### BEGIN INIT INFO
# Provides: carbon-cache
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: carbon-cache init script
# Description: An init script for Graphite's carbon-cache daemon.
### END INIT INFO
@eduardodeoh
eduardodeoh / gitlab-resque
Created November 1, 2012 00:58
Gitlab Resque Init Script for Ubuntu 12.04
#! /bin/bash
# GITLAB
# Maintainer: @randx
# App Version: 3.0
# Modified by @eduardodeoh (Start GITLAB Resque only)
### BEGIN INIT INFO
# Provides: gitlab
# Required-Start: $local_fs $remote_fs $network $syslog redis-server
@eduardodeoh
eduardodeoh / gunicorn-graphite
Created November 1, 2012 03:56
Init Script for Gunicorn for Graphite
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: GitLab git repository management
# Description: GitLab git repository management
### END INIT INFO
APP_ROOT="/opt/graphite/webapp/graphite"
NAME="gunicorn-graphite"
DESC="Gunicorn Workers"