Skip to content

Instantly share code, notes, and snippets.

View aberba's full-sized avatar

Lawrence Aberba aberba

View GitHub Profile
@aberba
aberba / country_state.json
Created February 12, 2024 10:12 — forked from manishtiwari25/country_state.json
List Of Countries With States And Other Useful Information, Updated On 02/01/2024 00:00:05
[
{
"name": "Andorra",
"countryCode": "AD",
"countryCodeAlpha3": "AND",
"phone": "376",
"currency": "EUR",
"stateProvinces": [
{
"name": "Sant Julià de Loria"
@aberba
aberba / README.md
Created January 5, 2024 21:25 — forked from zachshallbetter/README.md
Middleware Examples

Next.js Middleware Examples

This Gist contains a collection of Next.js Middleware examples that demonstrate various use cases and scenarios for enhancing your Next.js applications. Middleware in Next.js allows you to intercept, modify, and control the flow of requests and responses, making it a powerful tool for building robust web applications.

Middleware Examples

  1. Authentication Middleware (authenticationMiddleware.ts):
    • Checks if the user is authenticated based on a session cookie.
    • Redirects unauthenticated users to the login page.
  • Ensures users have the necessary role to access protected routes.
@aberba
aberba / .gitignore
Created December 27, 2023 19:19 — forked from tatsuyasusukida/.gitignore
Node.js Docker Image that can uses FFmpeg
/out.mp4
@aberba
aberba / AesUtil.ts
Created December 1, 2023 21:31 — forked from btxtiger/AesUtil.ts
Node.js - AES Encryption/Decryption with AES-256-GCM using random Initialization Vector + Salt
/**
* Cryptography Functions
*
* Forked from AndiDittrich/AesUtil.js
* https://gist.github.com/AndiDittrich/4629e7db04819244e843
*/
import crypto, { CipherGCM, CipherGCMTypes, DecipherGCM } from 'crypto';
import { Password } from './types';
@aberba
aberba / google-auth.js
Created November 21, 2023 21:01
Google auth snippets
const { OAuth2Client } = require("google-auth-library");
var client = new OAuth2Client(process.env.GOOGLE_CLIENT_ID, "", "");
async function getGoogleUser(token) {
try {
const login = await client.verifyIdToken({
idToken: token,
audience: process.env.GOOGLE_CLIENT_ID,
});
import Link from "next/link";
import styled from "styled-components";
import Row from "@app/layouts/Row";
const StyledPager = styled(Row)`
justify-content: center;
min-width: 200px;
max-width: 400px;
margin: 1em auto 2em auto;
import { PRIMARY, PRIMARY_LIGHT, IRON_GREY } from '@styles/variables/colors'
import React, { useEffect, useRef, useState } from 'react'
import styled from 'styled-components'
const Slider = styled.div`
position: relative;
margin: 16px auto;
width: calc(100% - 12px);
height: 8px;
background: ${PRIMARY_LIGHT};
@aberba
aberba / multiple-range-input.html
Created May 19, 2021 13:59
HTML5 multiple range input
<!-- https://jsfiddle.net/z2ov274f/ -->
<div class="range" id="range">
<input type="range" class="lower" min="0" max="10.5" value="5.0" step="0.5">
<input type="range" class="upper" min="0" max="10.5" value="5.5" step="0.5">
</div>
<div id="lower-val"></div>
<div id="upper-val"></div>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Draft • Decorators</title>
<link rel="stylesheet" href="../../dist/Draft.css" />
</head>
<body>
<div id="target"></div>
<script src="../../node_modules/react/dist/react.js"></script>
@aberba
aberba / RichEditor.js
Created December 30, 2020 22:13 — forked from paulinep/RichEditor.js
Draft js editor with images and videos
import React, {Component} from 'react'
import ReactDOM from 'react-dom';
import { EditorState, RichUtils,Editor, ContentState, DefaultDraftBlockRenderMap, convertFromHTML, getSafeBodyFromHTML, AtomicBlockUtils, CompositeDecorator} from 'draft-js';
import createImagePlugin from "draft-js-image-plugin";
import './rich-editor.scss'
import * as Immutable from "immutable";
import {stateToHTML} from 'draft-js-export-html';
import {InlineStyleControls, BlockStyleControls} from './StyleButton'
import Svg from 'common/Svg';
import createVideoPlugin from 'draft-js-video-plugin';