Skip to content

Instantly share code, notes, and snippets.

@daninfpj
daninfpj / upgrade.sh
Created April 17, 2024 16:25
Metabase Elastic Beanstalk upgrade
#!/bin/bash
# Usage:
# ./upgrade.sh $image_tag [$aws_profile]
# ./upgrade.sh 0.49.3 profile
export AWS_PAGER=""
image_tag=$1
aws_profile=${2:-'default'}
@daninfpj
daninfpj / result.py
Created March 23, 2023 23:00
Rust’s Result type in Python
from typing import TypeVar, Tuple, Generic
T = TypeVar('T')
E = TypeVar('E')
class Result(Generic[T, E]):
def __init__(self, value: T=None, error: E=None):
self.value = value
self.error = error
@daninfpj
daninfpj / dependabot open PRs.txt
Created July 28, 2022 23:17
dependabot open PRs
is:pr is:open author:app/dependabot org:***
@daninfpj
daninfpj / setup.md
Created July 14, 2022 22:24
pyenv setup
pyenv virtualenv 3.7.7 contacts-service
pyenv local contacts-service 3.7.7
pipenv sync -d
@daninfpj
daninfpj / main.dart
Created December 3, 2020 16:46
Enum extension
enum TransferStatus {
created,
authorizing,
sending,
verifying,
pending,
refunded,
success,
error,
}
@daninfpj
daninfpj / theme.dart
Last active February 21, 2020 23:09
Flutter Themes
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@daninfpj
daninfpj / json_decoder.py
Created December 10, 2019 14:12
Python JSON Decoder
import json
from decimal import Decimal
class A:
def __init__(self, value):
self.bar = Decimal(value)
def to_dict(self):
return {
@daninfpj
daninfpj / print.py
Last active November 29, 2019 00:12
SQLAlchemy print query
from sqlalchemy.dialects import postgresql
print(statement.compile(dialect=postgresql.dialect()))
from sqlalchemy.engine.default import DefaultDialect
from sqlalchemy.sql.sqltypes import String, DateTime, NullType
# python2/3 compatible.
PY3 = str is not bytes
text = str if PY3 else unicode
int_type = int if PY3 else (int, long)
@daninfpj
daninfpj / print.py
Created November 29, 2019 00:03
SQLAlchemy print query
from sqlalchemy.dialects import postgresql
print(statement.compile(dialect=postgresql.dialect()))
@daninfpj
daninfpj / movement.dart
Created June 28, 2019 19:10
Polymorphism
class Movement {
String get status => 'COMPLETED';
bool get isForeignCurrency => false;
}
class Deposit extends Movement {}
class Charge extends Movement {
String status;