Skip to content

Instantly share code, notes, and snippets.

View birchb's full-sized avatar

birchb

View GitHub Profile
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:time_tracker_flutter_course/app/home/tab_item.dart';
class CupertinoHomeScaffold extends StatelessWidget {
// final TabItem currentTab;
// final ValueChanged<TabItem> onSelectTab;
final Map<TabItem, WidgetBuilder> widgetBuilders;
const CupertinoHomeScaffold({
import 'package:flutter/material.dart';
import 'package:time_tracker_flutter_course/app/home/cupertino_home_scaffold.dart';
import 'package:time_tracker_flutter_course/app/home/tab_item.dart';
import 'jobs/jobs_page.dart';
// ? would this be a good place to put a riverpod database provider? Would it be globally available?
class HomePage extends StatefulWidget {
@override
@birchb
birchb / README.md
Created June 24, 2020 02:04 — forked from yusufkandemir/README.md
Quasar + FCM(Firebase Cloud Messaging) Setup

What to do next?

Manage The Subscription State

Manage the subscription state using localStorage, IndexedDB, or a server-side solution(e.g. in Firestore, store per-user), depending on the flow of your app.

Notification UI/UX

Create a notification section in settings, in navbar or just prompt it directly(not recommended, bad UX). On UI interaction such as a subscribe button, call subscribeNotifications with the related parameters(subscribe = true/false, token), then persist the notification state.

Create Notifications

const messaging = firebase.messaging();
messaging.usePublicVapidKey(YOUR_PUBLIC_VAPID_KEY_HERE);
messaging.onTokenRefresh(() => {
messaging.getToken().then(async token => {
const subscribeNotifications = firebase.functions().httpsCallable('subscribeNotifications');
await subscribeNotifications({ token });
});
@birchb
birchb / config.js
Last active April 19, 2020 16:28
Config file for using Handbrake in Electron
// ! also set ```asar: false``` in electron build process.
const path = require('path')
const electron = require('electron');
/* path to the HandbrakeCLI executable downloaded by the install script */
let HandbrakeCLIPath = null
switch (process.platform) {
case 'darwin':
// This is the firebase script called to create each user.
exports.createUser = functions.https.onCall((data) => {
const user = data.user[0]
let displayName = `${user.firstName} ${user.lastName}`
return admin.auth().createUser({
displayName: displayName,
email: user.email,
// I use this js function inside ManageUsers.vue. It maps through an array of user data (jsonData) to call the createUser httpsCallable function.
async createNewUsers () {
this.loadingNewUsers = true
var createUser = this.$fb.functions().httpsCallable('createUser')
let promises = this.jsonData.map(person => {
// I use quasar uid to create an initial password: https://quasar.dev/quasar-utils/other-utils#Generate-UID
person.password = uid()
let jsonDatum = []
jsonDatum.push(person)
<template>
...
<my-uploader
flat
color="grey-3"
text-color="grey-10"
style="min-width: 418px"
@uploaded="videoUploaded"
@failed="videoUploadFailed"
:pathPrefix="`${currentUser.uid}/videos`"
// adapted from https://github.com/quasarframework/quasar/issues/3428
import { QUploaderBase } from 'quasar'
import _ from 'lodash'
export default {
name: 'toStorage',
props: {
pathPrefix: {
type: String,
const primesLessThanN = (n) => { //* This can be processor intensive
let primes = []
for(i = 0; i < n; i++) {
if ( i <= 1) { //* no number <= 1 can be prime
continue
}
let isPrime = true
while( isPrime ) {