Skip to content

Instantly share code, notes, and snippets.

View ruan65's full-sized avatar
🎯
Focusing

Andrew ruan65

🎯
Focusing
View GitHub Profile
@ruan65
ruan65 / curl.md
Created March 30, 2024 19:20 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@ruan65
ruan65 / transparent_rounded_rectangle.dart
Created November 19, 2023 20:04
Custom painer with hole inside
import 'package:flutter/material.dart';
class TransparentRoundedRectangle extends StatelessWidget {
const TransparentRoundedRectangle({super.key});
@override
Widget build(BuildContext context) {
return CustomPaint(
painter: CandlePainter(),
);
@ruan65
ruan65 / max_min_integer.dart
Created November 6, 2023 12:06
Dart max min integer
int maxInteger = double.maxFinite.toInt();
const maxInteger2 = -1 >>> 1; // 1111 ... 1111 >>> 0111 ... 1111
print(maxInteger);
print(maxInteger2);
print(-maxInteger);
print(-maxInteger2);
{
"Flutter App Example Scaffold": {
"scope": "dart",
"prefix": "fsapp",
"body": [
"import 'package:flutter/material.dart';",
"",
"void main() {",
" runApp(MaterialApp(",
"title: 'Flutter Demo',",
extension CompactMap<T> on Iterable<T?> {
Iterable<T> compactMap<E>([E? Function(T?)? transform]) =>
map(transform ?? (e) => e).where((e) => e != null).cast();
}
extension Normalize on num {
num normalized(
num selfRangeMin,
num selfRangeMax, [
num normalizedRangeMin = 0.0,
num normalizedRangeMax = 1.0,
]) =>
(normalizedRangeMax - normalizedRangeMin) *
((this - selfRangeMin) / (selfRangeMax - selfRangeMin)) +
normalizedRangeMin;
void main() async {
Future.delayed(Duration(milliseconds: 500)).then((_) {
print('hi');
});
print('hello');
await Future.delayed(Duration(milliseconds: 1000));
print('hi');
@ruan65
ruan65 / form_utils.dart
Created October 4, 2021 16:18 — forked from roipeker/form_utils.dart
TextField concept for GetX (WIP) ...
/// copyright 2020, roipeker
class FormValidations {
static String email(String val) {
val = val.trim();
if (val.isEmpty) return 'Email cant be empty';
if (val.length <= 4) return 'Email is too short';
if (!val.isEmail) return 'Invalid email';
return null;
}
import 'dart:io';
import 'package:grpc/grpc.dart';
import 'generated/umka.pbgrpc.dart';
class UmkaTerminalClient {
late final ClientChannel channel;
late final UmkaClient stub;
import 'dart:math';
import 'package:grpc/src/server/call.dart';
import 'package:grpc/grpc.dart' as grpc;
import 'package:umka/questions_db_driver.dart';
import 'generated/umka.pbgrpc.dart';
class UmkaService extends UmkaServiceBase {