Skip to content

Instantly share code, notes, and snippets.

View MichaelSolati's full-sized avatar
:shipit:
Shippin' broken code

Michael Solati MichaelSolati

:shipit:
Shippin' broken code
View GitHub Profile
@MichaelSolati
MichaelSolati / possum.sh
Created September 2, 2022 08:55
possum.sh
#!/usr/bin/env bash
# editorconfig-checker-disable
cat <<EOF
--------------------------------------------------------------------------------
/@@#///////@@/(@//@%/(@.@( @@
@@//////////////////////////////#* @@@
@////@//(///////////@@@@@///@//@/@**//@@(
@///////@///////////////@@@@ ( @,
@MichaelSolati
MichaelSolati / create-njk-extension.js
Created February 1, 2022 19:49
Takes an 11ty shortcode and lets you load it as a NJK extension
/**
* Takes any 11ty shortcode that takes an argument and converts
* it into a NJK extension.
*
* @param {string} name The name of the extension/shortcode
* @param {(...args: any[]) => any} func The code to execute
* @returns {import('nunjucks').Extension} A NJK extension
*/
module.exports = function createNJKExtension(name, func) {
/** @type {import('nunjucks').Extension} */
@MichaelSolati
MichaelSolati / cloud-secrets.js
Last active May 2, 2022 18:10
Takes secrets stored in Google Cloud's Secret Manager and save's it into a `.env` file.
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
const client = new SecretManagerServiceClient();
const cloudSecrets = async () => {
if (!process.env.PROJECT_ID) {
return console.warn(
'No Google Cloud Project ID found, no .env file is being generated.'
);
}
@MichaelSolati
MichaelSolati / upgrade-geofirestore.js
Last active October 25, 2020 18:48
Node script to upgrade GeoFirestore v3 (and older) docs to GeoFirestore v4
const admin = require("firebase-admin");
const { GeoFirestore, GeoCollectionReference } = require("geofirestore");
/**
* Generate new private key by selecting a project from below:
* https://console.firebase.google.com/u/0/project/_/settings/serviceaccounts/adminsdk
*/
const SERVICE_ACCOUNT = require("./serviceAccountKey.json");
/**
* Set the collection to update here.
@MichaelSolati
MichaelSolati / dialogflow.d.ts
Created September 14, 2019 19:24
Dialogflow Typing Namespace for TS
/* tslint:disable:no-import-side-effect no-namespace no-shadowed-variable */
export namespace Dialogflow {
/** The basic card message. Useful for displaying information. */
export interface BasicCard {
/** Optional. The title of the card. */
title?: string;
/** Optional. The subtitle of the card. */
subtitle?: string;
/** Required, unless image is present. The body text of the card. */
formattedText?: string;
@MichaelSolati
MichaelSolati / index.ts
Created January 31, 2019 23:19
Using GeoFirestore with Firebase Functions
import * as admin from 'firebase-admin';
import * as functions from 'firebase-functions';
import { GeoFirestore } from 'geofirestore';
import '@google-cloud/firestore/types/firestore';
admin.initializeApp();
// A simple cloud function that will take any doc created in the geocollection collection and convert it to a geofirestore doc
const onCreate = functions.firestore
.document('geocollection/{uid}')
import * as admin from 'firebase-admin';
import * as gf from 'geofirestore';
import * as yargs from 'yargs';
let db: FirebaseFirestore.Firestore = null;
const argv: yargs.Arguments = yargs.argv;
/**
* Flag to indicate whether function is executing in Cloud Functions or locally
*/
@MichaelSolati
MichaelSolati / posts.service.ts
Created August 10, 2016 11:49
Angular2-Meteor Observable Service
import { Injectable } from '@angular/core';
import { Meteor } from 'meteor/meteor';
import { MeteorComponent } from 'angular2-meteor';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
// Collections
import { Posts } from '/imports/collections/posts/collection';
/**
* @class PostsService