Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Zambrano brianz

View GitHub Profile
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,
@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:
@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 / 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 / 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 / install-docker.sh
Last active Jun 22, 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
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
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:
@brianz
brianz / tech-scratch-pad.md
Last active Aug 11, 2016
brianz's tech scratch pad
View tech-scratch-pad.md

Sum column using awk

cat count.txt | awk '{sum+=$1} END {print sum}'

List open ports

linux: netstat -lnptu
mac: netstat -a -p tcp
View setup.py
from setuptools import setup, find_packages
setup(
name = 'calculator_service',
packages=find_packages(),
version = '1.0',
description = 'Example application with Servant',
author='Brian Zambrano',
author_email='brianz@gmail.com',
classifiers=[
You can’t perform that action at this time.