Skip to content

Instantly share code, notes, and snippets.

@zanona
zanona / hosting.ts
Last active January 26, 2023 21:52
Update specific files on firebase hosting via a google cloud function
/**
* SOURCE: https://github.com/firebase/firebase-tools/tree/master/scripts/examples/hosting/update-single-file
* THIS IS AN EXPERIMENT OF THE ABOVE THAT COULD BE USED BY ANY CLOUD
* FUNCTION TO UPDATE HOSTING FILES (THINK OF A CMS). THE BENEFITS WOULD BE TO
* RUN THE CLOUD FUNCTION ONLY ONCE, WHILE HAVING THE HOSTING FILES UPDATED AND
* SERVED STATICALLY MUCH FASTER THROUGH A CDN.
*
* Usage:
* import {updateHostingFiles} from './lib/hosting';
* await updateHostingFiles([{path: '/foo.json', data: '{version:2}']);
@zanona
zanona / firebase.json
Created September 1, 2022 09:53
redirect root firebase app hosting to another domain (excludes __/ files for auth)
{
"hosting": {
"public": "./",
"site": "example",
"ignore": ["firebase.json"],
"redirects": [
{
"regex": "^/([^_].*)",
"destination": "https://example.com/:1",
"type": 301
@zanona
zanona / randname.sh
Created April 8, 2022 11:54
shell script random username generator
#!/bin/env sh
# usage: [sep] adds a separator between adjective and noum .ie: randname "-"
# source: https://grammar.yourdictionary.com/parts-of-speech/adjectives/list-of-positive-adjectives.html
# source: https://eslgrammar.org/list-of-nouns/
ADJECTIVES="affectionate agreeable amiable bright charming creative determined diligent diplomatic dynamic energetic friendly funny generous giving gregarious hardworking helpful imaginative kind likable loyal patient polite sincere adept brave capable considerate courageous faithful fearless frank humorous knowledgeable loving marvelous nice optimistic passionate persistent plucky proficient romantic self-confident sensible thoughtful warmhearted willing zestful amazing awesome blithesome excellent fabulous favorable fortuitous gorgeous incredible unique mirthful outstanding perfect philosophical propitious remarkable rousing spectacular splendid stellar stupendous super upbeat stunning wondrous alluring ample bountiful brilliant breathtaking dazzling elegant enchant
@zanona
zanona / sentry-serverless-firebase.ts
Last active April 3, 2024 15:48
Missing Sentry's firebase serverless wrappers
/**
* Temporary wrapper for firebase functions until @sentry/serverless support is implemented
* It currently supports wrapping https, pubsub and firestore handlers.
* usage: https.onRequest(wrap((req, res) => {...}))
*/
import type {Event} from '@sentry/types';
import type {https} from 'firebase-functions';
import type {onRequest, onCall} from 'firebase-functions/lib/providers/https';
import type {ScheduleBuilder} from 'firebase-functions/lib/providers/pubsub';
import type {DocumentBuilder} from 'firebase-functions/lib/providers/firestore';
@zanona
zanona / react-native-android.mk
Last active September 22, 2020 12:06
react-native android development makefile
#FROM=reactnativecommunity/react-native-android
FROM=reactnativeci/android-base
docker-run = @ touch .env && docker run\
--name rn\
--network host\
--privileged\
--volume /dev/bus/usb:/dev/bus/usb\
--volume opt:/opt/android\
--volume npm:/root/.npm/\
@zanona
zanona / tmux-cheatsheet.markdown
Created January 5, 2018 21:24 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@zanona
zanona / webservice-snippets.html
Last active October 23, 2017 16:25
Sanitised web service snippets
<!--
We sometimes just want a nice looking HTML with
the least possible code to embed these bad boys.
No load check, nothing, just honest get to action.
-->
<!-- GOOGLE ANALYTICS -->
<script data-id=google-analytics>
(function() {
@zanona
zanona / obj.js
Last active July 2, 2016 13:24
Get or Set Object based on literal paths
//GET OR SET OBJECTS BASED ON LITERAL PATHS
function obj(base, path, value) {
const getter = typeof value === 'undefined',
nullify = (value === null),
keys = path.split(/[\.\[\]]/).filter((i) => i);
let key,
rBase = base || {};
while ((key = keys.shift())) {
if (keys.length) {
if (getter || nullify) {
@zanona
zanona / nodelist-iteration.js
Created May 20, 2016 12:18 — forked from bendc/nodelist-iteration.js
ES6: Iterating over a NodeList
var elements = document.querySelectorAll("div"),
callback = (el) => { console.log(el); };
// Spread operator
[...elements].forEach(callback);
// Array.from()
Array.from(elements).forEach(callback);
// for...of statement