This file contains hidden or 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
/** | |
* A TypeScript port of the Result type from Rust. | |
*/ | |
class Result<T, E = Error> { | |
private constructor(private readonly value: T, private readonly error?: E) {} | |
/** | |
* Create a new Result with a value. | |
* @param value | |
* @returns Result |
This file contains hidden or 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 sys | |
from timeit import timeit | |
import fibbers | |
RUNS = 100 | |
def fibonacci(n: int) -> int: | |
if n <= 1: |
This file contains hidden or 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
use pyo3::prelude::*; | |
/// Calculate the nth Fibonacci number. | |
#[pyfunction] | |
fn fib(n: u32) -> u32 { | |
if n <= 1 { | |
return n; | |
} | |
fib(n - 1) + fib(n - 2) | |
} |
This file contains hidden or 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
use pyo3::prelude::*; | |
/// Formats the sum of two numbers as string. | |
#[pyfunction] | |
fn sum_as_string(a: usize, b: usize) -> PyResult<String> { | |
Ok((a + b).to_string()) | |
} | |
/// A Python module implemented in Rust. | |
#[pymodule] |
This file contains hidden or 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 sys | |
from timeit import timeit | |
RUNS = 100 | |
def fibonacci(n: int) -> int: | |
if n <= 1: | |
return n | |
return fibonacci(n - 1) + fibonacci(n - 2) |
This file contains hidden or 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
package main | |
import ( | |
"encoding/csv" | |
"fmt" | |
"log" | |
"os" | |
"path/filepath" | |
"regexp" | |
"sort" |
This file contains hidden or 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 timeit | |
import faker | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
from cycler import cycler | |
from sqlalchemy import ( | |
Boolean, | |
Column, | |
ForeignKey, |
This file contains hidden or 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
/* Naive Python implementation */ | |
SELECT * | |
FROM orders | |
WHERE NOT payment_status | |
-- Loop over the results from previous query | |
-- and run this select each time | |
SELECT * | |
FROM users | |
WHERE id = '{{ user_id }}' |
This file contains hidden or 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 sqlalchemy.orm import Session | |
... | |
class User(Base): | |
... | |
class Order(Base): | |
... |
This file contains hidden or 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
services: | |
db: | |
image: mysql | |
environment: | |
MYSQL_ROOT_PASSWORD: password | |
MYSQL_DATABASE: default | |
MYSQL_USER: user | |
MYSQL_PASSWORD: password | |
ports: | |
- "3306:3306" |
NewerOlder