Skip to content

Instantly share code, notes, and snippets.

View alfonmga's full-sized avatar
👁️
What you look for is what you find.

Alfon alfonmga

👁️
What you look for is what you find.
View GitHub Profile
@alfonmga
alfonmga / readme.md
Created March 9, 2024 15:10 — forked from bagusnl/readme.md
Setting up Cloudflare R2 as CDN with HTTP frontend also uploads files from GitHub repository to said CDN with Actions

Setting up Cloudflare R2 as CDN

This guide will set up a CDN with URL frontend and sync them up from GitHub Repo with Actions

Things needed:

  • A domain that is tied to Cloudflare (free CF account is probably enough, depends on the load to your CDN)

Steps:

  1. Make a Cloudflare R2 bucket > Take a note of its bucket name.
@alfonmga
alfonmga / ffmpeg-format-to-mimetype.js
Created June 23, 2022 15:38 — forked from DusanBrejka/ffmpeg-format-to-mimetype.js
FFMPEG - map of formats to default mime types
// INCOMPLETE
// This command will give you list of available FFMPEG formats and their default Mime types
// ffmpeg -formats -hide_banner | tail -n +5 | cut -c5- | cut -d' ' -f1 | xargs -i{} ffmpeg -hide_banner -h demuxer={} | pcregrep -o2 -o4 -M '(Muxer (\w+) )|(Mime type:( .*).)'
// And then parse the output with regex to JSON format in JavaScript for example:
// str.match(/(.*)\n (.*)/gm).map(m => `"${m.replace(/\n /, '": "')}"`).join(',\n');
// Combine the output with MDN - Common MIME types
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
// And with IANA:
@alfonmga
alfonmga / useModals.tsx
Created June 21, 2022 17:03 — forked from statico/useModals.tsx
Chakra UI await-able alert, confirm, and prompt modal dialogs
/*
* Usage:
* const { alert, confirm, prompt } = useModals()
* alert("Hey!") // awaitable too
* if (await confirm("Are you sure?")) ...
* const result = await prompt("Enter a URL", "http://")
*/
import React, {
createContext,
@alfonmga
alfonmga / promisified-grpc-client.ts
Created May 24, 2022 15:37 — forked from smnbbrv/promisified-grpc-client.ts
Promisify @grpc-js service client with typescript
import { Client, ServiceError, Metadata, CallOptions, ClientUnaryCall } from '@grpc/grpc-js';
import { Message } from 'google-protobuf';
type OriginalCall<T, U> = (request: T, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError, res: U) => void) => ClientUnaryCall;
type PromisifiedCall<T, U> = ((request: T, metadata?: Metadata, options?: Partial<CallOptions>) => Promise<U>);
export type Promisified<C> = { $: C; } & {
[prop in Exclude<keyof C, keyof Client>]: (C[prop] extends OriginalCall<infer T, infer U> ? PromisifiedCall<T, U> : never);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CGPDeviceCategory</key>
<string>GamePad</string>
<key>CGPDeviceType</key>
<string>PS3</string>
<key>CGPDisplayNameOvr</key>
<string>DualShock3 Analogue Triggers</string>
@alfonmga
alfonmga / Docker.md
Created November 14, 2021 23:04 — forked from CaryBourgeois/Docker.md
How to set up FaunaDB clusters using the Public Docker image.

How to use the FaunaDB public Docker image.

This document will walk through creating a FaunaDB docker instance using the publicly available docker image. Three different types of deployments will be illustrated.

  • A single node FaunaDB - basic developer functionality.
  • A three node, single replica instance of FaunaDB - scale out operations.
  • A three node, three replicas instance of FaunaDB - distributed operations.

Finally, we will wrap up with some more general documentation around the various options available when using the public docker image.

Requirements

@alfonmga
alfonmga / workflow-install.py
Created April 13, 2021 00:20 — forked from deanishe/workflow-install.py
Script to install/symlink Alfred workflows. Useful for workflow developers.
#!/usr/bin/python
# encoding: utf-8
#
# Copyright (c) 2013 <deanishe@deanishe.net>.
#
# MIT Licence. See http://opensource.org/licenses/MIT
#
# Created on 2013-11-01
#
Name: Flash
Serial: eNrzzU/OLi0odswsqnHLSSzOqDGoca7JKCkpsNLXLy8v1ytJTczVLUotKNFLzs8FAJHYETc=
if anyone wants to thank ETH: 0x527c2aB55b744D6167dc981576318af96ed26676
Thank you!