Skip to content

Instantly share code, notes, and snippets.

View pior's full-sized avatar

Pior Bastida pior

View GitHub Profile
@pior
pior / gcs.py
Created October 10, 2017 21:19
import google.cloud.exceptions
import google.cloud.storage
class GCSFileStore:
def __init__(self, credentials_path, bucket_name):
Client = google.cloud.storage.Client
client = Client.from_service_account_json(credentials_path)
self._bucket = client.bucket(bucket_name)
@pior
pior / httpinfo.sh
Created September 20, 2017 04:01
Fetch some information from a host or an url
httpinfo () {
local urlorhost=$1
local host=${urlorhost#*//}
local bold=$(tput setaf 37);
local reset=$(tput sgr0);
echo "${bold}DNS records:${reset}"
dig +nocmd ${host} any +multiline +noall +answer;
def not_found_error(detail):
error = {'id': 'not_found', 'detail': detail}
return JSONApiObject(errors=[error])
class JSONApiObject:
"""Container for JSON API response."""
def __init__(self, data=None, errors=None):
self.data = data
@pior
pior / debug.sh
Created August 10, 2017 21:16
Debugging Kafka on AlpineLinux
# https://github.com/edenhill/librdkafka/wiki/Using-SSL-with-librdkafka
apk add --update openssl-dev
curl https://codeload.github.com/edenhill/kafkacat/tar.gz/master | tar xzf - && cd kafkacat-* && bash ./bootstrap.sh
./kafkacat -C -b ... -t TOPIC -X 'security.protocol=ssl' -X ssl.certificate.location=tls.crt -X ssl.key.location=tls.key
@pior
pior / Fictional-README.md
Created July 2, 2017 19:47
DevUp - help your contributors to onboard

MyProject

Development

  • Install DevUp with brew install devup or pip install devup.
  • Clone the project with de clone user/myproject.
  • Prepare your local development environment de up.
  • Test and lint! de test de lint

This is an argument in favor of using single underscore for declaring internal attributes (methods or variables).

1. PEP8 specify exactly this:

Use one leading underscore only for non-public methods and instance variables.
...
Even with __all__ set appropriately, internal interfaces
(packages, modules, classes, functions, attributes or other names)
@pior
pior / cloud_trace.rb
Created February 13, 2017 19:26
Simple ruby lib for Google Cloud Trace
require 'securerandom'
require 'date'
require 'googleauth'
require 'google/apis/cloudtrace_v1'
class CloudTrace
def initialize(project_id)
@project_id = project_id
require 'securerandom'
require 'date'
require 'googleauth'
require 'google/apis/cloudtrace_v1'
service = Google::Apis::CloudtraceV1::CloudTraceService.new
service.authorization = Google::Auth.get_application_default(['https://www.googleapis.com/auth/trace.append'])
project_id = 'XXXXX'
@pior
pior / poi.rst
Last active November 13, 2016 21:30

Buddy, your Cloudformation/ECS valet

Opinionated tools to manage your AWS infrastructure.

Manage your cloudformation stacks

title

  $ git 
  poipoi