Skip to content

Instantly share code, notes, and snippets.


Kayode Adechinan kayode-adechinan

  • Dakar, Senegal
View GitHub Profile
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
View typed-function.ts
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 / tailwind-bg-img-overlay.html
Created November 2, 2022 00:52
tailwind background + image cover + overlay
View tailwind-bg-img-overlay.html
<div className="absolute top-0 h-full w-full bg-cover bg-center" style={{ backgroundImage: "url(\"\")" }}><span id="blackOverlay" className="absolute h-full w-full bg-black opacity-75" /></div>
View mypurgecss.js
// 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"],
View purgecss.js
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 / schema.prisma
Created January 28, 2021 22:16 — forked from nmchenry01/schema.prisma
An example Prisma schema for "Prisma vs. TypeORM"
View schema.prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["transactionApi"]
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
View replace add to card by whatsapp
// The custom replacement button function
function custom_product_button(){
// HERE your custom button text and link
$button_text = __( "WhatSapp", "woocommerce" );
$button_link = "";
// Display button
echo '<a class="button" target="_blank" href="'.$button_link.'">' . $button_text . '</a>';
kayode-adechinan /
Created April 17, 2020 12:51 — forked from AtulKsol/
Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)

psql: FATAL: Peer authentication failed for user “postgres” (or any user)

The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).

If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.

But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:




import React, { Component } from "react";
import axios from "axios";

class Row extends Component {
  render() {
    return (
View nextjs_load_external_js.jsx
const loadDynamicScript = (src, callback) => {
const existingScript = document.getElementById('scriptId');
if (!existingScript) {
const script = document.createElement('script');
script.src = src; // URL for the third-party library being loaded.
// = 'libraryName'; // e.g., googleMaps or stripe
script.onload = () => {
View nextjs_auth_login.jsx
// login.jsx
import React, { Component } from "react";
import cookie from 'js-cookie'
import Router from 'next/router'
export default class Login extends Component {