Skip to content

Instantly share code, notes, and snippets.

View kayode-adechinan's full-sized avatar

Kayode Adechinan kayode-adechinan

  • Dakar, Senegal
View GitHub Profile
@kayode-adechinan
kayode-adechinan / reverse_proxy_view.py
Created April 15, 2024 11:43 — forked from JustinTArthur/reverse_proxy_view.py
A Django 1.4+ view function that acts as a reverse proxy. Great for testing locally or for using as a starting point to code that needs to cache or manipulate the proxied response. If one needs to proxy in production without any response manipulation, performing this in the web container (like nginx or apache) would be recommended instead of thi…
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def reverse_proxy(request):
"""
Reverse proxy for a remote service.
"""
path = request.get_full_path()
#Optionally, rewrite the path to fit whatever service we're proxying to.
@kayode-adechinan
kayode-adechinan / app.py
Created April 15, 2024 11:25 — forked from tombulled/app.py
Stream a file, in this case an mp4 video, supporting range-requests using starlette
from starlette.applications import Starlette
from starlette.responses import StreamingResponse
from starlette.requests import Request
from starlette.routing import Route
from pathlib import Path
from typing import IO, Generator
"""
Stream a file, in this case an mp4 video, supporting range-requests using starlette
@kayode-adechinan
kayode-adechinan / ts-custom-intrinsic-elements.tsx
Created April 7, 2024 17:34 — forked from Magellol/ts-custom-intrinsic-elements.tsx
Override react types to exclusively allow a set of custom intrinsic elements without inheriting from HTML.
// By overriding a subset of the interfaces from the `@types/react` package,
// we're able to strictly type check what our JSX must look like and avoid inheriting from HTML elements (since they're not valid in our environment for instance).
import * as React from 'react';
declare module 'react' {
namespace JSX {
interface ElementChildrenAttribute {
children: {};
}
@kayode-adechinan
kayode-adechinan / golang-tls.md
Created February 22, 2024 11:00 — forked from 6174/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048
    
# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key
@kayode-adechinan
kayode-adechinan / php_form_submit.md
Created April 25, 2023 20:51 — forked from jesperorb/php_form_submit.md
PHP form submitting with fetch + async/await

PHP Form submitting

If we have the following structure in our application:

  • 📁 application_folder_name
    • 📄 index.php
    • 📄 handle_form.php
    • 📄 main.js

And we fill our index.php with the following content just to get a basic website with a form working. You should be able to run this through a php-server of your choice.

@kayode-adechinan
kayode-adechinan / typed-function.ts
Last active December 19, 2022 18:36
how to ensure that the output of a function has the same type of one of the function parameter
import { z, ZodSchema } from 'zod';
function createAdapter<T extends ZodSchema, U extends ZodSchema>(
options: {
input: T;
output: U;
},
fn: (a: z.infer<T>) => Promise<z.infer<U>>
) {
return {
@kayode-adechinan
kayode-adechinan / tailwind-bg-img-overlay.html
Created November 2, 2022 00:52
tailwind background + image cover + overlay
<div className="absolute top-0 h-full w-full bg-cover bg-center" style={{ backgroundImage: "url(\"https://images.unsplash.com/photo-1557804506-669a67965ba0?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1267&q=80\")" }}><span id="blackOverlay" className="absolute h-full w-full bg-black opacity-75" /></div>
// installation
// npm i -D purgecss
// scripts
// "purge": "purgecss --config ./purgecss.config.js",
module.exports = {
content: ["assets/js/*.js", "*.html"],
//content: ["**/*.js", "**/*.html", "**/*.vue"],
css: ["assets/css/style.css"],
const exec = require('child_process').exec;
const fs = require('fs');
const path = require('path');
var pathPrefix = process.argv.slice(2)[0];
// find the styles css file
const files = getAllFiles(`./${pathPrefix}/`, '.css');
let data = [];
@kayode-adechinan
kayode-adechinan / schema.prisma
Created January 28, 2021 22:16 — forked from nmchenry01/schema.prisma
An example Prisma schema for "Prisma vs. TypeORM"
generator client {
provider = "prisma-client-js"
previewFeatures = ["transactionApi"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}