Skip to content

Instantly share code, notes, and snippets.

View tiagofernandez's full-sized avatar
☠️

Tiago Fernandez tiagofernandez

☠️
View GitHub Profile
{
"1st-feature-flag": {
"createdAt": 1639043672950,
"createdBy": "system@acme.org",
"description": "First feature flag",
"id": "1st-feature-flag",
"ignoreUpdates": false,
"lastUpdatedAt": 1639043672950,
"lastUpdatedBy": "system@acme.org",
"publicFlag": false,
@tiagofernandez
tiagofernandez / list-types-of-materialized-view.sql
Last active June 14, 2019 06:13
PostgreSQL query to list types given a materialized view.
SELECT a.attname,
pg_catalog.format_type(a.atttypid, a.atttypmod),
a.attnotnull
FROM pg_attribute a
JOIN pg_class t on a.attrelid = t.oid
JOIN pg_namespace s on t.relnamespace = s.oid
WHERE a.attnum > 0
AND NOT a.attisdropped
AND t.relname = 'my_view'
AND s.nspname = 'my_schema'
@tiagofernandez
tiagofernandez / ddos_attackers.sh
Last active May 30, 2022 19:22
Attempts to block DDoS attacks.
#! /bin/bash
SEARCHED=$1
if [ -z $SEARCHED ]; then
SEARCHED=/api/flights/fares
fi
echo "Protecting $SEARCHED"
echo "Reading:"
@tiagofernandez
tiagofernandez / whatsapp_chat_ranking.py
Last active October 8, 2015 10:57
Counts the number of message each participant has sent and generates a ranking.
# Counts the number of message each participant has sent and generates a ranking.
# Author: Tiago Fernandez
import operator, os
def main():
input_data = os.path.basename(__file__).replace('.py', '.txt')
output_data = count_messages(input_data)
generate_report(output_data)
@tiagofernandez
tiagofernandez / nsspain-2014-swift-workshop.swift
Last active August 29, 2015 14:06
Swift workshop in NSSpain 2014.
// https://bitbucket.org/agbo/swiftworkshop/src
// https://bytebucket.org/agbo/swiftworkshop/raw/d69842f1bb8de5d6addf00c7936e8fda6382ec3a/IntroToSwiftNSSpain.pdf
import UIKit
(2)
/////////////////////////////////
// Basic Building blocks
//
@tiagofernandez
tiagofernandez / google-maps-route-mapping.html
Created June 2, 2014 08:28
Display routes to several destinations from the same origin in Google Maps.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map-canvas { height: 100% }
.labels {
@tiagofernandez
tiagofernandez / _training.py
Created January 22, 2014 21:43
Python advanced training by Logilab.
import sys, re, time
import unittest
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from datetime import datetime
from itertools import izip
from multiprocessing.pool import ThreadPool
from threading import Thread
from urlparse import parse_qs
@tiagofernandez
tiagofernandez / single_round_robin_schedule.rb
Created December 7, 2013 17:08
Generate a single round-robin schedule for an even number of teams.
#!/usr/bin/env ruby
# http://stackoverflow.com/a/1916548/75265
def schedule(teams=[])
# odd_size = teams.size % 2 != 0
# teams << -1 if odd_size
rounds = (1...teams.size).map do |r|
t = teams.dup
(0...(teams.size / 2)).map do |_|
[t.shift, t.delete_at(-(r % t.size + (r >= t.size * 2 ? 1 : 0)))]
@tiagofernandez
tiagofernandez / ish-bookmarklet.js
Last active April 9, 2016 21:02 — forked from mremco/ish-bookmarklet.js
Bookmarklet that opens the current page into Brad Frost's ish viewport resizing tool (http://bradfrostweb.com/demo/ish/).
javascript:(function(){window.open('http://bradfrostweb.com/demo/ish/?url='+encodeURIComponent(document.URL));})();
@tiagofernandez
tiagofernandez / toggle_hidden_files_in_finder.scpt
Last active December 26, 2015 15:19
Toggle hidden files in Finder.
try
set dotVisible to do shell script "defaults read com.apple.finder AppleShowAllFiles"
on error errorMessage number errorNumber
set dotVisible to 0
end try
if dotVisible = "0" then
do shell script "defaults write com.apple.finder AppleShowAllFiles 1"
else
do shell script "defaults write com.apple.finder AppleShowAllFiles 0"