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
@bagusnl
bagusnl / readme.md
Created July 6, 2023 00:56
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.
@smnbbrv
smnbbrv / promisified-grpc-client.ts
Last active November 4, 2023 21:22
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);
}
@rpeshkov
rpeshkov / config.h
Created January 15, 2021 15:39
AnnePro2 QMK layout
#pragma once
#define TAPPING_FORCE_HOLD_PER_KEY
@danielperna84
danielperna84 / README.md
Created December 21, 2020 16:58
Unseal HashiCorp Vault using systemd

Automatically unseal HashiCorp Vault via systemd

WARNING!

Automatically unsealing Vault drastically reduces the security of the stored secrets. That being said, there might be scenarios, in which this simple approach could be useful / sufficient.

How it works / installation

This requires Vault to be started by a systemd-unit named vault.service, which typically is the case when installing from a distribution package. The script vault-unseal.sh should be placed in /root and secured with 700 permissions.

@hizkifw
hizkifw / cloudflare-worker-youtube-dl.js
Last active April 24, 2024 21:03
Download YouTube videos with Cloudflare Worker
/**
* cloudflare-worker-youtube-dl.js
* Get direct links to YouTube videos using Cloudflare Workers.
*
* Usage:
* GET /?v=dQw4w9WgXcQ
* -> Returns a JSON list of supported formats
*
* GET /?v=dQw4w9WgXcQ&f=251
* -> Returns a stream of the specified format ID

Domain Modeling with Tagged Unions in GraphQL, ReasonML, and TypeScript

GraphQL has exploded in popularity since its open-source announcement in 2015. For developers who had spent a lot of time managing data transformations from their back-end infrastructure to match front-end product needs, GraphQL felt like a tremendous step forwards. Gone were the days of hand-writing BFFs to manage problems of over-fetching.

A lot of value proposition arguments around GraphQL have been about over/under fetching, getting the data shape you ask for, etc. But I think GraphQL provides us more than that—it gives us an opportunity to raise the level of abstraction of our domain, and by doing so allow us to write more robust applications that accurately model the problems we face in the real world (changing requirements, one-off issues).

An underappreciated feature of GraphQL is its type system, and in particular features like [union types](https:

@nyze2oo9
nyze2oo9 / index.d.ts
Last active February 15, 2021 03:43
Basic Cloudinary React Prop Types
declare module 'cloudinary-react' {
type CropMode =
| string
| 'scale'
| 'fit'
| 'limit'
| 'mfit'
| 'fill'
| 'lfill'
| 'pad'
@orlandovallejos
orlandovallejos / scrolling.js
Created November 12, 2019 17:37
scrolling helper for react-dnd ^9.4.0
/*------------------------------------------------*/
/* LIBRARIES
/*------------------------------------------------*/
import throttle from 'lodash/throttle';
/*------------------------------------------------*/
/* INTERNAL DEPENDENCIES
/*------------------------------------------------*/
import { MAIN_APP_SIDEBAR_ID } from '../../constants/global';
@StevenACoffman
StevenACoffman / goGetPrivate.md
Last active April 15, 2024 17:01 — forked from dmitshur/gist:6927554
How to `go get` private repos using SSH key auth instead of password auth.

Set GOPRIVATE to match your github organization

Cloning the repo using one of the below techniques should correctly but you may still getting an unrecognized import error.

As it stands for Go v1.13, I found in the doc that we should use the GOPRIVATE variable like so:

GOPRIVATE=github.com/ORGANISATION_OR_USER_NAME go get -u -f github.com/ORGANISATION_OR_USER_NAME/REPO_NAME

The 'go env -w' command (see 'go help env') can be used to set these variables for future go command invocations.

How to go get private repos using SSH key auth instead of password auth.

@bgeesaman
bgeesaman / kphcme.sh
Last active March 21, 2021 00:45
GKE/Kube-proxy host command execution via kubectl exec
#!/usr/bin/env bash
# Credit: https://twitter.com/_fel1x
# poc: https://twitter.com/_fel1x/status/1151487051986087936
# Adapted to GKE/kube-proxy by: https://twitter.com/bradgeesaman
# and to avoid detection by Falco's default rules
read -r -d '' ESCAPE <<'EOF'
#!/bin/sh