Skip to content

Instantly share code, notes, and snippets.

View javebratt's full-sized avatar
🏠
Working from home

Jorge Vergara javebratt

🏠
Working from home
View GitHub Profile
@javebratt
javebratt / example.interceptor.ts
Created July 18, 2022 21:49
Example of injector token in nx monorepo
// This is an example in a previous application to show
// how to use the variables in the `environment.ts`
// file in different Nx libraries.
// First, we create the injection tokens in a shared library, for this example, I used the file:
// `libs/shared/util/environment-config/src/lib/app-config.ts`
import { InjectionToken } from '@angular/core';
export const APP_VERSION = new InjectionToken<string>('app-version');
// Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e
// by @levelsio
// HOW TO
// 1) Make a Google Sheet, we'll pull the first cell e.g. A1
// 2) Publish your Google Sheet, File -> Publish To Web
// 3) Copy the SHEET_ID in the URL, put it in here below:
const endpoint = "https://spreadsheets.google.com/feeds/cells/SHEET_ID/1/public/full?alt=json"
// 4) Install Scriptable @ https://apps.apple.com/us/app/scriptable/id1405459188
// 5) Copy this entire script in to Scriptable (tip: you can send it to your iPhone via Whatsapp/Messenger/Telegram etc)
{
"author": "Jorge Vergara"
}
async getUserProfile(): Promise<firebase.firestore.DocumentReference> {
const user = await firebase.auth().currentUser;
return firebase.firestore().doc(`/userProfile/${user.uid}`);
}
getUserProfile(): Promise<firebase.database.Reference> {
return new Promise((resolve, reject) => {
firebase.auth().onAuthStateChanged(user => {
if (user) {
const userProfile = firebase.database().ref(`/userProfile/${user.uid}`);
resolve(userProfile)
} else {
reject(false)
}
});
@javebratt
javebratt / pictures.ts
Created January 4, 2018 16:16
How to retrieve the guest list from an Event
// First I would create a function in the EventProvider to fetch the guest list
getGuestList(eventId: string): firebase.database.Reference {
return this.eventListRef.child(eventId).child('guestList');
}
// Then I'd call it from the event's detail page:
public guestList;
ionViewDidLoad(){
@javebratt
javebratt / master-firestore.md
Last active November 23, 2017 16:29
Short note for the people who pre-ordered Master Firestore

Master Firestore

Hey, thank you for pre-ordering my book, your support helps me create more free content for the people that can't afford my paid courses :)

I wanted to write a short note on how this pre-order is going to work.

I already have the app built, it's a collaborative shopping app (I know it sounds weird, but give me a sec to explain)

It showcases:

How to use Facebook Sign-In with Ionic and Firebase | Step-by-step guide

Facebook has become one of the most used methods to get users to sign-in to your application, in today's post we'll set up the Facebook native plugin through Ionic Native.

That way we can use the Facebook app to sign-in our users, instead of having them log in through a browser.

To make things easier, we're going to break down the process in three different parts:

  • Step #1: We'll log into our Facebook developer account, create a new app and get the credentials.
  • Step #2: We'll go into our Firebase console and enable Facebook Sign-In with the credentials from the first step.
// When using a provider to call AngularFire2
// which syntax do you use the most
// Provider
getItems(): FirebaseListObservable<any> {
return afDatabase.list('/items');
}
// Inside the class do you:
this.items = providerName.getItems();
firebase.auth().onAuthStateChange( user => {
if (!user){
// No user, send to login.
} else {
// There is a user, check for email verification.
if (user.emailVerified) {
// Email verified, do your thing.
} else {
// No verification yet
}