Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Paratron's full-sized avatar
🧙
Web Wizardry

Christian Engel Paratron

🧙
Web Wizardry
View GitHub Profile
@Paratron
Paratron / agents.md
Last active February 26, 2024 12:28
Social Network Crawler User Agents

#Social Network Crawler User Agents Users can post URLs on a lot of different platforms nowadays. Most of those platforms will send a request to that URL to generate some preview data from it.

These are a couple of user agents I quickly tested out.

##Facebook

facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
@Paratron
Paratron / svelte.txt
Created October 23, 2020 13:20
Svelte + Typescript + SASS
npx create-snowpack-app [NAME] --template @snowpack/app-template-svelte-typescript
npm i -d sass
// ====================================================================
// svelte.config.js
// ====================================================================
const autoPreprocess = require('svelte-preprocess');
module.exports = {
@Paratron
Paratron / eventEmitter.ts
Last active April 22, 2022 13:48
A typed event publish / subscribe system
/**
* Created by Christian Engel (parastudios.de)
* This code is provided as-is and needs to be used at own risk.
*
* v 1.1
*/
type EventCallbackFunction<EventMap, Key extends keyof EventMap> = (data: EventMap[Key]) => void;
type AllEventCallbackFunction<EventMap> = (event: keyof EventMap, data: EventMap[keyof EventMap]) => void;
@Paratron
Paratron / storageHooks.js
Created February 14, 2019 12:24
Enables you to use hooks for localStorage and sessionStorage that even redraw all components when their respective values change.
import React from "react";
let lsBus = {};
let ssBus = {};
/**
* Redraw all components that have a hook to localStorage with the given key.
* @param {string} key
* @param {*} newValue
*/
@Paratron
Paratron / docker-shell.sh
Created February 5, 2019 13:29
Open a shell into a running docker container
docker exec -ti container_id bash
@Paratron
Paratron / openWebsite.lua
Last active October 31, 2021 11:25
A script to open a website from within visionaire
-- Use this script to open a website.
-- Call the function like this:
-- openWebsite("https://example.com")
-- ------------------------------------------------------------
-- Helper function to detect the system type.
-- Returns either "win", "mac" or "linux"
function getOS()
var ws281x = require('rpi-ws281x');
const config = {
leds: 144 * 2,
type: "grb",
brightness: 255
};
function init(){
ws281x.configure(config);
@Paratron
Paratron / objectsEqual.js
Created April 4, 2020 12:17
Function to test if two objects are equal
/**
* This function takes two objects and compares if they have the same
* keys and their keys have the same values assigned, so the objects are
* basically the same.
* @param {object} objA
* @param {object} objB
* @return {boolean}
*/
const objectsEqual = (objA, objB) => {
const objAKeys = Object.keys(objA);
@Paratron
Paratron / cross-processA.js
Created February 4, 2020 06:47
Node cross process communication
// One Process needs to be the host
const ipc = require('node-ipc');
ipc.config.id = 'a-unique-process-name1';
ipc.config.retry = 1500;
ipc.config.silent = true;
ipc.serve(() => ipc.server.on('eventName', message => {
console.log(message);
}));
ipc.server.start();
@Paratron
Paratron / color-log.js
Created May 21, 2019 13:13
This tiny wrapper around chalk enables easy coloring of log messages.
/**
* Chalk powered color log
* =======================
* This module is a wrapper around the chalk package to provide
* simpler log message formatting.
* To switch a color inside your log message, simply use ´X where
* X is one of the color names in the chalkMap below.
*
* Example:
*