Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Coding time

Vinicius Souza vsouza

:octocat:
Coding time
View GitHub Profile
@vsouza
vsouza / .bashrc
Last active May 9, 2021
Golang setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell, fish or bash.
View .bashrc
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
@vsouza
vsouza / thread.py
Last active Mar 24, 2021
Python thread example.
View thread.py
from Queue import Queue
from threading import Thread
class Worker(Thread):
"""Thread executing tasks from a given tasks queue"""
def __init__(self, tasks):
Thread.__init__(self)
self.tasks = tasks
self.daemon = True
self.start()
@vsouza
vsouza / term_context.go
Created Sep 28, 2020 — forked from matryer/term_context.go
Making Ctrl+C termination cancel the context.Context
View term_context.go
func main() {
ctx := context.Background()
// trap Ctrl+C and call cancel on the context
ctx, cancel := context.WithCancel(ctx)
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
defer func() {
signal.Stop(c)
@vsouza
vsouza / parse_aws_s3_billing.py
Created Nov 17, 2015 — forked from oddskool/parse_aws_s3_billing.py
Simplistic script to parse the detailed AWS billing CSV file. Script displays cost of S3 operations broken down per region, bucket and usage type (either storage or network). It also sums up the amount of storage used per bucket. Output is filtered wrt to costs < 1$. See http://docs.aws.amazon.com/awsaccountbilling/latest/about/programaccess.html
View parse_aws_s3_billing.py
# -*- coding:utf-8 -*-
'''
Simplistic script to parse the detailed AWS billing CSV file.
Script displays cost of S3 operations broken down per region, bucket and usage
type (either storage or network). It also sums up the amount of storage used per bucket.
Output is filtered wrt to costs < 1$.
See http://docs.aws.amazon.com/awsaccountbilling/latest/about/programaccess.html for
how to set up programmatic access to your billing.
@vsouza
vsouza / installing_cassandra.md
Created Jul 30, 2020 — forked from hkhamm/installing_cassandra.md
Installing Cassandra on Mac OS X
View installing_cassandra.md

Installing Cassandra on Mac OS X

Install Homebrew

Homebrew is a great little package manager for OS X. If you haven't already, installing it is pretty easy:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@vsouza
vsouza / main.go
Created May 27, 2018 — forked from cespare/main.go
Example of testing Go HTTP servers using httptest.Server.
View main.go
package main
import (
"log"
"myserver"
"net/http"
)
const addr = "localhost:12345"
@vsouza
vsouza / Países - Mongo
Last active Jan 2, 2018
Lista com todos (ou quase) países do mundo, com nome em português e sigla.
View Países - Mongo
db.countries.insert({acron: 'AF', name: 'Afeganistão'} )
db.countries.insert({acron: 'AL', name: 'Albânia'} )
db.countries.insert({acron: 'DZ', name: 'Argélia'} )
db.countries.insert({acron: 'DS', name: 'Samoa'} )
db.countries.insert({acron: 'AD', name: 'Andorra'} )
db.countries.insert({acron: 'AO', name: 'Angola'} )
db.countries.insert({acron: 'AI', name: 'Anguilla'} )
db.countries.insert({acron: 'AQ', name: 'Antártica'} )
db.countries.insert({acron: 'AG', name: 'Antigua e / ou Barbuda'} )
db.countries.insert({acron: 'AR', name: 'Argentina'} )
@vsouza
vsouza / gist:cc16d0af73ebb1ac4e175ce61f908a04
Created Jan 2, 2018 — forked from digitaljhelms/gist:4287848
Git/GitHub branching standards & conventions
View gist:cc16d0af73ebb1ac4e175ce61f908a04

Branching

Quick Legend

Instance Branch Description, Instructions, Notes
@vsouza
vsouza / colorsUtil.swift
Last active Jul 20, 2017
Convert hex string to UIColor
View colorsUtil.swift
//
// ColorsUtil.swift
//
// Created by Vinicius Souza on 5/11/16.
// Copyright © 2016 Vinicius Souza. All rights reserved.
//
import Foundation
import UIKit
View kinesis_consumer.py
from __future__ import print_function
from pyspark import SparkContext
from pyspark.streaming import StreamingContext
from pyspark.streaming.kinesis import KinesisUtils, InitialPositionInStream
import datetime
import json
from pyspark.sql import SQLContext, Row
from pyspark.sql.types import *
aws_region = 'us-east-1'