Skip to content

Instantly share code, notes, and snippets.

View marcossevilla's full-sized avatar
🦄

Marcos Sevilla marcossevilla

🦄
View GitHub Profile
@marcossevilla
marcossevilla / isNum.dart
Last active February 4, 2023 12:39
Check if text input value is number
bool isNumber(String value) {
if (value.isEmpty) return false;
final numb = num.tryParse(value);
return numb == null ? false : true;
}
@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
@marcossevilla
marcossevilla / dart.json
Last active February 1, 2021 23:55
My Dart Custom Snippets for VSCode
{
"Flutter Screen": {
"prefix": "fl-page",
"body": [
"import 'package:flutter/material.dart';",
"",
"/// TODO: Finish the docs",
"/// ${1:name}Page to...",
"class ${1:name}Page extends StatelessWidget {",
"",
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');
}
Image imageFile = Image.asset('assets/img/my_image.png');
# 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
Text(
'Esto es usando las fuentes con FlutterGen',
style: TextStyle(fontFamily: FontFamily.googleSans),
);
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');
Assets.images.background.image();