Skip to content

Instantly share code, notes, and snippets.

@Tuarisa
Tuarisa / server.js
Created December 9, 2023 17:14
Live reload server for static folder
import http from 'node:http';
import fs from 'node:fs';
import path from 'node:path';
import { WebSocketServer } from 'ws';
const connections = new Map();
let currentConnectionNumber = 0
const staticFolder = './dist'
const MIME_TYPES = {
@Tuarisa
Tuarisa / index.js
Created February 10, 2023 21:47
Update content type on all s3 files
const AWS = require('aws-sdk')
const s3 = new AWS.S3({
endpoint: process.env.S3_SPACES_ENDPOINT,
accessKeyId: process.env.S3_SPACES_ACCESS_KEY,
secretAccessKey: process.env.S3_SPACES_SECRET_KEY
})
async function changeContentType() {
// Name of the bucket
// Require puppeteer
const puppeteer = require('puppeteer');
(async () => {
// Create an instance of the chrome browser
// But disable headless mode !
const browser = await puppeteer.launch({
headless: false
});
<?php
function get_menu() {
# Change 'menu' to your own navigation slug.
return wp_get_nav_menu_items('menu');
}
add_action( 'rest_api_init', function () {
register_rest_route( 'custom', '/menu', array(
'methods' => 'GET',
'callback' => 'get_menu',
@Tuarisa
Tuarisa / nuxt-axios-cache.js
Last active October 3, 2021 21:28
Nuxt axios cache plugin
import hash from 'object-hash'
import sizeof from 'object-sizeof'
import lruCache from 'lru-cache'
const cacheEnabled = true
const cacheMaxAge = 30 * 60 * 1000
const cacheMaxSize = 128 * 1000 * 1000
const getCacheKey = obj => hash(obj)
@Tuarisa
Tuarisa / json_extended_fields.php
Created January 2, 2018 19:38
Json Extended Fields for json api
<?php
/*
Plugin Name: Json Extended Fields for json api
Author: Tuarisa
Description: Extends json functionality for wordpress REST API
*/