Skip to content

Instantly share code, notes, and snippets.

View emiliodallatorre's full-sized avatar

Emilio Dalla Torre emiliodallatorre

View GitHub Profile
@emiliodallatorre
emiliodallatorre / find_route_without_context.dart
Created August 25, 2022 19:33
Find current route without context
// https://stackoverflow.com/questions/46483949/how-to-get-current-route-path-in-flutter
String? currentPath;
navigatorKey.currentState?.popUntil((Route<dynamic> route) {
currentPath = route.settings.name;
return true;
});
@emiliodallatorre
emiliodallatorre / default.conf
Last active June 7, 2022 19:00
Empty Nginx web server configuration
# server {
# listen 80;
# server_name yourhostname.it www.yourhostname.it;
# return 301 https://yourhostname.it$request_uri;
# }
server {
# listen 443 ssl; # managed by Certbot
# ssl_certificate /etc/letsencrypt/live/yourhostname.it/fullchain.pem; # managed by Certbot
# ssl_certificate_key /etc/letsencrypt/live/yourhostname.it/privkey.pem; # managed by Certbot
@emiliodallatorre
emiliodallatorre / lab_chrono.py
Created September 28, 2021 19:34
Un semplice script per un cronometro da laboratorio che tiene traccia delle misurazioni fatte.
from datetime import datetime
measures: list = []
while True:
print()
key: str = input(
"Premi un tasto qualsiasi per avviare il conteggio, \"r\" per fermare le misurazioni ")
if key == "r":
break
@emiliodallatorre
emiliodallatorre / index.php
Created August 13, 2021 17:24
Un file per testare la funzionalità di un'installazione di PHP + Nginx.
<?php
phpinfo();
@emiliodallatorre
emiliodallatorre / default.conf
Created August 13, 2021 17:15
La mia configurazione di default per Nginx, che uso nei server con funzionalità PHP.
# server {
# listen 80;
# server_name 127.0.0.1;
# return 301 https://127.0.0.1$request_uri;
# }
server {
listen 80;
# listen 443;
# ssl on;
@emiliodallatorre
emiliodallatorre / optimized_network_image.dart
Last active August 10, 2021 16:00
A simple wrapper for CachedNetworkImage that lets you specify caching parameters globally.
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:resmedia_manita_flutter/references.dart';
class OptimizedNetworkImage extends StatelessWidget {
final String imageUrl;
final Widget Function(BuildContext, String) placeholder;
final BoxFit fit;
@emiliodallatorre
emiliodallatorre / cleanser.py
Created May 27, 2021 10:57
Simple utility to put all <wp:author> tag child on the same line of a WordPress WXR/XML export
import os
def main():
export_file_names: list = [
f for f in os.listdir(".") if f.endswith(".xml") and not f.endswith(".correct.xml")]
for export_file_name in export_file_names:
print(f"Going with: {export_file_name}")
@emiliodallatorre
emiliodallatorre / sign_in_apple.dart
Created January 21, 2021 15:08
Funzione per il login con Apple
static Future<UserModel> signInWithApple() async {
final OAuthProvider appleOAuth = OAuthProvider("apple.com");
final AuthorizationCredentialAppleID appleCredential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
);
@emiliodallatorre
emiliodallatorre / http_uploader.dart
Created October 4, 2020 15:43
Funzione per caricare un file via http con Flutter.
import 'package:http/http.dart' as http;
class HttpUploader {
Future<void> uploadFile (File file, String nameOnPrinter) async {
String url = "http://192.168.1.125/upload?X-Filename=$nameOnPrinter.gcode";
Map<String, String> headers = {
"Content-Type": "application/octet-stream"
};
@emiliodallatorre
emiliodallatorre / flutter_clean_all.sh
Created June 20, 2020 09:10
Uno script per pulire recursivamente i progetti in Flutter nella cartella GitHub.
for f in $(ls -d */);
do
echo "Entro in $f."
cd "$f"
flutter clean
cd ..
done