Skip to content

Instantly share code, notes, and snippets.

View jaandrle's full-sized avatar
🚀
Exploring

Jan Andrle jaandrle

🚀
Exploring
View GitHub Profile
@ohhelloana
ohhelloana / speak.js
Last active May 31, 2024 11:27
Speech Recognition bookmarklet - Inspired by the gist made available by kevinlin1 (https://gist.github.com/kevinlin1/a7e644eda177d8b5777eb8f791971cb8) I adapted it to suit my needs and style
javascript:(() => {
const div = document.createElement('div');
div.classList.add("my-notes");
div.style.display = 'none';
div.style.backgroundColor = '#52614B';
div.style.position = 'fixed';
div.style.top = '0';
div.style.zIndex = '999';
div.style.maxWidth = '40rem';
div.style.maxHeight = '30vh';
// Turn all HTML <a> elements into client side router links, no special framework-specific <Link> component necessary!
// Example using the Next.js App Router.
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
function useLinkHandler() {
let router = useRouter();
useEffect(() => {
let onClick = e => {
@lakefox
lakefox / smmry.js
Created June 8, 2023 23:40
Paraphrasing Text without Machine Learning in JavaScript: full tutorial @ decode.sh
function smmry(text) {
var doc = [];
var stoplist = [
"",
"a",
"about",
"above",
"above",
"across",
"after",
@NeKzor
NeKzor / mastodon.js
Created November 9, 2022 16:19
Simple Mastodon bot in 100 lines.
const fetch = require('node-fetch');
const createHiddenField = (obj, fieldName, value) => {
Object.defineProperty(obj, fieldName, {
enumerable: false,
writable: true,
value: value,
});
};
import assert from 'node:assert/strict';
// Extended RegExp mode (flag /x) [1] via a template tag
//
// Quote: “While the x-mode flag can be used in a RegularExpressionLiteral,
// it does not permit the use of LineTerminator in RegularExpressonLiteral.
// For multi-line regular expressions you would need to use the RegExp
// constructor.”
//
// The plan is to include this functionality in re-template-tag [2]. Then
// The actual API is documented at the end of this file
/**
* @see https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
*/
const ansiConstants = {
//----- Attributes -----
Normal: 0,
/*
Functionality – when executed, these lines are copied to the clipboard:
1. The URL of the current web page.
2. The title of the current web page (as originally written)
3. The title of the current web page (converted to sentence case with a crude algorithm)
4. Optionally: The currently selected text (if any).
Installation: Create a bookmark whose URL is the code below (including `javascript:{···}`):
– Tested in Chrome and Safari.
– Both browsers can handle URLs with multiple lines.
@sindresorhus
sindresorhus / esm-package.md
Last active July 25, 2024 04:47
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
function partition(inputArray, callback) {
const result = {};
for (const [indexOfValue, value] of inputArray.entries()) {
const propertyKey = callback(value, indexOfValue);
if (propertyKey === null || propertyKey === '') {
continue;
}
if (!{}.hasOwnProperty.call(result, propertyKey)) {
result[propertyKey] = [];
}
@iamandrewluca
iamandrewluca / bookmarklets.md
Last active June 3, 2024 18:43
Collection of bookmarklets that I use day to day #bookmarklets