Skip to content

Instantly share code, notes, and snippets.

View heytulsiprasad's full-sized avatar
⚛️
Overreacting

Tulsi Prasad heytulsiprasad

⚛️
Overreacting
View GitHub Profile
@heytulsiprasad
heytulsiprasad / WebViewInApp.js
Created June 11, 2021 15:58
Basic usage of React Native Webview
// Mobile: React Native
import React, {useState, useEffect} from 'react';
import { View } from 'react-native';
import {Button} from 'react-native-paper';
import { WebView } from 'react-native-webview';
const App = () => {
const [show, setShow] = useState({isOpen: false, url: null});
@heytulsiprasad
heytulsiprasad / FirstWebViewComponent.js
Last active June 14, 2021 13:03
Basic usage of React Native Webview inside a component
import React from 'react';
import {SafeAreaView, StatusBar} from 'react-native';
import {WebView} from 'react-native-webview';
const App = () => {
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView style={{flex: 1}}>
<WebView source={{uri: 'https://medium.com/'}} />
@heytulsiprasad
heytulsiprasad / signInWithAuthProvider.js
Last active June 11, 2021 16:55
Basic sign in using third party auth provider using Firebase
export const signInUserWithAuthProvider = async (
authProvider: AuthProvider
) => {
firebase.auth().tenantId = authProvider.tenantId;
const provider = new firebase.auth.SAMLAuthProvider(authProvider.provider);
firebase.auth().signInWithRedirect(provider);
const authResult = await firebase.auth().getRedirectResult();
return authResult;
@heytulsiprasad
heytulsiprasad / signInUserWithFirebase.js
Last active June 11, 2021 16:55
Basic email and password signin with Firebase
const signInUser = () => {
return firebase.auth().signInWithEmailAndPassword(email, password);
}
@heytulsiprasad
heytulsiprasad / getAuthProviderResponse.json
Last active June 14, 2021 12:47
Response given by Auth Provider API
{ "tenantId": "some-random-tenant", "provider": "third.party" }
@heytulsiprasad
heytulsiprasad / getAuthProvider.js
Last active June 11, 2021 16:54
API to get the right auth provider for each user
export const getAuthProvider = async (email: string) => {
const response = await fetch(`${backendUrl}/auth-provider?email=${email}`, {
method: "GET",
headers: {
"Content-type": "application/json"
},
credentials: "include"
});
return response.json();
@heytulsiprasad
heytulsiprasad / data_structure.js
Created February 10, 2021 11:23
For lazzzy app
///////////////////////////////////////////////////////////////////
/**
* currentPages is an array of objects which holds each active page
* on the browser.
*
* page: {
* id: <string>,
* url: <string>,
* author: <string>,
@heytulsiprasad
heytulsiprasad / fireystore.js
Last active February 22, 2021 17:15
Firestore basics
// Edited this from VS code
var firebaseConfig = {};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
const db = firebase.firestore();
// Read
db.collection("cafes")
@heytulsiprasad
heytulsiprasad / a.java
Created December 7, 2020 07:03
Java 1
import java.util.Scanner;
public class Practice {
public static void main(String args[]) {
Scanner scr = new Scanner(System.in);
System.out.println("please enter two numbers");
int a = scr.nextInt();
int b = scr.nextInt();
@heytulsiprasad
heytulsiprasad / shopify-prop-types.js
Last active November 26, 2020 09:36
Validating prop types of results fetched by Shopify Storefront API
ProductForm.propTypes = {
product: PropTypes.exact({
description: PropTypes.string.isRequired,
descriptionHtml: PropTypes.string.isRequired,
handle: PropTypes.string.isRequired,
id: PropTypes.string.isRequired,
options: PropTypes.arrayOf(
PropTypes.exact({
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,