This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Ruby on Rails trigger Github Actions" | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool getRandomElement(List<bool> list) => list[Random().nextInt(list.length)]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter_week_view/flutter_week_view.dart'; | |
DateTime now = DateTime.now(); | |
DateTime date = DateTime(now.year, now.month, now.day); | |
DayView dayView() { | |
return DayView( | |
date: now, | |
events: [ | |
FlutterWeekViewEvent( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
// Find first date and last date of CURRENT WEEK | |
DateTime today = DateTime.now(); | |
print(findFirstDateOfTheWeek(today)); | |
print(findLastDateOfTheWeek(today)); | |
// Find first date and last date of any provided date | |
DateTime date = DateTime.parse('2023-09-01'); | |
print(findFirstDateOfTheWeek(date)); | |
print(findLastDateOfTheWeek(date)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:convert'; | |
// package needed: https://pub.dev/packages/crypto | |
import 'package:crypto/crypto.dart'; | |
void main() { | |
var passwordBytes = utf8.encode("s0me-super-cool-p@$$WorD-here"); | |
var passwordEncrypt = sha256.convert(passwordBytes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* It forces strong passwords | |
* @require String password | |
* @return bool | |
* | |
* return true if password has: | |
* 1 capitalized character | |
* 1 special character | |
* 1 number | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void testConnection() async { | |
try { | |
final connection = await InternetAddress.lookup('www.google.com'); | |
if (connection.isNotEmpty && connection.first.rawAddress.isNotEmpty) { | |
hasConnection = true; | |
} | |
} on SocketException catch (_) { | |
hasConnection = false; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class AppDrawer extends StatelessWidget { | |
const AppDrawer({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return Drawer( | |
backgroundColor: Colors.white, | |
child: Column( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HttpStatusConstants { | |
// can't be 'continue' because it is reserved name | |
static const int continueCode = 100; | |
static const int switchingProtocols = 101; | |
static const int processing = 102; | |
static const int ok = 200; | |
static const int created = 201; | |
static const int accepted = 202; | |
static const int nonAuthoritative = 203; | |
static const int noContent = 204; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:your_project_name/config/http_status_constants.dart'; | |
int responseCodeHelper(code) { | |
switch (code) { | |
case HttpStatusConstants.continueCode: | |
return HttpStatusConstants.continueCode; | |
case HttpStatusConstants.switchingProtocols: | |
return HttpStatusConstants.switchingProtocols; | |
case HttpStatusConstants.processing: | |
return HttpStatusConstants.processing; |
NewerOlder