Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Shippin' broken code

Michael Solati MichaelSolati

:shipit:
Shippin' broken code
View GitHub Profile
View possum.sh
#!/usr/bin/env bash
# editorconfig-checker-disable
cat <<EOF
--------------------------------------------------------------------------------
/@@#///////@@/(@//@%/(@.@( @@
@@//////////////////////////////#* @@@
@////@//(///////////@@@@@///@//@/@**//@@(
@///////@///////////////@@@@ ( @,
@MichaelSolati
MichaelSolati / create-njk-extension.js
Created Feb 1, 2022
Takes an 11ty shortcode and lets you load it as a NJK extension
View create-njk-extension.js
/**
* 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
Takes secrets stored in Google Cloud's Secret Manager and save's it into a `.env` file.
View cloud-secrets.js
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 Oct 25, 2020
Node script to upgrade GeoFirestore v3 (and older) docs to GeoFirestore v4
View upgrade-geofirestore.js
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 Sep 14, 2019
Dialogflow Typing Namespace for TS
View dialogflow.d.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 Jan 31, 2019
Using GeoFirestore with Firebase Functions
View index.ts
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}')
View geofirestore-js-issues-55.ts
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 Aug 10, 2016
Angular2-Meteor Observable Service
View posts.service.ts
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