Skip to content

Instantly share code, notes, and snippets.

View davidgilbertson's full-sized avatar

David Gilbertson davidgilbertson

  • Sydney, Australia
View GitHub Profile
{
"data" : {
"courses" : {
"-KIPudHADux41n04CCxE" : {
"name" : "An excellent course!",
"schoolKey" : "-KIPudH9ZmFi3cimtCTH"
},
"-KIPudHADux41n04CCxF" : {
"name" : "An second excellent course",
"schoolKey" : "-KIPudH9ZmFi3cimtCTH"
//This sets up listeners to listen to data in this structure: https://gist.github.com/davidgilbertson/283581dd10013848b0e7037e308db113
const db = firebase.database().ref('test');
const userId = firebase.auth().currentUser.uid;
const userRef = db.child('users').child(userId);
// a mock store
const store = {
dispatch: (action) => {
console.log(action);
}
// Firebase V3.0.0
// an example using a single atomic `update()` to create objects in three 'tables' that reference each other.
// one school has many courses and many studens
// one course has many students and is in only one school
// one student is in many courses and only one school
db = firebase.database().ref('test');
const userId = firebase.auth().currentUser.uid;
db = firebase.database().ref('test');
const userId = firebase.auth().currentUser.uid;
function removeStudent(studentKey) {
db.child('data/students').child(studentKey).once('value', (studentSnapshot) => {
const student = studentSnapshot.val();
const courseKeys = Object.keys(student.courseKeys);
const removeData = {
import React from 'react';
export default () => (
<svg width="22" height="22" viewBox="0 0 1024 1024">
<path d="M192 1024h640l64-704h-768zM640 128v-128h-256v128h-320v192l64-64h768l64 64v-192h-320zM576 128h-128v-64h128v64z"></path>
</svg>
);
import React from 'react';
const {PropTypes} = React;
const icons = {
trash: 'M192 1024h640l64-704h-768zM640 128v-128h-256v128h-320v192l64-64h768l64 64v-192h-320zM576 128h-128v-64h128v64z',
facebook: 'M608 192h160v-192h-160c-123.514 0-224 100.486-224 224v96h-128v192h128v512h192v-512h160l32-192h-192v-96c0-17.346 14.654-32 32-32z',
};
const Icon = props => (
<svg width="22" height="22" viewBox="0 0 1024 1024">
// this is the selection.json file from IcoMoon, with "export default" added at the start and renamed from '.json' to '.js';
export default {
"IcoMoonType": "selection",
"icons": [
{
"icon": {
"paths": [
"M192 1024h640l64-704h-768zM640 128v-128h-256v128h-320v192l64-64h768l64 64v-192h-320zM576 128h-128v-64h128v64z"
],
import React from 'react';
const {PropTypes} = React;
import iconPaths from './selection.js';// the file exported from IcoMoon
function getPath(iconName) {
const icon = iconPaths.icons.find(icon => icon.properties.name === iconName);
if (icon) {
return icon.icon.paths.join(' ');
} else {
// These are the paths taken from IcoMoon's `selection.json` file.
// Where there were multiple paths (e.g. the linkedIn icon) they can be concatenated with a space
export default {
'bubble': 'M512 64c282.77 0 512 186.25 512 416 0 229.752-229.23 416-512 416-27.156 0-53.81-1.734-79.824-5.044-109.978 109.978-241.25 129.7-368.176 132.596v-26.916c68.536-33.578 128-94.74 128-164.636 0-9.754-0.758-19.33-2.164-28.696-115.796-76.264-189.836-192.754-189.836-323.304 0-229.75 229.23-416 512-416z',
'enlarge2': 'M1024 0v416l-160-160-192 192-96-96 192-192-160-160zM448 672l-192 192 160 160h-416v-416l160 160 192-192z',
'shrink2': 'M448 576v416l-160-160-192 192-96-96 192-192-160-160zM1024 96l-192 192 160 160h-416v-416l160 160 192-192z',
'bin2': 'M192 1024h640l64-704h-768zM640 128v-128h-256v128h-320v192l64-64h768l64 64v-192h-320zM576 128h-128v-64h128v64z',
'cloud-check': 'M892.268 514.49c2.442-11.108 3.732-22.646 3.732-34.49 0-88.366-71.634-160-160-160-14.224 0-28.014 1.868-41.134 5.352-24.796-77.352-97.288-133.352-
@davidgilbertson
davidgilbertson / Icon.jsx
Last active August 10, 2022 03:00
Production version
import React from 'react';
const {PropTypes} = React;
const Icon = props => {
const styles = {
svg: {
display: 'inline-block',
verticalAlign: 'middle',
},
path: {