Skip to content

Instantly share code, notes, and snippets.

@FranciscoG
FranciscoG / acf_repeater_shortcode.php
Last active April 18, 2024 00:00
An Advanced Custom Fields shortcode that allows to loop through a field with a repeater. This only handles simple cases, it can't handle nested repeater fields
<?php
/**
* ACF Pro repeater field shortcode
*
* I created this shortcode function because it didn't exist and it was being requested by others
* I originally posted it here: https://support.advancedcustomfields.com/forums/topic/repeater-field-shortcode/
*
* @attr {string} field - (Required) the name of the field that contains a repeater sub group
* @attr {string} sub_fields - (Required) a comma separated list of sub field names that are part of the field repeater group
* @attr {string} post_id - (Optional) Specific post ID where your value was entered. Defaults to current post ID (not required). This can also be options / taxonomies / users / etc
@FranciscoG
FranciscoG / convert.sh
Last active January 17, 2024 16:04
Convert Video to Image sequence using ffmpeg
ffmpeg -i input.mov -r 0.25 output_%04d.png
# -i followed by video file sets input stream
# -r set framerat. 1 = 1 frame per second.
# and then set the output file with the number replacement
# more info: https://ffmpeg.org/ffmpeg.html#Main-options
# https://superuser.com/questions/135117/how-to-convert-video-to-images
(function (turntable) {
const modal = `
<div class='playlistFeatures'>
<p>Deep-Cut to Queup exporter</p>
<button type="button" class='exportPlaylist'>Export Playlist: <span id="exporting-playlist"></span></button>
<hr />
<p>Experimental: Export all playlists at once</p>
<p>Warning: this can be slow and will lock up the UI while processing, do not do this if you are DJ-ing</p>
<button type="button" class='exportPlaylistAll'>Export All Playlists</button>
<div id="pluginTT-loading">
@FranciscoG
FranciscoG / deno-check-permissions.md
Last active April 8, 2023 16:12
A small Deno script that enforces some stricter security in your project

Place this script at the very top of your entry file so that you can enfore that you are always using an allow-list for each of the permission flags deno provides.

it will exit with error code 1 if:

  • you use --allow-all
  • if you use any flag without providing a list: --allow-write instead of --allow-write=./tmp
  • you use --allow-hrtime

hrtime - This one does not use a list but I've included it because Deno's documentation states that "High-resolution time can be used in timing attacks and fingerprinting".

This script was written for Deno's permissions as of version v1.32.3.

@FranciscoG
FranciscoG / FetchError.ts
Last active March 28, 2023 02:58
Wrapping native Fetch to make it mimic Axios
/**
* An extended Error similar to Axios where it includes some of the response information in the error object
* Response type info: https://developer.mozilla.org/en-US/docs/Web/API/Response
*/
export class FetchError extends Error {
response: {
status: Response["status"];
statusText: Response["statusText"];
headers: Response["headers"];
type: Response["type"];
// create a new bookmark and paste this into the url
javascript:(function(){window.location.href=window.location.href.replace('//www.reddit','//old.reddit')})();
@FranciscoG
FranciscoG / README.md
Last active August 30, 2022 18:35
Hacker News - open both links at the same time

This snippet inserts a button into the row of actionable links under each submission that allows a user to open both the submission and the comments in one click

WARNING

Since this opens up 2 tabs from one click, you'll need to grant the site popup permissions.

@FranciscoG
FranciscoG / README.md
Last active May 20, 2022 17:23
Turntable.fm resize chat

Turntable.fm resize chat

If you just want to set the size once, you can use the CSS file below and change the values to your preference. You can use the turnStyles extension to insert the CSS

If you want to be able to resize the chat panel width and font size, use the JS file below and copy paste it into the inspector console

view demo

of add a bookmark with the following js code:

@FranciscoG
FranciscoG / specialChar.js
Last active May 4, 2022 09:20
a collection of mini functions that return special characters from their character codes in Javascript
/* Special Characters */
// <
// less-than sign
export const lt = () => String.fromCharCode(60);
// >
// greater-than sign
export const gt = () => String.fromCharCode(62);
// "
@FranciscoG
FranciscoG / my-cheatsheet.md
Last active October 29, 2021 14:42
bash and other terminal related things (heavily MacOS leaning)