Skip to content

Instantly share code, notes, and snippets.

View giuliano-macedo's full-sized avatar

Giuliano Macedo giuliano-macedo

  • Brazil
View GitHub Profile
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Clubbi code challenge',
debugShowCheckedModeBanner: false,
@giuliano-macedo
giuliano-macedo / with_sized_box_between.dart
Created December 18, 2022 15:18
A dart extension on a list of flutter widgets so that it can add padding between each one.
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
extension WidgetListSpacing on List<Widget> {
List<Widget> withSizedBoxBetween({double? width, double? height}) {
final box = SizedBox(width: width, height: height);
return mapIndexed((index, widget) => index == 0 || index == length ? [widget] : [box, widget]).flattened.toList();
}
}
T = TypeVar("T")
class MyProtocol(Protocol[T]):
def my_method(self, first_param: int, args: T) -> int:
...
@dataclass
class Imp1Args:
x: float
y: float
class Imp1(MyProtocol[Imp1Args]):
@giuliano-macedo
giuliano-macedo / interesting.md
Last active November 7, 2023 14:50
Interesting python stuff

Interesting python stuff i found messing around with it

1 hash function is random for non non-primitive objects, and it's seed is reset each time the interpreter is ran

Example: python -c "print(hash('hello world'))" generates random numbers, while python -c "print(hash(4.2))" always returns a constant value

2 list.extend method updates itself each time the iterator is called

This code will run forever ( and eat all your RAM ):

@giuliano-macedo
giuliano-macedo / compile_drop_table.py
Last active February 16, 2023 14:39
sqlalchemy createtable with cascade (with type hints), original answer: https://stackoverflow.com/a/38679457/5133524
from sqlalchemy.schema import DropTable
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.dialects.postgresql.base import PGDDLCompiler
from typing import Any
@compiles(DropTable, "postgresql")
def _compile_drop_table(element: DropTable, compiler: PGDDLCompiler, **kwargs: Any) -> str:
return compiler.visit_drop_table(element) + " CASCADE"
@giuliano-macedo
giuliano-macedo / reverse-jhs.md
Last active July 15, 2024 16:23
More comprehensive reverse JHS formula for Transverse Mercator projection

JHS Reverse formula

More comprehensive reverse JHS formula for computing latitude,longitude given northing, easting of a projection.

reference: Geomatics guidance Note number 7 part 2 - 3.5.3.1

(EPSG Dataset coordinate operation method code 9807)

Constants