This file contains hidden or 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
For new apps (+flexibility and +maintainability) | |
Angular w/ Universal + Cypress | |
TailwindCSS v3 | |
Flutter - For Mobile/Desktop only, no SEO in web. | |
Firebase (Auth, Hosting...) | |
Akka HTTP + Alpakka backend (Scala) | |
PostreSQL/MySQL or GCP Spanner | |
GCP infrastructure (Cloud Run, BigQuery etc) | |
Other options |
This file contains hidden or 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
/*** HTML ***/ | |
<div class="group inline-block relative"> | |
<div class="flex flex-row"> | |
<input id="item" class="rounded-l group-hover:rounded-b-none p-2 bg-gray-100 w-full" type="text" spellcheck="false" (keyup)="filterItems($event.target)" placeholder="All" [(ngModel)]="chosenItemLabel"> | |
<div class="secondary-button rounded-r group-hover:rounded-b-none cursor-pointer" (click)="clearItem()"> | |
<img class="h-6 px-2 mt-[2px]" src="../../assets/clear_black_24dp.svg"> <!-- from https://fonts.google.com/icons --> | |
</div> | |
</div> | |
<ul class="absolute hidden bg-white text-gray-500 group-hover:block group-hover:rounded-t-none border-[0.1px] rounded z-10 min-w-max w-full h-56 overflow-auto group-hover:shadow-lg"> |
This file contains hidden or 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 { Observable, pipe, throwError, timer } from 'rxjs'; | |
import { mergeMap, retryWhen } from 'rxjs/operators'; | |
export function backoff(maxRetries = 5): (_: Observable<any>) => Observable<any> { | |
return pipe( | |
retryWhen(errors => errors.pipe( | |
mergeMap((error, i) => { | |
const retryAttempt = i + 1; | |
if (retryAttempt > maxRetries) { | |
return throwError(() => new Error(error)); |
This file contains hidden or 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
This gist describes how to implement a debounce when using an html input that calls an http method in Angular, something you can use in a search input. | |
/*** HTML ***/ | |
<input type="text" (input)="changeInput(titleSearch, $event.target, titleSearchChange, 2)"> | |
/*** /HTML ***/ | |
/*** Typescript ***/ |
This file contains hidden or 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
application: you-app-name-here | |
version: 1 | |
runtime: python | |
api_version: 1 | |
default_expiration: "30d" | |
handlers: | |
- url: /(.*\.(appcache|manifest)) | |
mime_type: text/cache-manifest |
This file contains hidden or 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'; | |
const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override |
This file contains hidden or 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:async'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override |
This file contains hidden or 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
/* This is basically what | |
> db.myCollection.distinct("productId", {"items.0": {$exists: true}}).count() | |
should do, or what | |
> db.myCollection.distinct("productId", {"items.0": {$exists: true}}).length | |
does, but may not scale well (32-bit unsigned int: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length). | |
Solved with the aggregation framework: | |
> db.myCollection.aggregate([ | |
{ $match: { 'items.0': {$exists: true} } }, | |
{ $group: { _id: "$productId"} }, | |
{ $group: { _id: 1, count: { $sum: 1 } } } |