Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Chris Brannen cbrannen9a

🏠
Working from home
View GitHub Profile
@cbrannen9a
cbrannen9a / main.py
Created Apr 1, 2019
Add data from csv to firestore with types
View main.py
import csv
import firebase_admin
import google.cloud
from firebase_admin import credentials, firestore
cred = credentials.Certificate("./ServiceAccountKey.json")
app = firebase_admin.initialize_app(cred)
store = firestore.client()
@cbrannen9a
cbrannen9a / UseState.js
Created Jan 18, 2019
React hooks useState example
View UseState.js
export const UseState = () => {
//Declare state value of count and setCount function to update
//set the initial value of count as 0
const [count, setCount] = useState(0);
//setCount function
return (
<div className='content'>
<h4>UseState</h4>
<p>You clicked {count} times</p>
@cbrannen9a
cbrannen9a / test.py
Created Jan 4, 2019
Checking data from firestore
View test.py
import firebase_admin
from firebase_admin import credentials, firestore
cred = credentials.Certificate("./ServiceAccountKey.json")
app = firebase_admin.initialize_app(cred)
store = firestore.client()
doc_ref = store.collection(u'COLLECTION_TO_CHECK')
data = []
@cbrannen9a
cbrannen9a / main.py
Created Jan 4, 2019
Add data from csv to Firestore
View main.py
import csv
import firebase_admin
import google.cloud
from firebase_admin import credentials, firestore
cred = credentials.Certificate("./ServiceAccountKey.json")
app = firebase_admin.initialize_app(cred)
store = firestore.client()
@cbrannen9a
cbrannen9a / main.py
Created Jan 4, 2019
Adding data to Firestore
View main.py
import firebase_admin
import google.cloud
from firebase_admin import credentials, firestore
cred = credentials.Certificate("./ServiceAccountKey.json")
app = firebase_admin.initialize_app(cred)
store = firestore.client()
doc_ref = store.collection(u'test')
@cbrannen9a
cbrannen9a / main.py
Created Jan 4, 2019
Get data from Firestore
View main.py
import firebase_admin
import google.cloud
from firebase_admin import credentials, firestore
cred = credentials.Certificate("./ServiceAccountKey.json")
app = firebase_admin.initialize_app(cred)
store = firestore.client()
doc_ref = store.collection(u'users').limit(2)
View requirements.py
pip install firebase-admin google-cloud-firestore
@cbrannen9a
cbrannen9a / setup.py
Created Jan 4, 2019
Virtualenv setup
View setup.py
virtualenv env
@cbrannen9a
cbrannen9a / Example2.js
Created Nov 12, 2018
Adding second hook
View Example2.js
import React, { useState, useEffect } from 'react';
function Example() {
// Declare a new state variable, which we'll call "count"
const [count, setCount] = useState(0);
useEffect(() => {
// Update the document title using the browser API
document.title = `You have written ${count} hooks`;
});
@cbrannen9a
cbrannen9a / App.js
Created Nov 12, 2018
Example App.js
View App.js
import React, { Component } from 'react';
import './App.css';
import Example from './Example';
class App extends Component {
render() {
return (
<div className="App">
<Example />
</div>
You can’t perform that action at this time.