Skip to content

Instantly share code, notes, and snippets.

View dserodio's full-sized avatar
🐕

Daniel Serodio dserodio

🐕
View GitHub Profile
@dserodio
dserodio / .editorconfig
Created January 26, 2023 20:48
EditorConfig config file
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file and no trailing whitespace
[*]
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
@dserodio
dserodio / history.sh
Last active January 11, 2023 13:34
Misc bash snippets
# Show timestamp for history output
export HISTTIMEFORMAT="%d/%m/%y %T "
@dserodio
dserodio / nrql.sql
Last active November 11, 2022 22:04
New Relic NRQL snippets
-- Query APM agent version
-- https://discuss.newrelic.com/t/is-there-a-nrql-query-i-can-do-that-will-list-all-of-the-versions-of-my-apm-agents/105495
SELECT agentHostname, apmAgentVersion, apmAppName, apmLanguage
FROM NrDailyUsage
WHERE apmLanguage IS NOT NULL
SINCE 1 day ago
LIMIT MAX
@dserodio
dserodio / parse_yaml.sh
Last active September 19, 2022 17:50
Parse YAML using pure Bash
# bash-only parser that leverages sed and awk to parse simple yaml files
#
# See https://stackoverflow.com/a/21189044/31493 for usage, caveats, etc.
function parse_yaml {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\):|\1|" \
-e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
@dserodio
dserodio / parseDuration.gs
Created July 1, 2022 18:36
Google Apps Script for parsing duration strings
/* Based on: https://stackoverflow.com/a/44018490/31493 */
var duration = /(-?\d*\.?\d+(?:e[-+]?\d+)?)\s*([a-zμ]*)/ig
/**
* conversion ratios
*/
@dserodio
dserodio / aws.sh
Last active June 21, 2022 17:50
AWS snippets
# find the owner of an AWS access key
# https://stackoverflow.com/a/31275655
for user in $(aws iam list-users --output text | awk '{print $NF}'); do
aws iam list-access-keys --user $user --output text
done
# alternative that uses jq(1) insteaed of awk(1)
for user in $(aws iam list-users --query 'Users[*].UserName' --output text); do
@dserodio
dserodio / toggle_zero_columns.gs
Last active November 3, 2021 18:21
Hide Google Sheets columns with zeros
/*
* Usage: Tools > Script Editor
* replace all code with below
* Click Run
*
* Source: https://stackoverflow.com/a/13591754/31493
*/
function onOpen() {
// get active spreadsheet
@dserodio
dserodio / userChrome.css
Created June 10, 2021 20:48
Make Firefox bookmarks visible only on new tab page, like Chrome
/*
* Bookmarks toolbar is visible only on new tab page, just like Chrome.
*
* Screenshot: https://vimeo.com/235059188
* Video: https://vimeo.com/240436456
*
* Contributor(s): https://www.reddit.com/user/AJtfM7zT4tJdaZsm and Andrei Cristian Petcu
* https://www.reddit.com/r/FirefoxCSS/comments/7evwow/show_bookmarks_toolbar_only_on_new_tab/
*/
@dserodio
dserodio / ublock-filters.txt
Created May 28, 2021 13:31
uBlock Origin filters for blocking annoying push notification popups
!Source: https://www.reddit.com/r/brasil/comments/93zlgh/e_reclamam_do_adblock/e3ikvb9/
!
!Desabilitar notificações
||onesignal.com^
||pushcrew.com^
||widget.intercom.io^
||pushnews.eu^
! Block Pushnews (heavily abused by Exame, and other Brazilian media sites)
/pushnews-sw.js
@dserodio
dserodio / Vagrantfile
Last active October 14, 2020 12:00 — forked from lorn/Vagrantfile
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.provider :virtualbox do |vb|
vb.name = "ubuntu.local"
vb.customize [ 'modifyvm', :id, '--memory', '512' ]
vb.customize [ 'modifyvm', :id, '--cpus', '1' ]
end