Skip to content

Instantly share code, notes, and snippets.

View g-andrade's full-sized avatar

Guilherme Andrade g-andrade

  • Dash Games
  • Lisbon, Portugal
  • 08:16 (UTC +01:00)
View GitHub Profile
@ducfilan
ducfilan / iso3611-2 to FIPS.go
Created December 23, 2023 14:18
ISO 3611-2 to FIPS (regions)
var RegionCodeISO31662ToFIPS = map[string]string{
// From Maxmind's list.
"AD-2": "02",
"AD-3": "03",
"AD-4": "04",
"AD-5": "05",
"AD-6": "06",
"AD-7": "07",
"AD-8": "08",
if Code.ensure_loaded?(Ecto.Type) do
defmodule Bitstring do
@moduledoc """
Implements the Ecto.Type behaviour for the Postgres
type "bit varying"
"""
use Ecto.Type
@calexandre
calexandre / merge-zsh-history.sh
Last active May 9, 2024 15:56
Merge two zsh history files
#!/bin/bash
# Inspired on https://david-kerwick.github.io/2017-01-04-combining-zsh-history-files/
set -e
history1=$1
history2=$2
merged=$3
echo "Merging history files: $history1 + $history2"
test ! -f $history1 && echo "File $history1 not found" && exit 1
@posilva
posilva / disable.sh
Last active November 21, 2023 18:15
Remove/Disable Ubuntu SystemD Daily.Timers
# References:
#
# https://cinhtau.net/2016/12/09/disable-apt-auto-update-and-upgrade/
# https://unix.stackexchange.com/questions/315502/how-to-disable-apt-daily-service-on-ubuntu-cloud-vm-image
# https://askubuntu.com/questions/824718/ubuntu-16-04-unattended-upgrades-runs-at-random-times/831206
apt-get -y purge update-notifier-common ubuntu-release-upgrader-core landscape-common unattended-upgrades
systemctl kill --kill-who=all apt-daily.service
systemctl kill --kill-who=all apt-daily-upgrade.service
@posilva
posilva / build.sh
Last active September 27, 2018 13:18
Helper script to test cloudformation scripts
#!/usr/bin/env bash
# Helper commands for clouformation deploy in the EC2 instances
# curl http://169.254.169.254/latest/user-data
# cat /var/log/cloud-init-output.log
# sudo yum install htop tmux tcpdump telnet -y
# describe stack
# this parameters are not passed by command line parameters
# to ensure that the developer does not hit a different STACK NAME or template by mistake
Originally from: http://erlang.org/pipermail/erlang-questions/2017-August/093170.html
For a safe and fast Erlang SSL server, there's a few
configuration values you might want by default:
[{ciphers, CipherList}, % see below
{honor_cipher_order, true}, % pick the server-defined order of ciphers
{secure_renegotiate, true}, % prevent renegotiation hijacks
{client_renegotiation, false}, % prevent clients DoSing w/ renegs
{versions, ['tlsv1.2', 'tlsv1.1']}, % add tlsv1 if you must
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active May 24, 2024 03:56
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@ipbastola
ipbastola / jq to filter by value.md
Last active April 25, 2024 17:14
JQ to filter JSON by value

JQ to filter JSON by value

Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'

Example: To get json record having _id equal 611

cat my.json | jq -c '.[] | select( ._id | contains(611))'

Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

@lrascao
lrascao / gist:f57312ff33b799c4c0db56b10e80fe26
Created March 31, 2016 16:19
Export/Import datadog dashboards
dash_id=xxxx
api_key=xxx
app_key=xxx
# 1. export
curl -X GET "https://app.datadoghq.com/api/v1/dash/${dash_id}?api_key=${api_key}&application_key=${app_key}" > dash.json
# 2. edit dash.json
move "graphs", "title", "description" up one level in the json hierarchy, from being beneath "dash" to being at the same level
@dtheodor
dtheodor / listen_sqla.py
Last active August 7, 2023 11:38
Listen for pg_notify with SQL Alchemy + Psycopg2
import select
import datetime
import psycopg2
import psycopg2.extensions
from sqlalchemy import create_engine, text
engine = create_engine("postgresql+psycopg2://vagrant@/postgres")