Skip to content

Instantly share code, notes, and snippets.

@alvarotf
alvarotf / async-api-call-helper.service.ts
Created December 22, 2018 21:07
Angular Universal: Using ZoneMacroTaskWrapper to make renderModuleFactory wait for async api calls.
import { Injectable } from '@angular/core';
import { Observable, Observer, Subscription } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class AsyncApiCallHelperService {
@singledigit
singledigit / cognito.yaml
Last active January 16, 2024 16:15
Create a Cognito Authentication Backend via CloudFormation
AWSTemplateFormatVersion: '2010-09-09'
Description: Cognito Stack
Parameters:
AuthName:
Type: String
Description: Unique Auth Name for Cognito Resources
Resources:
# Creates a role that allows Cognito to send SNS messages
SNSRole:
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@mnoble01
mnoble01 / international phone number mask
Last active March 2, 2023 14:03
i18n libphonenumber mask (with in-hand country code)
/*
This is using the JS port of Google's libphonenumber.
As far as I know, though, all of the APIs are the same or similar
*/
// I just hardcoded "US" as the country, but of course you can use any country iso code
var ctry = 'US';
var exampleNumber = i18n.phonenumbers.PhoneNumberUtil.getInstance()
.getExampleNumberForType(ctry, i18n.phonenumbers.PhoneNumberType.MOBILE); // returns PhoneNumber instance
@6174
6174 / Random-string
Created July 23, 2013 13:36
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);