Skip to content

Instantly share code, notes, and snippets.

View gcorreaq's full-sized avatar

Gonzalo Correa-Young gcorreaq

View GitHub Profile
@gcorreaq
gcorreaq / index.js
Last active December 17, 2020 07:58
Filter flavor text for the Poke API
fetch("https://pokeapi.co/api/v2/pokemon-species/2").then((result) => {
result.json().then((data) => {
// We filter the array of flavor texts only for the ones that have the language `en`
const fileterdFlavorTextEntries = data.flavor_text_entries.filter(
(element) => element.language.name === "en"
);
// If there's any entries, let's get the first one
const flavorTextEntry = fileterdFlavorTextEntries.length > 0 ? fileterdFlavorTextEntries[0] : {};
console.log(flavorTextEntry);

iOS: Setup PagerDuty numbers so you always get the calls/SMS

iOS doesn't have granular control over notifications as Android does. This is specially frustrating while being on call: how can I get only notified about pages but silence everything else? Well, the solution is a bit simple! Enter Emergency Bypass for contacts: a feature added in iOS 10 (I think?) that will let calls and SMS from specific contacts to always ring, even if the phone is in Do Not Disturb mode.

Setup

  1. From your phone, download the vCard with all the possible numbers that PagerDuty can use to contact you (even in other countries!). If the above link doesn't work, try here
  2. Select Open in "Contacts" and add the new contact.
  3. Edit the contact, and go to Ring Tone. Touch it and it will display a ton of other options.

Keybase proof

I hereby claim:

  • I am gcorreaq on github.
  • I am gonchi (https://keybase.io/gonchi) on keybase.
  • I have a public key ASB0uBsHis2WxSVBiiZPx19gcPxZQeAzrN_do4ZZQ2bt2go

To claim this, I am signing this object:

In [1]: a = {'asd': 1, 'qwe': 2},
In [2]: b = [{'asd': 3, 'qwe': 4}]
In [3]: b.append(a)
In [4]: b
Out[4]: [{'asd': 3, 'qwe': 4}, ({'asd': 1, 'qwe': 2},)]
In [5]: type(b[1])
Out[5]: tuple
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
@gcorreaq
gcorreaq / keybase.md
Created August 23, 2014 02:42
keybase.md

Keybase proof

I hereby claim:

  • I am gcorreaq on github.
  • I am gonchi (https://keybase.io/gonchi) on keybase.
  • I have a public key whose fingerprint is 22B7 AE08 C784 5565 4489 C4B6 F964 64B3 0694 2FA3

To claim this, I am signing this object:

#!/usr/bin/env python
#
# Copyright 2012 by Jeff Laughlin Consulting LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
import numpy
def squares(matrix, square_size):
paint = False
for row in xrange(len(matrix)):
# Only in the borders of the square, we change the switch to paint
if row % square_size == 0:
paint = not paint
@gcorreaq
gcorreaq / encontrar_primos.py
Last active December 28, 2015 09:29
Pequeña función para encontrar números primos en un intervalo dado, incluyendo ambos extremos.
def verifica_primo(menor, mayor):
# Guardaremos los numeros primos en una lista
primos = []
for termino in xrange(menor, mayor + 1):
divisores = 0
# Aca hay un truco: si el termino es divisible por cualquier numero
# entre 2 y el (termino - 1), entonces no es primo porque tiene mas de
# un divisor (aparte de 1 y de si mismo)
@gcorreaq
gcorreaq / track_progress.py
Created July 11, 2013 22:38
Track the progress of a list of AsyncResult objects
def track_progress(async_results, logger=None, polling_time=30):
total_tasks = remaining_tasks = len(async_results)
# We need to iterate until all the tasks are done
while async_results and remaining_tasks:
ping = time.time()
# It's cheaper to add the running tasks in a new list
# instead of removing them from a copy of the original list