Skip to content

Instantly share code, notes, and snippets.

@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
View deno-check-permissions.md

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
View FetchError.ts
/**
* 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"];
View old-reddit.js
// 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
View README.md

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
View README.md

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 / custom-keys-directive.js
Last active May 28, 2020 21:05
Vue custom directive that only allows certain keys to be typed into an element that accepts keyboard input
View custom-keys-directive.js
/**
* `v-kesAllowed` directive
*
* This works by blocking keys during onKeyDown by using a whitelist regex and
* testing `event.key`
*/
/**
* these keys should be allowed in all cases because they handle traversing and a11y
*/
@FranciscoG
FranciscoG / adbrecord.sh
Last active December 13, 2019 19:52
Using adb to create screen recordings of all plugged in Android devices
View adbrecord.sh
#!/bin/bash
# TODO:
# - add option to change the time limit
# - add option to change the output folder
# - add option to delete recordings on device once they have been pulled
# - figure out how to kill script when everything is done
# how many seconds to record for
LIMIT=5
@FranciscoG
FranciscoG / convert.sh
Last active May 9, 2023 08:12
Convert Video to Image sequence using ffmpeg
View convert.sh
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
@FranciscoG
FranciscoG / scrollIt.js
Created November 6, 2018 18:57
Vanilla JS scroll window to an element
View scrollIt.js
/**
* Source: https://pawelgrzybek.com/page-scroll-in-vanilla-javascript/
*/
function scrollIt(destination, duration = 200, easing = 'linear', callback) {
const easings = {
linear(t) {
return t;
},
View mb-explanation.md