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 / 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.
import { Injectable } from '@angular/core';
import * as firebase from 'firebase';
//...omitted
@Injectable()
export class AuthService {
resetPassword(email: string) {
var auth = firebase.auth();
return auth.sendPasswordResetEmail(email)
@codediodeio
codediodeio / index.js
Last active January 23, 2021 17:06
Transactional Email Firebase Cloud Function with Sendgrid
var functions = require('firebase-functions');
const sendgrid = require('sendgrid')
const client = sendgrid("YOUR_SG_API_KEY")
function parseBody(body) {
var helper = sendgrid.mail;
var fromEmail = new helper.Email(body.from);
var toEmail = new helper.Email(body.to);
var subject = body.subject;
import 'package:flutter/material.dart';
Stream<bool> interval =
Stream.periodic(Duration(seconds: 1), (i) => (i % 2 == 0))
.asBroadcastStream();
class Blink extends StatelessWidget {
String text;
Blink({Key key, this.text}) : super(key: key);
@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 / auth.guard.ts
Last active August 28, 2020 02:50
Angular Firebase Router Guard with Browser Refresh
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { AngularFireAuth } from 'angularfire2/auth';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/take';
@Injectable()
export class AuthGuard implements CanActivate {
@codediodeio
codediodeio / index.js
Created July 10, 2017 16:03
Simple Stripe Payments with Firebase Cloud Functions
const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp(functions.config().firebase);
const stripe = require('stripe')(functions.config().stripe.testkey)
exports.stripeCharge = functions.database
@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 / index.js
Created July 17, 2017 17:40
Algolia Firebase Cloud Functions - Update/Delete Items from Index
const functions = require('firebase-functions');
const admin = require("firebase-admin");
admin.initializeApp(functions.config().firebase);
const algoliasearch = require('algoliasearch');
const algolia = algoliasearch(functions.config().algolia.appid, functions.config().algolia.adminkey);
exports.updateIndex = functions.database.ref('/books/{bookId}').onWrite(event => {
@codediodeio
codediodeio / auth.service.ts
Last active January 8, 2020 20:13
Service for Angular4 + Firebase Authentication
import { Injectable } from '@angular/core';
import { AngularFireAuth, AngularFireDatabase, FirebaseAuthState, AuthProviders, AuthMethods, AngularFire } from "angularfire2";
import { Router } from "@angular/router";
import * as firebase from 'firebase';
@Injectable()
export class AuthService {