Skip to content

Instantly share code, notes, and snippets.

View brunohcastro's full-sized avatar

Bruno Henrique de Castro brunohcastro

View GitHub Profile
@brunohcastro
brunohcastro / 0_reuse_code.js
Created August 7, 2014 22:39
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@brunohcastro
brunohcastro / esc-pos-image.py
Created September 22, 2015 17:04 — forked from scruss/esc-pos-image.py
print image files to thermal printer ESC-POS on stdout
#!/usr/bin/python
# esc-pos-image.py - print image files given as command line arguments
# to simple ESC-POS image on stdout
# scruss - 2014-07-26 - WTFPL (srsly)
# if you want a proper CUPS driver for a 58mm thermal printer
# that uses this command set, go here:
# https://github.com/klirichek/zj-58
import sys
@brunohcastro
brunohcastro / route53DynDNS.bash
Created February 13, 2016 12:27 — forked from simonmcc/route53DynDNS.bash
Amazon Route 53 Dynamic DNS Updater Script
#!/bin/bash
#
# This script requires xpath to parse part of the dnscurl.pl output
# on CentOS/RedHat/Amazon Linux:
#
# sudo yum install perl-XML-XPath
#
# also, dnscurl.pl (from http://aws.amazon.com/code/Amazon-Route-53/9706686376855511)
# expects your secrets to be in ~/.aws-secrets
# using a file format like this (from http://dmz.us/wp/wp-content/uploads/r53/aws-secrets.txt)
@brunohcastro
brunohcastro / le-renew-webroot
Created March 1, 2016 19:48 — forked from thisismitch/le-renew-webroot
Let's Encrypt Auto-Renewal using the Webroot Plugin (Nginx)
#!/bin/bash
web_service='nginx'
config_file="/usr/local/etc/le-renew-webroot.ini"
le_path='/opt/letsencrypt'
exp_limit=30;
if [ ! -f $config_file ]; then
echo "[ERROR] config file does not exist: $config_file"
@brunohcastro
brunohcastro / rbenv-install-system-wide.sh
Created March 2, 2016 02:13 — forked from jnx/rbenv-install-system-wide.sh
rbenv install and system wide install on Ubuntu 10.04 LTS.
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path:
@brunohcastro
brunohcastro / app.js
Created April 17, 2016 16:58 — forked from sogko/app.js
gulp + expressjs + nodemon + browser-sync
'use strict';
// simple express server
var express = require('express');
var app = express();
var router = express.Router();
app.use(express.static('public'));
app.get('/', function(req, res) {
res.sendfile('./public/index.html');
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserify = require('gulp-browserify'),
concat = require('gulp-concat'),
embedlr = require('gulp-embedlr'),
refresh = require('gulp-livereload'),
lrserver = require('tiny-lr')(),
express = require('express'),
livereload = require('connect-livereload')
livereloadport = 35729,
@brunohcastro
brunohcastro / consul-register.sh
Created October 31, 2016 06:35 — forked from double-z/consul-register.sh
Register with Chef-Provisioning-Registry via consul
#!/bin/bash
MACHINE_TYPE=$1
USER_NAME='provisioner'
USER_HOME="/home/$USER_NAME"
if [ -d $USER_HOME ]
then
echo "ALREADY REGISTERED"
else
#!/usr/bin/bash
#
# Script to notify user for new mails.
# Crontab ex:
# */3 * * * * ~/bin/offlineimap-notify.sh
#
#run OfflineIMAP once, with quiet interface
offlineimap -o -q -u quiet
@brunohcastro
brunohcastro / gpg-import-and-export-instructions.md
Created April 3, 2017 17:53 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...