Skip to content

Instantly share code, notes, and snippets.

View codediodeio's full-sized avatar
🤹‍♂️
hardly working

Jeff Delaney codediodeio

🤹‍♂️
hardly working
View GitHub Profile
@codediodeio
codediodeio / user.component.ts
Last active September 19, 2019 14:56
Link Anonymous Users to Google/Facebook with AngularFire2 (Angular 4 + Firebase)
import { Component, OnInit } from '@angular/core';
import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
import { Observable } from 'rxjs/Observable';
@Component({
selector: 'app-user',
templateUrl: './user.component.html',
styleUrls: ['./user.component.scss']
})
@codediodeio
codediodeio / movie.service.ts
Last active August 9, 2019 10:23
Infinite scroll solution for Firebase + Angular4 (work in progress)
// Movies in Database
//
// movies
// movieKey
// title
// image
// year
import { Injectable } from '@angular/core';
@codediodeio
codediodeio / main.dart
Last active May 17, 2019 00:58
An animated box shadow button with Dart 2.3 collection if/for
class CircleStack extends StatefulWidget {
@override
_CircleStackState createState() => _CircleStackState();
}
class _CircleStackState extends State<CircleStack> {
bool open = true;
@override
Widget build(BuildContext context) {
@codediodeio
codediodeio / database.rules.json
Last active May 7, 2019 14:54
Associate Firebase users with database items based on their UID
"rules": {
"items": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
}
}
class Dog {
String breed;
int age;
Dog({ this.age, this.breed });
factory Dog.fromMap(data) {
return Dog(
breed: data['breed'],
age: data['age'],
@codediodeio
codediodeio / reverse.pipe.ts
Created July 3, 2017 14:50
Reverse a FirebaseListObservable in Angular 4
<div *ngFor="let item of listObservable | async | reverse">
{{item?.whatever}}
</div>
import { Component } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Component({
selector: 'app-root',
template: `
<p>You clicked {{count.value}} times</p>
<button (click)="setCount(count.value + 1)">Click Me</button>
`,
})
@codediodeio
codediodeio / index.html
Created September 25, 2018 03:07
How Pick a Random YouTube Comment https://youtu.be/_dvQpqoJkc4
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.0/lodash.min.js"></script>
<style>
body {
text-align: center;
display: flex;
@codediodeio
codediodeio / fcm.ts
Created August 3, 2018 21:46
FCM Bug
// BUG: never emits token on first permission granted
this.fcm.getToken.subscribe(console.log);
// Works Fine
this.fcm.requestPermission
.pipe(
switchMap(v => {
return this.fcm.requestToken;
})
)
export class DocRef {
private ref: firebase.firestore.DocumentReference;
private stream;
constructor(private path: string) {
this.ref = firebase.firestore().doc(path);
this.stream = Observable.create(observer => {
this.ref.onSnapshot({
next(doc) {
observer.next(doc);