Skip to content

Instantly share code, notes, and snippets.

View GuilhermeBarile's full-sized avatar

Guilherme Barile GuilhermeBarile

  • Toptal
  • São Paulo
View GitHub Profile
@GuilhermeBarile
GuilhermeBarile / terraform-update.sh
Created December 27, 2018 13:31
Update terraform to latest release
#!/bin/bash
current_version=$(terraform -v | head -n1 | cut -dv -f2)
echo "Running terraform $current_version"
echo -n "Checking for updates..."
version=$(curl -s https://releases.hashicorp.com/terraform/ | grep -vE '(alpha|beta|rc)' | grep 'href="/terraform' | cut -d\" -f2 | head -n1 | cut -d\/ -f3)
if [ "$version" = "$current_version" ]; then
DOMAIN_WHITELIST {
map = "redis://whitelist_domains";
type = "from";
action = "accept";
filter = "email:domain";
}
USER_WHITELIST {
map = "redis://whitelist_senders";
type = "from";
@GuilhermeBarile
GuilhermeBarile / server.py
Created November 3, 2017 11:59
Python HTTPServer example
# coding: utf-8
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
class S(BaseHTTPRequestHandler):
def do_GET(self):
data = [ { "Nome": "asdf" }, { "Nome": "fdsa" } ]
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
@GuilhermeBarile
GuilhermeBarile / deleteJenkinsJobs.groovy
Created August 16, 2017 21:48 — forked from nextrevision/deleteJenkinsJobs.groovy
Groovy script to delete all jenkins jobs that match a regex pattern
import jenkins.model.*
def matchedJobs = Jenkins.instance.items.findAll { job ->
job.name =~ /my_regex_here/
}
matchedJobs.each { job ->
println job.name
//job.delete()
}
@GuilhermeBarile
GuilhermeBarile / redis-rate-limiter.php
Last active May 7, 2021 00:41
php/redis rate limiter and blacklist handler
<?php
/**
* Based on https://engineering.classdojo.com/blog/2015/02/06/rolling-rate-limiter/
*/
for ($i = 1; $i < 20; $i++) {
// limit 5 runs of action by ip every 10 seconds, runs function if overflown
limit('action', 'ip', 5, 10, function($count) {
echo "Ran limit function after $count runs";
@GuilhermeBarile
GuilhermeBarile / tmux-cheatsheet.markdown
Created October 1, 2016 15:54 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
<?php
if (!class_exists('db')) {
class db implements Illuminate\Database\ConnectionResolverInterface {
/**
* Get a database connection instance.
*
* @param string $name
* @return \Illuminate\Database\ConnectionInterface
*/
public function connection($name = null)
#!/bin/bash
# -----------------------------------------------------------
# -- Write psdthumbnailer
# -----------------------------------------------------------
OUTFILE=/usr/lib/psdthumbnailer
(
sudo cat <<'EOF'
# bin/bash
@GuilhermeBarile
GuilhermeBarile / Ansible-Vault how-to.md
Created December 17, 2015 00:56 — forked from tristanfisher/Ansible-Vault how-to.md
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

##Working with ansible-vault

I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.

What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.

Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.

@GuilhermeBarile
GuilhermeBarile / Social RESTful URLs snippet.md
Created September 22, 2015 16:15 — forked from dr-dimitru/Social RESTful URLs snippet.md
Social links, +1s and shares using only HTML (no JS)