Skip to content

Instantly share code, notes, and snippets.

View shalaby's full-sized avatar

Muhammad Shalaby shalaby

  • Egypt
View GitHub Profile
@shalaby
shalaby / singleton.dart
Created June 22, 2020 23:34 — forked from theburningmonk/singleton.dart
Using Dart's factory constructor feature to implement the singleton pattern
class MyClass {
static final MyClass _singleton = new MyClass._internal();
factory MyClass() {
return _singleton;
}
MyClass._internal() {
... // initialization logic here
}
@shalaby
shalaby / deploy.yml
Created June 17, 2020 14:14 — forked from apgapg/deploy.yml
Github Workflow for Building, Releasing Flutter web app to Github Pages and Firebase Hosting
# This is a basic workflow to help you get started with Actions
name: Build, Release app to Github Pages and Firebase Hosting
# name: Test, Build and Release apk
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
- master

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@shalaby
shalaby / date-formats.ts
Created May 28, 2020 21:28 — forked from wottpal/date-formats.ts
Custom DateFormats & DateAdapter for Angular Material MatDatepicker using Day.js
import { Platform } from '@angular/cdk/platform';
import { NativeDateAdapter } from '@angular/material';
import * as dayjs from 'dayjs';
import 'dayjs/locale/de';
import * as customParseFormat from 'dayjs/plugin/customParseFormat';
import * as localizedFormat from 'dayjs/plugin/localizedFormat';
/**
* Custom Date-Formats and Adapter (using https://github.com/iamkun/dayjs)
@shalaby
shalaby / color.dart
Created May 22, 2020 14:20 — forked from erluxman/color.dart
Colorfilters in dart
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(App());
}
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
@shalaby
shalaby / gist:b3b24d1be19c67f458561bf58822857f
Created May 12, 2020 16:01 — forked from iainsproat/gist:8378720
Git: stash work in progress and move it to a new branch
  • make changes
  • git stash save
  • git checkout -b xxx
  • git stash pop

where xxx is the new branch name

@shalaby
shalaby / fix_firefox.sh
Created January 28, 2020 13:01
Fix Firefox not opening secured web sites.
//Open about:config in firefox
//Toggle security.enterprise_roots.enabled to true
@shalaby
shalaby / popup_route.dart
Created December 10, 2019 10:46
Popup route.
PopupRoute
I read flutter framework code and found out showDialog is actually using PopupRoute. Basically, this will create a new route and make the previous routepage inactive.
The simplest code is as follows:
class MyPopupRoute extends PopupRoute<void> {
@override
Color get barrierColor => Colors.black54;
@override
@shalaby
shalaby / sub_navigator.dart
Created December 10, 2019 10:43
Creating another Navigator right inside of MaterialApp
Creating another Navigator right inside of MaterialApp - some kind of a second 'sub-root' navigator.
Now you will be able to choose between 2 layers of Navigator depending on your needs.
Navigator.of(context, rootNavigator: true) will return the top-level Navigator - use it for your Flushbar or any other modal popups that you want to keep persistent above all screens.
Navigator.of(context), where rootNavigator is false by default. Use it to get the 'sub-root' Navigator to display new screens / pages.
e.g. placing another Navigator right in the MaterialApp.