Skip to content

Instantly share code, notes, and snippets.

View mv's full-sized avatar

Marcus Vinicius Ferreira mv

View GitHub Profile
@mv
mv / useful_pandas_snippets.py
Created September 9, 2017 22:05 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
#!/usr/bin/env python
import hashlib
import optparse
import paramiko
from Crypto.PublicKey import RSA
def insert_char_every_n_chars(string, char='\n', every=64):
return char.join(

============================================ System Operations Engineer @ Dinda.com.br/Baby.com.br

Manage an infrastructure that is impossible to outgrow!

Your responsibilities

Enjoy the DevOps lifestyle; automate everything. Have fun scripting as well as programming.

{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Core ec2 example: http://coreos.com/docs/ec2/",
"Parameters": {
"InstanceType" : {
"Description" : "EC2 instance type",
"Type" : "String",
"Default" : "t1.micro",
"AllowedValues" : [ "t1.micro","m1.small","m1.medium","m1.large","m1.xlarge", "m3.xlarge", "m3.2xlarge", "m2.xlarge","m2.2xlarge","m2.4xlarge","c1.medium","c1.xlarge","cc1.4xlarge","cc2.8xlarge","cg1.4xlarge", "hi1.4xlarge", "hs1.8xlarge"],
@mv
mv / check_aws_status.rb
Created October 16, 2012 12:35 — forked from ktheory/check_aws_status.rb
Nagios plugin to check AWS Status RSS feeds
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'net/http'
# check_aws_status.rb
# A nagios plugin for fetching RSS feeds from http://status.aws.amazon.com.
# Source: https://gist.github.com/1604786
# Written by Aaron Suggs: https://github.com/ktheory
@mv
mv / redis2txt.rb
Created August 18, 2012 09:27 — forked from nono/redis2txt.rb
Export data from redis to a plain text files
#!/usr/bin/env ruby
require "redis"
redis = Redis.new
redis.keys("*").each do |key|
val = case redis.type(key)
when "string"
redis.get key
when "list"
@mv
mv / gist:2819323
Created May 28, 2012 13:55 — forked from matthewhudson/good-commit.md
Linus Torvalds describes a good commit message. See https://github.com/torvalds/subsurface/blob/master/README#L161
A good commit message looks like this:
Header line: explaining the commit in one line
Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc etc.
The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
@mv
mv / cronjob.sh
Created January 21, 2012 18:06
Script to transform Amazon RDS slow log table into the MySQL slow query log format
#!/bin/bash
(/usr/local/bin/db2log | \
mk-query-digest --fingerprints \
--filter '$event->{user} !~ m/^(bi|memonic)$/') 2>&1 | \
mail -s "MySQL slow logs" root
# Rotate slow logs. Will move them into the backup table slow_log_backup. If
# that table exists it's overwritten with the primary slow log.
# So with this strategy we can still access yesterday's slow log by querying
# slow_log_backup.
@mv
mv / parse-json.rb
Created December 21, 2011 13:39 — forked from mislav/stupid-json.rb
Stupid simple JSON parser
require 'strscan'
require 'forwardable'
# Stupid JSON parser. Only handles well-formed JSON.
# Otherwise, it may go into an endless loop.
class Parser
WSP = /\s+/
OBJ = /[{\[]/
NUM = /-?\d+(\.\d+)?([eE][+-]?\d+)?/
BOL = /(?:true|false)\b/
@mv
mv / shared.rb
Created December 21, 2011 13:36 — forked from pbosetti/shared.rb
IPC shared memory access via FFI
#!/usr/bin/env ruby
# untitled.rb
# Created by Paolo Bosetti on 2011-04-22.
# Copyright (c) 2011 University of Trento. All rights reserved.
require "rubygems"
require 'ffi'
module Shared