Skip to content

Instantly share code, notes, and snippets.

View g-andrade's full-sized avatar

Guilherme Andrade g-andrade

  • Dash Games
  • Lisbon, Portugal
  • 16:12 (UTC +01:00)
View GitHub Profile
@indygreg
indygreg / find_old_lines.pl
Created June 17, 2012 20:17
Find oldest lines in git repository
#!/usr/bin/perl
# This script parses Git blame's "porcelain" output format and
# ascertains the oldest lines of code seen.
#
# If you want to perform a custom report, just define your own callback
# function and invoke parse_porcelain() with it.
#
# The expected input format is slightly modified from raw `git blame
# -p`. Here is an example script for producing input:
@MercuryRising
MercuryRising / gravitytrain.py
Created August 28, 2013 21:19
Hypocycloid Gravity Train
# -*- coding: utf-8 -*-
from math import *
import wolframalpha
client = wolframalpha.Client("YHQ3GK-PT45KT9AHG")
radius = 6367500
circumference = 2*pi*radius
gravitational_constant = 9.8 # m/s2
@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")
@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
@ipbastola
ipbastola / jq to filter by value.md
Last active June 5, 2024 09:07
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)

@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active June 14, 2024 05:57
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
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
@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
@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
@calexandre
calexandre / merge-zsh-history.sh
Last active May 31, 2024 06:33
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