Skip to content

Instantly share code, notes, and snippets.

@joshdavenport
joshdavenport / tailwind-srcset-sizes.ts
Last active July 5, 2024 04:09
Generate srcset sizes attribute from tailwind screens
/*
The main method here is processTailwindSrcsetSizes. You can generate a sizes attribute using it based on
tailwind style breakpointed sizes referencing your screens, such as:
"100vw md:500px"
"200px lg:100vw"
"200px md:300px xl:600px"
"100vw lg:50vw"
"100vw"
"400px"
@erikyuzwa
erikyuzwa / wordpress-6-2-2-docker-compose.yml
Last active January 20, 2026 17:29
Wordpress 6.2.2 Docker Compose for Local Development
# create a local .env file with the following 4 properties:
#
# MYSQL_DATABASE=<something>
# MYSQL_USER=<something>
# MYSQL_PASSWORD=<something>
# MYSQL_ROOT_PASSWORD=<something>
#
# Note: I have had a LOT of issues working with anything newer then Docker Desktop v4.26.1
# If you're on something newer, then double check against this release.
#
@NachoToast
NachoToast / captcha.php
Created April 27, 2021 06:43
Verify a recaptcha v3 token.
<?php
function verify_captcha($token) {
$threshold = 0.5; // Score must be > threshold to pass captcha.
// Default is 0.5, although the majority of users will get 0.9
$sites = ["localhost", "nachotoast.com", "ntgc.ddns.net"]; // Site names string, e.g. sub.domain.com:8080
$secret = "Put your client secret here.";
$url = "https://www.google.com/recaptcha/api/siteverify";
$data = array("secret" => $secret, "response" => $token);
@tamagosante
tamagosante / file-mime-types.ts
Last active November 13, 2024 06:32
Typescript Enum for file mime types
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
enum MimeTypes {
".aac" = "audio/aac",
".abw" = "application/x-abiword",
".arc" = "application/x-freearc",
".avi" = "video/x-msvideo",
".azw" = "application/vnd.amazon.ebook",
".bin" = "application/octet-stream",
".bmp" = "image/bmp",
@cuongnguyen32199
cuongnguyen32199 / ubuntu-software-setup.md
Last active September 27, 2022 03:04
Setting Ubuntu 18.04 LTS (Environment and Software)

Setup environment and software

Install vim

sudo apt-get update
sudo apt-get install vim

Install cURL:

@ChaoLiangSuper
ChaoLiangSuper / encryption.ts
Last active March 24, 2024 14:30 — forked from vlucas/encryption.ts
Stronger Encryption and Decryption in typescript
import crypto from 'crypto';
const ALGORITHM = 'aes-256-cbc';
const ENCODING = 'hex';
const IV_LENGTH = 16;
const KEY = process.env.ENCRYPTION_KEY!;
export const encrypt = (data: string) => {
const iv = crypto.randomBytes(IV_LENGTH);
const cipher = crypto.createCipheriv(ALGORITHM, new Buffer(KEY), iv);
@Asjas
Asjas / nginx.conf
Last active November 1, 2025 22:19
Nginx sample config. Includes CSP headers, caching headers, gzip and brotli compression
user www-data;
worker_processes auto;
worker_rlimit_nofile 8192;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 8000;
}
@qoomon
qoomon / conventional-commits-cheatsheet.md
Last active March 17, 2026 07:11
Conventional Commits Cheatsheet
@ambroisemaupate
ambroisemaupate / security.conf
Last active December 10, 2025 14:11
Nginx CSP example
# config to don't allow the browser to render the page inside an frame or iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
# https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
add_header X-Frame-Options SAMEORIGIN;
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
# to disable content-type sniffing on some browsers.
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers
# currently suppoorted in IE > 8 http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],