Skip to content

Instantly share code, notes, and snippets.

Brian Zambrano brianz

Block or report user

Report or block brianz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View switch.py
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(18)
if input_state == False:
View parse-postgresql-logs.py
"""Simple script to read stdin postgresql csv logs and output the SQL statements
To use, do something like this:
tail -f /path/to/your/postgres.log | python -u parse-postgresql-logs.py
"""
import csv
import sys
@brianz
brianz / install-docker.sh
Last active Jan 8, 2020
Install docker on Amazon Linux
View install-docker.sh
#!/bin/bash
#
# steps taken verbatim from:
# http://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html#install_docker
#
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
# log out and log in to pickup the added group
@brianz
brianz / logstash_fwder.conf
Created Sep 12, 2014
Get salt pillars from a specific grain
View logstash_fwder.conf
{% set instance_type = grains.get('instance_type', '') %}
{% set logstash_servers = salt['pillar.get'](instance_type + ':logstash_servers') %}
{% set logstash_paths = salt['pillar.get'](instance_type + ':logstash_paths') %}
{% set logstash_fields = salt['pillar.get'](instance_type + ':logstash_fields') %}
{% if logstash_servers and logstash_paths and logstash_fields %}
{
"network": {
"servers": {{ logstash_servers|json }}
@brianz
brianz / simple-echo-server.py
Created Sep 11, 2014
SimpleHTTPServer to echo the path from GET requests
View simple-echo-server.py
import sys
import SimpleHTTPServer
import SocketServer
try:
PORT = int(sys.argv[1])
except IndexError:
PORT = 8888
class EchoHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
@brianz
brianz / getpip.sls
Created Jul 30, 2014
Salt sls for installing pip via get-pip.py
View getpip.sls
get-pip:
file.managed:
- name: /usr/local/sbin/get-pip.py
- source: https://raw.githubusercontent.com/pypa/pip/1.5.6/contrib/get-pip.py
- source_hash: md5=3f120892a637a59a9c497d516eb2ca76
cmd.run:
- name: /usr/bin/python /usr/local/sbin/get-pip.py
- unless: which pip
- require:
@brianz
brianz / minion-or-master-config
Last active Aug 29, 2015
Multi environment salt minion or master config
View minion-or-master-config
master: localhost
file_client: local
file_roots:
base:
- /srv/salt/base
dev:
- /srv/salt/dev
- /srv/salt/base
qa:
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'fileutils'
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
box = {
:django_fwd => 9000,
:elasticsearch_fwd => 9200,
You can’t perform that action at this time.