Skip to content

Instantly share code, notes, and snippets.

View unix14's full-sized avatar
๐Ÿ‘‹
Hi there

Eyal Yaakobi unix14

๐Ÿ‘‹
Hi there
View GitHub Profile
@unix14
unix14 / smart_image_loader.dart
Created October 7, 2024 09:49
A Flutter widget that intelligently loads network images and SVGs with support for customization (width, height, fit, alignment) and error handling. Depends on flutter_svg lib
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:path/path.dart' as Path;
class SmartImageLoader extends StatefulWidget {
final String imageUrl;
// add others image params like width height fit , alignment, errorBuilder
final double? width;
final double? height;
@unix14
unix14 / file_cache.dart
Created January 2, 2024 21:48
FileCache lib
import 'dart:io';
import 'dart:convert';
class FileCache {
// The directory where the cache files are stored
final Directory cacheDir;
// The constructor that takes the cache directory as a parameter
FileCache(this.cacheDir);
@unix14
unix14 / date_extensions.dart
Created December 10, 2023 01:22
simpler date formatter - human readable date
import 'package:intl/intl.dart';
String getFormattedDate(_date) {
var inputFormat = DateFormat('yyyy-MM-dd HH:mm');
var inputDate = inputFormat.parse(_date);
var outputFormat = DateFormat('dd/MM/yyyy HH:mm');
// Calculate time difference
final timeDifference = DateTime.now().difference(inputDate);
@unix14
unix14 / BagTripsCalculator.java
Created November 29, 2023 17:45
Small bags per trips calculator algorithm
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Random;
public class BagTripsCalculator {
// Default const values 1.01-3.0Kg
static final float MINIMUM_WEIGHT = 1.01f;
static final float MAXIMUM_WEIGHT = 3f;