Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mdestafadilah's full-sized avatar
🧠
I'm an Intuiting Ekstrovert (IE) with B Blood Type.

mDestaFadilah mdestafadilah

🧠
I'm an Intuiting Ekstrovert (IE) with B Blood Type.
View GitHub Profile
@fakhrulhilal
fakhrulhilal / JwtSessionMiddleware.cs
Created June 13, 2023 08:52
ASP.NET core middleware to block JWT token containing blacklisted JTI
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.IdentityModel.Tokens;
/// <summary>
/// Reject JWT token containing blacklisted JTI. The JTI is registered into cache provider to be blacklisted,
@agungsugiarto
agungsugiarto / codeigniter3-cors.md
Last active April 14, 2024 15:00
Dealing with CORS in CodeIgniter 3

1. Add a config file named cors.php in the application/config directory.

<?php

defined('BASEPATH') or exit('No direct script access allowed');

$config = [
    /*
 |--------------------------------------------------------------------------
@AverageMarcus
AverageMarcus / Dockerfile
Created September 2, 2021 08:49
Example multi-arch Dockerfile for Go projects
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.16 as builder
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
WORKDIR /app/
ADD . .
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o yourapplication main.go
@gilsonviana
gilsonviana / react-native-reanimate-more.tsx
Last active May 31, 2021 18:12
React Native + Reanimated + PanGestureHandler + TapGestureHandler
import React, { useState } from 'react';
import { StyleSheet, View, Dimensions } from 'react-native';
import Animated, {
useSharedValue,
useAnimatedGestureHandler,
withSpring,
useAnimatedStyle,
withTiming,
useDerivedValue,
runOnJS
@fasalmbt
fasalmbt / solution.py
Created December 15, 2020 07:40
Generate QR Codes
#QRCode geneartion made easy
import os
import pyqrcode
from PIL import Image
class QRCode(object):
def __init__(self,text):
self.qr_image = self.qr_generator(text)
@nikolasburk
nikolasburk / nextjs-and-prisma.md
Last active July 1, 2023 22:59
Fullstack Apps with Next.js and Prisma (PostgreSQL, MySQL & SQLite)

🚀 Fullstack Apps with Next.js and Prisma

Next.js blurs the lines between client and server. It supports pre-rendering pages at build time (SSG) or request time (SSR). Prisma is the perfect companion if you need to work with a database in a Next.js app.

Here is a list of example apps that are based on Next.js and use Prisma on the server to access data from a database:

✍️ Language 🤖 Server 🔐 Authentication 🔗 URL
TypeScript API Routes Yes (via NextAuth.js) URL
TypeScript API Routes No
@nfantone
nfantone / use-validation-schema.js
Last active December 4, 2023 10:27
Use `yup` with `react-final-form`
import { setIn } from 'final-form';
import { useMemo } from 'react';
/**
* Sets the `innerError.message` in an `errors` object at the key
* defined by `innerError.path`.
* @param {Object} errors The object to set the error in.
* @param {{ path: string, message: string }} innerError A `yup` field error.
* @returns {Object} The result of setting the new error message onto `errors`.
*/
@jordanburke
jordanburke / Upload.tsx
Last active December 29, 2020 22:44
React Simple S3 Uploader
import React, {useState} from "react";
import axios from "axios";
import config from "../config"
const endpoint = config.apiGateway.URL;
export const Upload = () => {
const [file, setFile] = useState<File | undefined>()
@marklchaves
marklchaves / forecast.js
Last active January 23, 2021 10:24
How to read in an environment variable on Netlify using a lambda function.
/**
* This was a proof of concept for me to be able to
* retrieve an API key using a Netlify environment variable
* using this lambda function. I spent a lot of time looking
* for a complete example like this--without any luck.
*
* So, here's a step-by-step of what I did.
*
* 1) For this function to work, define the env variable in
* Netlify > Site > Build & Deploy > Environment > Edit Variables
@manzoorwanijk
manzoorwanijk / yup-with-final-form.js
Last active August 31, 2023 20:16
How to properly use yup validation schema with (React) Final Form?
import * as yup from 'yup';
import { setIn } from 'final-form';
const validationSchema = yup.object({
email: yup.string().email(),
shipping: yup.object({
name: yup.string(),
phone: yup.object({
code: yup.string().matches(/^\+\d+$/i),
number: yup.number().max(10),