Skip to content

Instantly share code, notes, and snippets.

View caiosba's full-sized avatar
🤘
Headbanger Hacker

Caio Almeida caiosba

🤘
Headbanger Hacker
View GitHub Profile
@caiosba
caiosba / monitor-links.sh
Created August 26, 2018 23:28
Script to monitor a list of links and e-mail the links that are offline... the links are read from a CSV file with the following columns in the following order: title, module, unit, URL (only URL is mandatory)
@caiosba
caiosba / upload-img-to-imgur.sh
Created April 8, 2017 14:49
Upload an image to Imgur - no API keys needed
#!/bin/bash
# Usage: ./upload-img-to-imgur.sh <image file path>
# Output: URL to the image on Imgur
filepath=$1
content_type="image/png"
filename="$(basename filepath)"
curl -X POST "http://imgur.com/upload" \
-H "Referer: http://imgur.com/upload" \
-F "Filedata=@$filepath;filename=$filename;type=$content_type" 2>/dev/null | sed 's/^{"data":{"hashes":\["\([^"]\+\).*/http:\/\/imgur.com\/\1/g'
echo
@caiosba
caiosba / dollar-reais-indicator.py
Created July 5, 2016 16:45
Ubuntu Unity Indicator to show current dollar value in Brazilian Reais (auto-updates every minute)
#!/usr/bin/env python
# Unity indicator for dolar/real currency
# Author: Caio Almeida <caiosba@gmail.com>
# 05 Jul 2016
import gobject
import gtk
import appindicator
import os, sys
import time
@caiosba
caiosba / csv2table.py
Created October 16, 2015 16:30
Python script to convert from CSV to a pretty ASCii table
#!/usr/bin/python
from __future__ import print_function
import prettytable
import csv
import sys
def main(argv):
if len(sys.argv) != 3:
print('Usage: python csv2table.py [input file] [output]\n')
@caiosba
caiosba / otf2ttf.ff
Created October 19, 2014 20:45
otf2ttf
#!/usr/local/bin/fontforge
# Quick and dirty hack: converts a font to truetype (.ttf)
# You need to install fontforge: aptitude install fontforge
# After that, simply run: fontforge -script otf2ttf.sh FONTNAME.otf
# Or, for a bunch of files: for i in *.otf; do fontforge -script otf2ttf.sh $i; done
Print("Opening " + $1);
Open($1);
Print("Saving " + $1:r + ".ttf");
Generate($1:r + ".ttf");
Quit(0);
@caiosba
caiosba / post-commit
Created June 12, 2014 00:30
Git hook to run tests after commit and notify a Slack channel
#!/bin/bash
# Run tests after commit and notify a Slack channel
webhook_url="https://<your subdomain>.slack.com/services/hooks/incoming-webhook?token=<your token>"
channel="#<your channel>"
root=$(git rev-parse --show-toplevel)
cd $root
repo=$(basename $root)
user=$(git config --global --get user.name)
output=$(bundle exec rake test)
@caiosba
caiosba / drupal-performance-check
Created January 27, 2014 04:50
Shell script to check which module(s) (or group of them) are responsible for high CPU load
#!/bin/bash
# This script disables the Drupal modules one by one and checks CPU load
# after disabling each. Please run it from the Drupal root. Set the URL below.
url='http://localhost/drupal'
# Check CPU load on the last minute
function cpuload {
uptime | sed 's/.*load average/CPU load on the last minute/g' | sed 's/,.*//g'
}