This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Verifying that +alizee is my Bitcoin username. You can send me #bitcoin here: https://onename.io/alizee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Helper functions that allow string arguments for dplyr's data modification functions like arrange, select etc. | |
# Author: Sebastian Kranz | |
# Examples are below | |
#' Modified version of dplyr's filter that uses string arguments | |
#' @export | |
s_filter = function(.data, ...) { | |
eval.string.dplyr(.data,"filter", ...) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## claim_queries.R | |
# Quick R-script to test the claim API built by | |
# Andrew. | |
# Setup ------------------------------------------------------------------- | |
# Library | |
library(httr) | |
# Constants |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Fuction that computes the devaluation factor depending on the | |
# time interval, based on the target yearly ratio. | |
decrease <- function(days, yrRatio = 0.5) { | |
exp(days/365.25 * log(yrRatio)) | |
} | |
# Test & plot | |
x <- 0:800; | |
plot(x, decrease(x), type = "l", yaxp = c(0.25, 1, 3), #xaxp = c(0, 365.25*2, 6), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import io | |
import tarfile | |
import urllib.request | |
import re | |
ARCHIVE_URL = 'http://d.pr/f/YqS5+' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from werkzeug.routing import Rule as BaseRule | |
class Rule(BaseRule): | |
except_hosts = [] | |
def match(self, path): | |
""" Monkey patched version of the default Werkzeug behavior to achieve host matching with catchall. | |
By default, if host matching is enabled, the match is only done if the host is always provided, which is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gmail.com | |
yahoo.com | |
hotmail.com | |
aol.com | |
hotmail.co.uk | |
hotmail.fr | |
msn.com | |
yahoo.fr | |
wanadoo.fr | |
orange.fr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Show the distribution of customers per number of orders in 2020: | |
WITH n_orders_by_customer AS ( | |
SELECT customer_id, count(*) AS n_orders | |
FROM orders | |
WHERE paid_date > '2020-01-01' | |
GROUP BY 1 | |
) | |
SELECT n_orders, count(*) AS n_customers | |
FROM n_orders_by_customer | |
GROUP BY 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Show the number of paid and delivered orders per country: | |
WITH orders_from_france AS ( | |
SELECT paid_date, delivered_date | |
FROM orders | |
WHERE geo_country(lat, lon) = 'France' | |
) | |
, orders_by_paid_date AS ( | |
SELECT paid_date AS date_, count(*) AS n_paid_orders | |
FROM orders_from_france | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Show the distribution of orders from senior customers per month: | |
WITH senior_customers AS ( -- [This would not be a pb if PG 12+] | |
SELECT * | |
FROM remote.customers | |
WHERE age > 60 | |
) | |
SELECT date_trunc(paid_date) AS order_month, count(*) AS n_orders | |
FROM remote.orders o -- brings back to the local server ALL the orders | |
JOIN senior_customers c ON c.id = o.customer_id -- do a JOIN without the indices from the remote |
OlderNewer