Skip to content

Instantly share code, notes, and snippets.

View vanling's full-sized avatar
💚
Nuxt

Ling vanling

💚
Nuxt
View GitHub Profile
@workatease
workatease / index.js
Last active November 24, 2022 12:37
directus - Google reCaptcha v2 using auth.login.before api hook for validation for custom login
// extensions/hooks/google-recaptcha-v2/index.js
module.exports = function registerHook({ env, exceptions }) {
const querystring = require("querystring");
const axios = require("axios");
const { BaseException } = exceptions;
const VERIFY_ENDPOINT = "https://www.google.com/recaptcha/api/siteverify";
return {
"auth.login.before": async function (input) {
const captcha = input["g-recaptcha-response"];
if (captcha) {
@re2005
re2005 / validators.js
Last active February 6, 2024 10:45
Regular expression for common validators | alpha, date, kvk number, iban, zicode (NL)
const regexps = {
alpha: '[a-zA-Z .-]+',
alphaNumeric: '[a-zA-Z0-9À-ü ,.\'-]+',
sameChars: /^(?!.*(.)\1\1+)/i,
date: /^(?:(?:(?:[0]?[1-9]|1[0-9]|2[0-8])-(?:(0)?[1-9]|1[0-2])|(?:29|30)-(?:(0)?[13-9]|1[0-2])|31-(?:(0)?[13578]|1[02]))-[1-9]\d{3}|29-(0)?2-(?:[1-9]\d(?:0[48]|[2468][048]|[13579][26])|(?:[2468][048]|[13579][26])00))$/,
kvkNumber: /^[0-9]{8}$/,
btwNumber: /^[A-Za-z]{2}[0-9]{9}[A-Za-z][0-9]{2}$/,
phoneMobile: /(^(\(?(0031|0|\+31)\)?){1})( ?-?(6){1}\)?)(( ?|-)?[1-9]( ?|-)?){1}(( ?|-)?[0-9]( ?|-)?){7}$/,
phoneFixedThreeDigits: /(^(\(?(0031|0|\+31)\)?){1})( ?-?([0-9]){3}\)?)(( ?|-)?[0-9]( ?|-)?){6}$/,
phoneFixedFourDigits: /(^(\(?(0031|0|\+31)\)?){1})( ?-?([0-9]){2}\)?)(( ?|-)?[0-9]( ?|-)?){7}$/,
@ikennaokpala
ikennaokpala / README.md
Last active January 31, 2025 09:32 — forked from magnetikonline/README.md
Setting Nginx FastCGI response buffer sizes.

Nginx FastCGI response buffer sizes

By default when Nginx starts receiving a response from a FastCGI backend (such as PHP-FPM) it will buffer the response in memory before delivering it to the client. Any response larger than the set buffer size is saved to a temporary file on disk. This process is also explained at the Nginx ngx_http_fastcgi_module page document page.

Since disk is slow and memory is fast the aim is to get as many FastCGI responses passing through memory only. On the flip side we don't want to set an excessively large buffer as they are created and sized on a per request basis (i.e. it's not shared memory).

The related Nginx options are:

@polster
polster / readme.md
Last active May 15, 2023 13:53
How to build latest Git Tag on Jenkins

Build latest Git Tag on Jenkins

Build all tags

  1. Add the following refspec to the Git plugin:
+refs/tags/*:refs/remotes/origin/tags/*
  1. Add the following branch specifier: