Skip to content

Instantly share code, notes, and snippets.

View marcossevilla's full-sized avatar
🦄

Marcos Sevilla marcossevilla

🦄
View GitHub Profile
@marcossevilla
marcossevilla / silly_game.py
Created October 22, 2019 15:14
A silly World War game, randomized and written in Python
from random import randrange
parts = {
"USA": randrange(1, 100),
"Germany": randrange(1, 100),
"Russia": randrange(1, 100)
}
keys = list(parts.keys())
values = list(parts.values())
@marcossevilla
marcossevilla / karatsuba.py
Last active October 26, 2020 15:32
Karatsuba Multiplication with Bitwise operators for memory efficiency
def karatsuba(x, y):
if x < 16 or y < 16:
return x * y
max_len = max(x.bit_length(), y.bit_length()) // 2
bitwise_filter = (1 << max_len) - 1
a, b = x >> max_len, x & bitwise_filter
c, d = y >> max_len, y & bitwise_filter
Image imageFile = Image.asset('assets/img/my_image.png');
Future callToAPI() async {
await http.get('url_to_my_api.dev/api');
}
Future anotherCallToAPI() async {
await http.get('url_to_my_api.dev/api/another');
}
class API {
static const url = 'url_to_my_api.dev/api';
}
Future callToAPI() async {
await http.get(API.url);
}
Future anotherCallToAPI() async {
await http.get('${API.url}/other');
# aquí toda la configuración de flutter_gen
# ojo con las indentaciones
flutter_gen:
# por defecto, los archivos generados van en `lib/gen/`
# se puede sobreescribir con `lib/src/gen` usando [output]
output: lib/src/gen/
# si utilizamos algún linter sensible a la cantidad de
# líneas de código, podemos complacerlo con [lineLength]
# que por defecto viene en 80
Assets.images.background.image();
Text(
'Esto es usando las fuentes con FlutterGen',
style: TextStyle(fontFamily: FontFamily.googleSans),
);
Container(height: 100, width: 100, color: ColorName.justBlack);
# * si usas Provider
provider: ^4.3.3
state_notifier: ^0.6.0
flutter_state_notifier: ^0.6.1
# * si usas Riverpod, ya integra state_notifier
flutter_riverpod: ^0.12.2
# usa las dependencias más recientes o
# las que sean compatibles con tu proyecto