Skip to content

Instantly share code, notes, and snippets.

View epatel's full-sized avatar

Edward Patel epatel

View GitHub Profile
@epatel
epatel / main.dart
Last active March 28, 2024 11:24
ListView.builder with delayed loading
import 'package:flutter/material.dart';
import 'dart:math' as math;
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@epatel
epatel / main.dart
Created March 23, 2024 01:07
Local var life
Future<void> repeat(void Function() repeat) async {
while (true) {
await Future.delayed(Duration(seconds: 1));
repeat();
}
}
void test() {
int a = 7;
repeat(() {
@epatel
epatel / main.dart
Created March 22, 2024 16:13
map object
class Test {
Map<String, String> data = {};
Test();
String toString() {
return '$data';
}
}
@epatel
epatel / main.dart
Created March 22, 2024 15:49
Null after future
class Test {
final String text;
Test({
required this.text,
});
Future<void> hello() async {
await Future.delayed(Duration(seconds: 2));
print(text);
import 'dart:math';
import 'package:flutter/material.dart';
void main() => runApp(const AnimatedContainerExampleApp());
class AnimatedContainerExampleApp extends StatelessWidget {
const AnimatedContainerExampleApp({super.key});
@override
Widget build(BuildContext context) {
@epatel
epatel / main.dart
Last active January 10, 2024 09:56
Sync Scroll
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@epatel
epatel / main.dart
Last active September 8, 2023 08:58
AnimatedGradient - Flutter
import 'package:flutter/material.dart';
// https://dartpad.dev/6ff26f35a86f70855a10ef3a83cb721a
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@epatel
epatel / templater
Last active September 8, 2023 08:53
Create template script
#!/bin/bash
#
# Create a template script.
#
# Add files containing "{Name}" to a script that will extract and change "{Name}" to something else
#
# Example:
#
#. NAME=mbench
@epatel
epatel / box.sh
Last active July 14, 2023 11:36
Output box around text bash
#!/bin/bash
function box() {
LEN=`expr "$1" : '.*'`
LINE=`printf "%${LEN}s" | tr " " "━"`
printf "┏━%s━┓\n" "$LINE"
printf "┃ %s ┃\n" "$1"
printf "┗━%s━┛\n" "$LINE"
}
/* Offset gcode tool (with speed change)
* -------------------------------------
*
* Compile: 'cc -o offset-gcode offset-gcode.c'
*
* Use: 'offset-gcode -x 12.0 -y 12.0 -f 1.2 file.gcode > newfile.gcode'
*
*/
#include <unistd.h>