Skip to content

Instantly share code, notes, and snippets.

View rarylson's full-sized avatar

Rarylson Freitas rarylson

View GitHub Profile
@rarylson
rarylson / drawio.plugin.zsh
Last active September 2, 2023 22:50
Function to Draw.io CLI in MacOS to export to PNG all pages of a diagram
alias draw="/Applications/draw.io.app/Contents/MacOS/draw.io"
# Export all pages of a diagram to PNG
# Based on: https://stackoverflow.com/q/65404843/2530295
draw-export-all-pages-to-png () {
if [ "$#" -eq 0 ]; then
echo 2>&1 "No input file entered"
return 1
fi
if [[ ! "$1" == *.drawio ]]; then
@rarylson
rarylson / aws_cwlogs_get_event_logs_full.py
Last active September 2, 2023 23:06
Script to dump/download logs from AWS CloudWatch Logs
#!/usr/bin/env python3
# TODO - Possible improvements
#
# - Optionally add timestamp (events.timestamp) in a human readable format
# to the output. Useful if the date/time is not in the message itself.
# - Use filter_log_events instead of get_log_events, accepts a log stream
# pattern, and add log stream name to the output. Useful when we want to
# download logs from multiple log streams.
#
@rarylson
rarylson / mount.efs-nfs4
Created September 28, 2016 02:29
Mount helper for AWS EFS filesystems on AWS EC2 hosts
#!/bin/sh
# vim: et colorcolumn=80
set -e
# Mount helper for mounting AWS EFS filesystems on AWS EC2 hosts
#
# AWS EFS filesystems must be mounted as NFS4 filesystems using URLs (called
# "mount target DNS") that are different for each available zone.
# An EFS URL has the following format:
#
@rarylson
rarylson / rational.py
Last active July 9, 2016 03:54
A class that represents a rational number (useful for study purposes)
""" Module for working with fractional/rational numbers
"""
from functools import total_ordering
def gcd(a, b):
""" Greast common divisor between two numbers
It uses the Euclidean algorithm.
@rarylson
rarylson / automator_new_file.scpt
Last active March 1, 2024 01:03
AppleScript to create a new file in Finder (to be used in Automator)
-- AppleScript to create a new file in Finder
--
-- Use it in Automator, with the following configuration:
-- - Service receives: no input
-- - In: Finder.app
--
-- References:
-- - http://apple.stackexchange.com/a/129702
-- - http://stackoverflow.com/a/6125252/2530295
-- - http://www.russellbeattie.com/blog/fun-with-the-os-x-finder-and-applescript
@rarylson
rarylson / net-snmp-create-v3-user
Last active April 20, 2023 17:29
"net-snmp-create-v3-user" script for Ubuntu 14.04 (forgotten by the Ubuntu package mantainers)
#!/bin/sh
#
# $Id$
#
# this shell script is designed to add new SNMPv3 users
# to Net-SNMP config file.
prefix=/usr
exec_prefix=/usr
includedir=/usr/include
#! /bin/sh
set -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.