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
@jakoblorz
jakoblorz / README.md
Created May 17, 2019 16:22
Simple global state without depending on any additonal state manager. Uses and exposes React Hooks.

I used this structure in multiple projects and had a blast using it which is why I want to share it. It automatically propagates state changes to all dependent states and does not require additional state managing packages such as redux or mobx.

It enables architectures where e.g. the navbar is at the same level as all other components while still receiving updates about e.g. current user: If in this example the Index View logs the user in, there will also be a re-render in the navbar as its state has changed. This construction removes the state-silos of each component. Using useState instead of useReflectedState still enables the usage of component-specific state.

import React from "react";
import ReactDOM from "react-dom";
import { BrowserRouter as Router, Route } from "react-router-dom";

import Navbar from "./views/Navbar";
import Index from "./views/Index";
@satori99
satori99 / app.js
Last active April 17, 2024 09:36
This is a proof-of-concept for using ffmpeg as a HTTP video stream proxy that can reduce the volume of ad-breaks
/**
* This is a proof-of-concept for using ffmpeg as a HTTP video stream proxy
* that can reduce ad volume.
*
* It only works on streams containing SCTE35 data packets.
* You can check a stream using:
*
* ffmpeg -hide_banner -i <SOURCE_URL> 2>&1 | grep scte_35
*
* Start the demo:
'use strict';
const puppeteer = require('puppeteer');
(async () => {
/* PRECONDITION:
0. download ublock, I used https://github.com/gorhill/uBlock/releases/download/1.14.19b5/uBlock0.chromium.zip
1. run $PATH_TO_CHROME --user-data-dir=/some/empty/directory --load-extension=/location/of/ublock
2. enable block lists you want to use
*/
@CaryBourgeois
CaryBourgeois / Docker.md
Created October 23, 2018 15:06
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

@gagarine
gagarine / fish_install.md
Last active May 3, 2024 08:11
Install fish shell on macOS Mojave with brew

Installing Fish shell on MacOS (Intel and M1) using brew

Fish is a smart and user-friendly command line (like bash or zsh). This is how you can instal Fish on MacOS and make your default shell.

Note that you need the https://brew.sh/ package manager installed on your machine.

Install Fish

brew install fish

@ModPhoenix
ModPhoenix / axios-interceptors-refresh-token.js
Last active January 30, 2024 07:14
Axios interceptors token refresh for few async requests. ES6
import axios from "axios";
import { settings } from "../settings";
import { authAPI } from ".";
const request = axios.create({
baseURL: settings.apiV1,
});
request.interceptors.request.use(
(config) => {
import ApolloClient from 'apollo-boost';
const client = new ApolloClient({
uri: '<your graphql endpoint>',
// Apollo Boost allows you to specify a custom error link for your client
onError: ({ graphQLErrors, networkError, operation, forward }) => {
if (graphQLErrors) {
for (let err of graphQLErrors) {
// handle errors differently based on its error code
switch (err.extensions.code) {
@leymannx
leymannx / iterm2-oh-my-fish.md
Last active December 31, 2023 16:37
iTerm2 Solarized Dark theme + Fish shell + oh-my-fish /// macOS High Sierra
@yoannmoinet
yoannmoinet / icons.sh
Last active April 25, 2024 00:30
Mac OS X icon.icns
#!/bin/sh
#Usage: ./icons.sh ../assets/media/icon_color_1024.png ../assets/icons
name=$(basename "$1" ".png")
dir=$(cd "$(dirname "$2")"; pwd)/$(basename "$2")
mkdir $dir/$name.iconset
sips -Z 16 --out $dir/$name.iconset/icon_16x16.png $1
sips -Z 32 --out $dir/$name.iconset/icon_16x16@2x.png $1
sips -Z 32 --out $dir/$name.iconset/icon_32x32.png $1
@drewmccormack
drewmccormack / verifyPaddleSignature.swift
Last active March 13, 2021 20:27
How to verify the Paddle webhook signature in Swift 3 using the Vapor packages CTLS and Crypto (include OpenSSL)
/// Verify the signature passed with the Paddle request parameters.
/// Details here: https://paddle.com/docs/reference-verifying-webhooks
func verifyPaddleSignature(inParameters parameters: [String:String]) throws -> Bool {
guard let signatureString = parameters[PaddleParameter.signature.rawValue],
let signature = Data(base64Encoded: signatureString) else {
return false
}
// Need to gather sorted parameters
var signatureParameters = parameters