Skip to content

Instantly share code, notes, and snippets.

View alexcmgit's full-sized avatar

Alex Castro alexcmgit

View GitHub Profile
@alexcmgit
alexcmgit / microservice bots.md
Created April 6, 2022 21:21 — forked from DasWolke/microservice bots.md
Microservice bots

Microservice Bots

What they are and why you should use them

Introduction

Recently more and more chatbots appear, the overall chatbot market grows and the platform for it grows as well. Today we are taking a close look at what benefits creating a microservice chatbot on Discord - (a communication platform mainly targeted at gamers) would provide.

The concepts and ideas explained in this whitepaper are geared towards bots with a bigger userbase where the limits of a usual bot style appear with a greater effect

Information about Discord itself

(If you are already proficient with the Discord API and the way a normal bot works, you may skip ahead to The Concept)

@alexcmgit
alexcmgit / cypress.js
Last active February 14, 2022 21:48
Too lazy do find JS selectors and implement testing code, so lets make the browser my friend
/**
* Generate unique CSS selector from document [HTMLElement]
*/
function generateCssSelector(element) {
let path = [],
parent;
while ((parent = element.parentNode)) {
path.unshift(
`${element.tagName}:nth-child(${
@alexcmgit
alexcmgit / FlexRow.kt
Created December 4, 2021 22:32 — forked from vganin/FlexRow.kt
Jetpack Compose simple flex-wrap container
@Composable
fun FlowRow(
horizontalGap: Dp = 0.dp,
verticalGap: Dp = 0.dp,
alignment: Alignment.Horizontal = Alignment.Start,
content: @Composable () -> Unit,
) = Layout(content = content) { measurables, constraints ->
val horizontalGapPx = horizontalGap.toPx().roundToInt()
val verticalGapPx = verticalGap.toPx().roundToInt()
@alexcmgit
alexcmgit / DashedBorder.kt
Created December 4, 2021 19:23 — forked from DavidIbrahim/DashedBorder.kt
dashedBorder modifier for android compose
import androidx.compose.foundation.BorderStroke
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@alexcmgit
alexcmgit / apply.dart
Created November 3, 2021 07:44
Fix some Dart analyzer errors, save your work before using this script
import 'dart:io';
import 'package:equatable/equatable.dart';
const kPreferConstConstructors = 'prefer_const_constructors';
const kUnnecessaryConst = 'unnecessary_const';
const kPreferConstDeclarations = 'prefer_const_declarations';
Future<void> main() async {
final result = await Process.run('dart', ['analyze']);
@alexcmgit
alexcmgit / emulator-install-using-avdmanager.md
Created October 26, 2021 04:15 — forked from mrk-han/emulator-install-using-avdmanager.md
Installing and creating Emulators with AVDMANAGER (For Continuous Integration Server or Local Use)

Install and Create Emulators using AVDMANAGER and SDKMANAGER

TL;DR

For generic skin emulator with default apis (without google apis):

  1. List All System Images Available for Download: sdkmanager --list | grep system-images

  2. Download Image: sdkmanager --install "system-images;android-29;default;x86"

import 'package:flutter/material.dart';
void main() {
runApp(const TabBarDemo());
}
class TabBarDemo extends StatefulWidget {
const TabBarDemo({Key? key}) : super(key: key);
@override
import 'dart:math';
String _roundTo(num value, int decimals,
{bool floor = true, bool round = false, bool ceil = false}) {
assert(floor || round || ceil);
final sign = value >= 0 ? 1 : -1;
final current = ((value * pow(10, decimals)) + (sign * 0.001));
@alexcmgit
alexcmgit / dotted_background.dart
Last active October 10, 2021 18:27
CustomPainter to help render a dotted background as Widget for Flutter
import 'package:flutter/material.dart';
class DottedBackground extends StatefulWidget {
final Widget? child;
final Color color;
/// Size of each square pattern
final double? size;
/// double [between 0.0 and 0.1] that represents the fraction of each square padding
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.