Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Loukissas aloukissas

View GitHub Profile
View gist:50647225541178cf664f44c1cfcbfbbd
Line # Hits Time Per Hit % Time Line Contents
==============================================================
[...]
51 7750 1967208.0 253.8 90.8 cor = np.corrcoef(data1, data2)
View js_static_fn_variable.js
function maybeShowAlert(event) {
event.preventDefault();
if (maybeShowAlert.shown === undefined) {
alert("Hello!");
maybeShowAlert.shown = true;
}
}
document.addEventListener("mouseout", maybeShowAlert, false);
View simple_mult_int.py
Python 3.7.6 (default, Jan 2 2020, 08:35:56)
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 165 * 1940
320100
View dime_loop.py
Python 3.7.6 (default, Jan 2 2020, 08:35:56)
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 0
>>> for x in range (0, 10000):
... a += 0.1
...
>>> a
1000.0000000001588
View simple_mult.py
Python 3.7.6 (default, Jan 2 2020, 08:35:56)
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 165 * 19.40
3200.9999999999995
View simple_addition.py
Python 3.7.6 (default, Jan 2 2020, 08:35:56)
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.1 + 0.2
0.30000000000000004
View simple_addition.py
Python 3.7.6 (default, Jan 2 2020, 08:35:56)
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.1 + 0.2
0.30000000000000004
View create_subscription_with_v2.ex
def create_subscription(email, plan_id, payment_method_id) do
with {:user_lookup, %User{customer_id: nil, name: name} = user} <-
{:user_lookup, Repo.get_by(User, email: email)},
{:customer_creation, {:ok, %Stripe.Customer{id: customer_id}}} <-
{:customer_creation,
Stripe.Customer.create(%{
name: name,
email: email,
payment_method: payment_method_id,
invoice_settings: %{
View create_subscription_with.ex
def create_subscription(email, plan_id, payment_method_id) do
with %User{customer_id: nil, name: name} = user <-
Repo.get_by(User, email: email),
{:ok, %Stripe.Customer{id: customer_id}} <-
Stripe.Customer.create(%{
name: name,
email: email,
payment_method: payment_method_id,
invoice_settings: %{
default_payment_method: payment_method_id
View create_subscription_nested.ex
def create_subscription(email, plan_id, payment_method_id) do
case Repo.get_by(User, email: email) do
%User{customer_id: nil, name: name} = user ->
params = %{
name: name,
email: email,
payment_method: payment_method_id,
invoice_settings: %{
default_payment_method: payment_method_id
}