Skip to content

Instantly share code, notes, and snippets.

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
@mikela
mikela / tailwindTypeaheadDropdownAngularTypescript.ts
Last active November 19, 2021 16:52
Tailwindcss typeahead dropdown Angular Typescript
/*** 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">
@mikela
mikela / backoff.ts
Last active December 7, 2021 17:19
A rxjs retryWhen error with backoff in Typescript
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));
@mikela
mikela / inputDebounceAngularGist.ts
Last active November 19, 2021 16:35
Input debounce Angular Typescript
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 ***/
@mikela
mikela / app.yaml
Created November 12, 2021 20:11 — forked from darktable/app.yaml
GAE: App.yaml designed for serving a static site on Google App Engine (Python). Copy your static html and files into a folder called "static" next to app.yaml. Contains a bunch of mimetype declarations from html5boilerplate's .htaccess. May not be neces
application: you-app-name-here
version: 1
runtime: python
api_version: 1
default_expiration: "30d"
handlers:
- url: /(.*\.(appcache|manifest))
mime_type: text/cache-manifest
@mikela
mikela / gist:1b3bc9b9d78b6133d2617d68b69b31e9
Last active September 21, 2021 19:05
get-selection-of-textformfield-in-flutter workaround
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@mikela
mikela / main.dart
Last active March 18, 2021 09:48
Flutter TextField debounce
import 'dart:async';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@mikela
mikela / mongodbAggregateCasbah.scala
Last active September 20, 2016 18:33
MongoDB / Casbah Scala toolkit: Count number of different "someField" where $match some condition
/* 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 } } }