Firebase is a widely used mobile and website development kit by google firebase team. firebase comes with a variety of development tools which makes Application development fast than ever before.
Angular Firebase Cheat Sheet covers all essential things which are needed for creating a variety of web applications such as Authentication, posting data and retrieving data from cloudfirestore and uploading an image on firebase.
Authentication
Authorizing folks to use the website is not an easy task a single flaw can lead to a personal data breach and making a custom authentication server is time-consuming and costly. firebase provides a variety of authentication services which saves much time and cost.
Firebase Database API Cheatsheet There is no way to store an empty object/array/null value. There are also no actual arrays. Array values get stored as objects with integer keys. Firebase provides detailed documentation and cross-platform SDKs to help you build and ship apps on Android, iOS, the web, C, and Unity. View all docs Try Firebase today. Integrating it into your app is easy. Get started Learn. Guides Reference Samples. A Firebase database security rules cheat sheet. Code snippets which demonstrate how to work with Firebase Realtime Database security rules.
Create a new firebase project then register web app and copy Firebase SDK snippet in environment.ts
Enable email and password sign method in the Authentication section of firebase
Installangularfire
Import angular firebase dependence and initialize environment settings in app.module.ts
Generate new angular service then create a firebase login method
Import firebaseService.ts in component
Create user email and password with firebase rest request for more info visit(https://firebase.google.com/docs/reference/rest/auth).
Copy project Web API Key from project settings
Routing Guard
Creating a routing guard let authorized users can only access a certain page of Web App!
Update app-routing.ts
CloudFirestore
Similarly, firebase also provides CloudFirestore to store data in NoSQL formate. a complex query can also be fired in CloudFirestore such as AND OR EQUAL TO very easily. data can be added modified or deleted in CloudFirestore at realtime
CloudFirestore CRUD Operations
- Insert data in a firebase collection
Add and read data from a specific document of collection
Cloudfirestore Query
- Update Data
- Delete Data
Upload File
Firebase also gives storage option for saving files or images. after uploading file in firebase project it automatically creates URL of that upload file.
Upload file in firebase
Current User Detail
In some scenarios, Angular application also requires current login detail for slowing profile image, user name or UID of the user which might be required throughout the application.
Get current user detail
Regular Expressions are notoriously difficult to learn - they have a very compact syntax that ends up looking like gibberish. However, they can be extremely powerful when it comes to form validation, find and replace tasks, and/or searching through a body of text. The following cheatsheet provides common RegEx examples and techniques for the JavaScript developer.
Firebase Cheat Sheet
? There are several awesome tools that can help you debug RegEx in the browser - my personal favorite is RegExr.
How do you Pronounce RegEx?
Much like Gif vs Jif, the proper pronunciation of RegEx is passionately debated among developers. Based on my limited twitter poll, in looks like most prefer the hard G over the soft J.
Before I make a video about Regular Expressions... How do you pronounce it?
— fireship.io (@fireship_dev) May 18, 2020Regex Reference
Basics
/ expression / flags
, i.e/[A-Z]+/g
basic format/ hello?*/
escape special characters with backslashes()
group with parentheses|
logical OR
Character classes
w
wordd
digits
whitespace (tabs, line breaks)W
NOT wordD
NOT digitS
NOT whitespacet
tabs,n
line breaks.
any character (except newline)
Brackets
[xyz]
match any x, y, z[J-Z]
match any capital letters between J & Z.[^xyz]
NOT x, y, z
Quantification
bob|alice
match bob or alicez?
zero or one occurrencesz*
zero or multiple occurrencesz+
one or multiple occurrencesz{n}
n occurrencesz{min,max}
min/max occurrences
Firebase Cheat Sheet 2020
Anchors
hello world
exact match^hello
start of the stringsworld$
end of the string
How to Use RegEx in JavaScript
Create a Regular Expression
There are two ways to create a regular expression in JavaScript. The literal way is just a set of characters between two forward slashes
/ /
.You can also instantiate
RegExp
.String Regex Functions
There are several ways to use a regular expression on a string primitive, such as (1)
match
all the occurrences, (2) search
for the existence of a pattern, or (3) replace
matches with a new value.Common Examples
Password Validation
How do you validate the format of a password for a signup form? Let’s force passwords to contain a capital letter, lowercase letter, number, and min length of 8.
See full demo.
Hex Codes
How do you find all of the hex codes, such as CSS colors, in a document? Useful if you need to analyze the color scheme.
See full demo.
Remove HTML Tags
How do you remove all HTML tags from a document? Use the regex below to find and replace all HTML tags.
See full demo