Skip to content

Instantly share code, notes, and snippets.

View PedroEscudero's full-sized avatar

Pedro Escudero PedroEscudero

  • Delivery Hero
  • Berlin
View GitHub Profile
@PedroEscudero
PedroEscudero / author.json
Last active March 16, 2020 14:15
Author in a different document set (Medium article)
{
"id": "r?dskhuD9ewgvweosdJIe2s8u34br",
"name": "Pedro",
"surname": "Escudero",
"birth_year": "1976",
"nationality": "Spanish",
"alive": 1
}
@PedroEscudero
PedroEscudero / mongo-author-inside.json
Last active March 16, 2020 14:02
mongo book data set with author inside (Medium article)
{
"title": "Zombi Kidergarten",
"isbn": "11121m21232323232",
"publish:_date": "23-07-2012",
"author": {
"name": "Pedro",
"surname": "Escudero",
"birth_year": "1976",
"nationality": "Spanish",
"alive": 1
def fibonacci(n)
return n if ( 0..1 ).include? n
(fibonacci(n - 1) + fibonacci( n - 2 ))
end
start = Time.now
fibonacci(22)
p Time.now - start
import time
def Fibonacci(n):
if n<2:
return 1
else:
return Fibonacci(n-1)+Fibonacci(n-2)
start = time.time()
Fibonacci(22)
print(time.time() - start)
<?php
function fibonacci($n){
$start = microtime(true);
if ($n < 2){
$f = 1;
}else{
$f = fibonacci($n - 2) + fibonacci($n - 1);
}
return microtime(true) - $start;
}
@PedroEscudero
PedroEscudero / bubble.php
Last active January 29, 2022 06:52
Bubble script for testing speed of PHP-8
<?php
function bubble_sort($array)
{
$start = microtime(true);
do
{
$sw = false;
for($i = 0, $size = count($array) - 1; $i < $size; $i++)
{
if( $array[$i] > $array[$i + 1] )