Skip to content

Instantly share code, notes, and snippets.

View loonix's full-sized avatar

Daniel Carneiro loonix

  • CADS UK
  • Vila Nova de Gaia, PT
View GitHub Profile
@loonix
loonix / call_it_from_implementation.dart
Created September 23, 2021 13:30
[Flutter] Long Press menu widget
var _tapPosition;
void _showCustomMenu() {
var overlay = Overlay.of(context)!.context.findRenderObject() as RenderBox;
showMenu(
context: context,
items: <PopupMenuEntry<int>>[PlusMinusEntry()],
position: RelativeRect.fromRect(
_tapPosition & const Size(40, 40), // smaller rect, the touch area
@loonix
loonix / mostUsedCommandsGit.md
Last active April 9, 2021 14:44
[Git] Most used commands

create branch from another branch git checkout -b subbranch_of_b1 branch1

move to different branch git checkout branch1

git merge branch git merge branch_to_merge_from

delete branch locally

@loonix
loonix / version_handler.dart
Created March 8, 2021 08:57
Control version from api and local version.
import 'package:package_info/package_info.dart';
/// Helper functions for version handling.
/// Note: For functions that only manipulate version conversions/formatting
class VersionHandler {
/// Validates a version object and returns true or false, e.g. major: 1, minor: 0, patch: 1 returns true
static bool isValidVersionObject(obj) {
return (obj.major is int && obj.minor is int && obj.patch is int && (obj.major != null && obj.minor != null && obj.patch != null) && (obj.major != 0 || obj.minor != 0 || obj.patch != 0));
}
@loonix
loonix / dart_email_regex.dart
Last active March 23, 2021 15:42
[Dart Email Regex]
/// Needed to make a regex that matched my criterias, there are a few regex already made that do not take into acount domais that end in .services
/// for international email please have a look at this regex https://rubular.com/r/bqNZ0WT0RMSaGV
main() async {
_checkEmail("a@a"); // false
_checkEmail("[email protected]"); // false
_checkEmail("s@asd,com"); // false
_checkEmail("[email protected],uk"); // false
_checkEmail("[email protected]"); // true
_checkEmail("[email protected]"); // true
@loonix
loonix / vertical_text_widget.dart
Created February 11, 2021 09:59
Flutter vertical text widget
/// REF: https://stackoverflow.com/a/58345080/5232022
class MyVerticalText extends StatelessWidget {
final String text;
const MyVerticalText(this.text);
@override
Widget build(BuildContext context) {
return Wrap(
@loonix
loonix / db1.sql
Created June 26, 2020 15:11
[DB1] DB #sql
create database db3 charset latin1 collate latin1_swedish_ci;
@loonix
loonix / class.cs
Last active June 24, 2020 21:44
ClassDB
private void Notas_Load(object sender, EventArgs e)
{
ClassBD classBD = new ClassBD(); // link a classDB
//SqlDataReader dataReader = classBD.ObterDadosCodigos(); // Obter os dados para popular a tabela
//DataTable table = new DataTable();
//table.Load(dataReader); // Carrega os dados para a datatable
DataTable table = classBD.ObterDadosCodigos2();
dataGridView1.DataSource = table; // Mostra valores na grid
@loonix
loonix / db21.sql
Last active June 24, 2020 16:59
[DB21] New Database - Import from DUMP
create database db21 charset latin1 collate latin1_swedish_ci;
create database db23 charset latin1 collate latin1_swedish_ci;
mysql -u root db22 < C:/Users/danie/Documents/Universidade/university/Databases/MariaDbDatabases/db4.sql
mysql -u root db22 > C:/Users/danie/Documents/Universidade/university/Databases/MariaDbDatabases/db55.sql
C:/Users/danie/Documents/Universidade/university/Databases/MariaDbDatabases/db-hp-calc-input.csv
-- insert products CSV
@loonix
loonix / db4.sql
Last active June 22, 2020 11:56
[MariaDb Dump Example database] #sql
-- MariaDB dump 10.17 Distrib 10.4.13-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: db2
-- ------------------------------------------------------
-- Server version 10.4.13-MariaDB-1:10.4.13+maria~bionic
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
@loonix
loonix / db3.sql
Last active June 24, 2020 16:56
[DB3 - Database creation and multiple queries] Database Example #university
--- run mysql XAAMP >> mysql -u root mysql
------------------------------------------------------------------------
-- DB 3
------------------------------------------------------------------------
create database db3 charset latin1 collate latin1_swedish_ci;
CREATE TABLE IF NOT EXISTS products (
productID INT UNSIGNED NOT NULL AUTO_INCREMENT,
productCode CHAR(3) NOT NULL DEFAULT '',