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 / example.ts
Last active July 26, 2017 15:21
Composite Key Pattern in Firebase
createData() {
const data = {
name: 'Crane',
family: 'bird',
weight: 10,
endangered: false,
// composite keys
endangered_family: 'false_bird',
@codediodeio
codediodeio / geo-json.ts
Last active November 9, 2021 12:54
A Typescript interface for GeoJSON objects based on rfc7946
export interface IGeometry {
type: string;
coordinates: number[];
}
export interface IGeoJson {
type: string;
geometry: IGeometry;
bbox?: number[];
properties?: any;
@codediodeio
codediodeio / content-box.component.html
Created August 5, 2017 18:00
Animate a div based on scroll position Angular 4.3
<div class="box" [@scrollAnimation]="state">
<img src="https://images.pexels.com/photos/37547/suit-business-man-business-man-37547.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb">
</div>
@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 / longest-substring.js
Created September 4, 2017 23:13
Longest Substring JavaScript - LeetCode Solution
// Given a string, find the length of the longest substring without repeating characters.
// Examples:
// Given "abcabcbb", the answer is "abc", which the length is 3.
// Given "bbbbb", the answer is "b", with the length of 1.
// Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substring, "pwke" is a subsequence and not a substring.
@codediodeio
codediodeio / reverse-int.js
Created September 4, 2017 23:32
Reverse integer and determine overflow in JavaScript - LeetCode solution
/**
* @param {number} x
* @return {number}
*/
var reverse = function(x) {
let a = x.toString().split('')
let num;
if(a[0] == '-') {
let c = a.shift()
num = parseInt(c +a.reverse().join(''))
@codediodeio
codediodeio / index.js
Created September 13, 2017 00:21
Integrate Twilio with Firebase Cloud Functions
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const twilio = require('twilio');
const accountSid = functions.config().twilio.sid
const authToken = functions.config().twilio.token
const client = new twilio(accountSid, authToken);
@State<AppStateModel>({
name: 'app',
defaults: {
hello: '',
}
})
export class AppState {}
@codediodeio
codediodeio / functional-approach.ts
Last active October 4, 2021 04:55
rxfire Ideas
const firestore = firebase.firestore()
const doc$ = (path: string) => {
return Observable.create(observer => {
firestore
.doc(path)
.onSnapshot({
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);