Skip to content

Instantly share code, notes, and snippets.

View pjanuario's full-sized avatar

Pedro Januário pjanuario

View GitHub Profile
@pjanuario
pjanuario / redis_keys_migration
Last active December 28, 2015 10:49
This script migrates redis keys namespaces
require 'redis'
module RedisMigrator
def self.run
from = "production:"
to = "development:"
start = Time.now
@pjanuario
pjanuario / analyze.rb
Last active December 31, 2015 15:49 — forked from ldmosquera/analyze.rb
Analyze redis keys patterns this was forked from previous script and updated
#!/usr/bin/env ruby
#usage: analyze.rb REDIS_PORT
#produces CSV with stats by key pattern
#ex: [foo:bar:123, foo:bar:234] -> foo:bar:ID
# development:hari:contest/log_entry#8a0b7edae8b965c9:log:in:contest
# development:hari:notification#24d1d025654c71e7:components
# development:rex:event#11570:traits
require 'rubygems'
@pjanuario
pjanuario / js-object-comparer.js
Created March 24, 2014 16:26
Compare javascript objects and output property name and value of different ones. Usefull for unit testing, property detection.
var compareKeys = function(obj, obj2){
for(var key in obj){
var _obj = obj[key];
var _obj2 = obj2[key];
if(!_obj){
if(_obj2){
console.log("%s: %s => %s",
key, _obj, _obj2);
@pjanuario
pjanuario / logger-facade-console-plugin-nodejs-sample.js
Last active February 5, 2016 09:31
This gist is logger facade console plugin nodejs usage sample
var Logger = require('logger-facade-nodejs');
var LoggerConsolePlugin = require('logger-facade-console-plugin-nodejs');
// this is the default config
var config = {
level: 'debug',
timeFormat: 'YYYY-MM-DD HH:mm:ss',
messageFormat: '%time | %logger::%level - %msg'
};
@pjanuario
pjanuario / LoggerAirbrakePluginSample
Created August 5, 2014 15:52
LoggerAirbrakePlugin sample
var Logger = require('logger-facade-nodejs');
var LoggerAirbrakePlugin = require('logger-facade-airbrake-plugin');
console.log("Start sample of Async error Log...");
var config = {
//api key, default (null)
apiKey: "apikey",
// host, default (null)
host: "api.airbrake.io",
@pjanuario
pjanuario / UserAge.rb
Created November 4, 2014 14:49
This gist contains some info about calculating users age avoiding leap year issues.
class User
attr_reader :born_on
def age(today = Time.now.utc)
return nil unless self.born_on.present?
((today.to_time - self.born_on.to_time) / 1.year).to_i
end
end
@pjanuario
pjanuario / download_files.sh
Last active August 29, 2015 14:28
Bash script to download files from a comma separated source file.
mkdir -p /tmp/downloaded_files
while IFS='' read -r line || [[ -n "$line" ]]; do
#echo "Text read from file: $line"
filename=$(echo $line | cut -d "," -f 1)
url=$(echo $line | cut -d "," -f 2)
echo "url: $url filename: $filename"
curl $url -o "/tmp/downloaded_files/$filename"
done < "$1"
@pjanuario
pjanuario / Microservices Stuff
Last active December 18, 2015 10:20
This gist will contain a bunch of links and stuff related with microservices researches and some thoughts maybe
Sam Newman - Building Microservices
http://shop.oreilly.com/product/0636920033158.do
Sam Newman podcast with Beth Skurrie about:
- microservices
- vanila rails codebase issues on larger codebases
- contract driven tests vs system integration tests
- pact
http://samnewman.io/blog/2015/12/16/magpie-talkshow-episode-8-beth-skurrie/
var Logger = require('logger-facade-nodejs');
var LoggerConsolePlugin = require('logger-facade-console-plugin-nodejs');
// this is the default config
var config = {
level: 'debug',
timeFormat: 'YYYY-MM-DD HH:mm:ss',
messageFormat: '%time | %logger::%level - %msg',
json: true
};
@pjanuario
pjanuario / snippets.cson
Created February 25, 2016 15:30
Atom snippets
'.source.js':
'Describe':
'prefix': 'desc'
'body': 'describe(\'$1\', function () {\n\tit(\'$2\', function () {\n\t\t$3\n\t});\n});'
'Test':
'prefix': 'it'
'body': 'it(\'$1\', function () {\n\t$2\n});'
'Before Each':
'prefix': 'be'
'body': 'beforeEach(function () {\n\t$1\n});'