Skip to content

Instantly share code, notes, and snippets.

なまえ:フィリップ レネー
ドイツでいちばんきれいな町:ハイデルベルク
 みなさん、こんにちは。
これから、私の町についてはなします。
 私の町はハイデルベルクです。
ゆうめいで、とてもふるいですから、たくさんの人がここにきます。
それから、人はハイデルベルクじょうをみます。
from typing import List
class Solution:
def bruteforce_distances(self, arr: List[int]) -> List[int]:
distances = [0]*len(arr)
for i, a in enumerate(arr):
distance = 0
for a_ in arr:
distance += abs(a - a_)
import numpy as np
import torch
"""
w* = \argmin_{w\in R^L} \delta_\Delta(w) + \frac12 (w-v)^T H (w-v)
where H is diagonal (represented as array)
"""
def scaled_proj(v, H):
N, L = v.size()
Hv = H * v
@filipre
filipre / simulation.py
Created July 20, 2018 07:42
Video Poker Simulation
from pcards import Deck, Card
from itertools import chain, combinations
from joblib import Parallel, delayed
import multiprocessing
from statistics import mean
# https://docs.python.org/2.7/library/itertools.html#recipes
def powerset(iterable):
"powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
s = list(iterable)
DOPE RAP
Retrogott - esmusssosein (“it’s necessary”) https://www.youtube.com/watch?v=rVEcnfS0Dx4
JAW - Arztbesuch (Doctor Appointment) https://www.youtube.com/watch?v=KEJDy2U7h90
Kram aus der Ecke - ID https://youtu.be/J5jpR5QGYlk?t=31m
Mase - Der Spliffmeister https://www.youtube.com/watch?v=AVa9aQqLCcs
Advanced Chemistry - Fremd im eigenen Land (from my home town Heidelberg, first commercial german rap track) https://www.youtube.com/watch?v=iL6tzhvF8_c
Stieber Twins (also really old) https://www.youtube.com/watch?v=o6jcwo1dOD0
Aohroe - Ruhrpott State of Mind (if you know NAS - NY State of mind its VERY nice, he copied 100% the flow) https://www.youtube.com/watch?v=xgP8N_HfXAc
Scarf Face - Broke aber High https://www.youtube.com/watch?v=r8d7_Il-7Do
2zg - 8 kurze: https://www.youtube.com/watch?v=lozZ7p--2dI
-- Running sum partitioned by customer and month with some formatting
with months(n, name) as (
values (1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'October'), (11, 'November'), (12, 'December')
)
select c_name, (select name from months where n = extract(month from o_orderdate)) as month, o_orderdate, sum(o_totalprice) over (
partition by o_custkey, extract(month from o_orderdate)
order by o_orderdate
) / 1000000.0 || ' Mio'
from orders, customer
where customer.c_custkey = orders.o_custkey
/*
-- Correlated Query
select sum(l_extendedprice) / 7.0 as avg_yearly
from lineitem, part
where p_partkey = l_partkey
and p_brand = 'Brand#23'
and p_container = 'MED BOX'
and l_quantity < (
select 0.2 * avg(l_quantity) from lineitem where l_partkey = p_partkey
)
with recursive numbers(n) as (
select n
from generate_series(1,5000) s(n)
),
prim(n, step) as (
select numbers.n, 2
from numbers
union
select prim.n, prim.step + 1
from prim
with recursive
-- all friends into one direction
friends (a, b) as (
values('Alice','Bob'), ('Alice','Carol'), ('Carol','Grace'),
('Carol','Chuck'), ('Chuck','Grace'),('Chuck','Anne'),
('Bob','Dan'),('Dan','Anne'),('Eve','Adam')
),
-- all friendships into both directions
friendship (name, friend) as (
select a, b
@filipre
filipre / query.sql
Created February 2, 2017 19:38
Decorrelated Query
/*
select count(o_orderkey)
from orders o1
where o_totalprice < (
select avg(o_totalprice) from orders o2 where o2.o_shippriority = o1.o_shippriority or o2.o_orderstatus = o1.o_orderstatus
)
Result: 788047
*/