Skip to content

Instantly share code, notes, and snippets.

Avatar
🏆
Working towards my goals, every day!

Maximilian Torggler scriptify

🏆
Working towards my goals, every day!
View GitHub Profile
View derived-field.tsx
import React from "react";
import { CmsEditorFieldTypePlugin } from "@webiny/app-headless-cms/types";
import { Grid, Cell } from "@webiny/ui/Grid";
import { Typography } from "@webiny/ui/Typography";
import { Select } from "@webiny/ui/Select";
import { Input } from "@webiny/ui/Input";
import { i18n } from "@webiny/app/i18n";
const t = i18n.ns("app-headless-cms/admin/fields");
import { ReactComponent as TextIcon } from "./round-text_fields-24px.svg";
View derived-field-renderer.tsx
import React from "react";
import { CmsEditorFieldTypePlugin } from "@webiny/app-headless-cms/types";
import { Grid, Cell } from "@webiny/ui/Grid";
import { Typography } from "@webiny/ui/Typography";
import { Select } from "@webiny/ui/Select";
import { Input } from "@webiny/ui/Input";
import { i18n } from "@webiny/app/i18n";
const t = i18n.ns("app-headless-cms/admin/fields");
import { ReactComponent as TextIcon } from "./round-text_fields-24px.svg";
@scriptify
scriptify / Statikk Yo
Created Jan 18, 2020
You know what it is
View Statikk Yo
/** Play around and try to convert a website into re-usable React components */
// Code from https://github.com/scriptify/statikk-converter/
(() => {
const $ = document.querySelectorAll.bind(document);
function extractElements() {
const allElements = $('body *');
const allStatikkElements = [];
for (const elem of allElements) {
allStatikkElements.push(domToStatikk(elem));
@scriptify
scriptify / not-that-noble.js
Created Oct 26, 2019
If you find out what it's doing, it can be pretty useful...
View not-that-noble.js
const audioCtx = new (window.AudioContext || window.webkitAudioContext || window.audioContext);
function beep(duration, frequency, volume, type, callback) {
const oscillator = audioCtx.createOscillator();
const gainNode = audioCtx.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioCtx.destination);
@scriptify
scriptify / volume-calculation.js
Created Oct 16, 2019
Potree Volume Calculation
View volume-calculation.js
const defaultArea = [
{ x: 1.51, y: 0, z: -1.98 },
{ x: -0.17, y: 0, z: -1.96 },
{ x: -0.06, y: 0, z: 0.06 },
{ x: 1.36, y: 0, z: 0.73 }
];
//determinant of matrix a
function det(a) {
return (
@scriptify
scriptify / translate.js
Last active Sep 7, 2021
Go to https://www.deepl.com, paste this code into your browser console, and execute "translateAll" with a key-value object as the first param.
View translate.js
function waitUntilValueChanges(domElem) {
return new Promise(resolve => {
let prevVal = domElem.value;
const inter = setInterval(() => {
if (domElem.value !== prevVal) {
clearInterval(inter);
return resolve();
}
prevVal = domElem.value + '';
}, 100);
@scriptify
scriptify / AreaCalculation.js
Created Sep 20, 2019
Calculates the area of a polygon in 3D space
View AreaCalculation.js
//determinant of matrix a
function det(a) {
return (
a[0][0] * a[1][1] * a[2][2] +
a[0][1] * a[1][2] * a[2][0] +
a[0][2] * a[1][0] * a[2][1] -
a[0][2] * a[1][1] * a[2][0] -
a[0][1] * a[1][0] * a[2][2] -
a[0][0] * a[1][2] * a[2][1]
);
@scriptify
scriptify / julius.js
Created May 28, 2019
Simple Caesar Decryption in JavaScript
View julius.js
function caesar(str, increment) {
const letters = 'abcdefghijklmnopqrstuvwxyz';
return str
.toLowerCase()
.split('')
.map(c => {
const index = letters.indexOf(c);
if (index === -1) return c;
let newIndex = index + increment;
if (newIndex < 0) {
@scriptify
scriptify / schroedinger.js
Last active Dec 18, 2018
If you don't debug the function using console.log, it throws an unexpected error. But as soon as you want to debug it, it works like a charm (I recently had an occurence like this, and instead of fixing the bug, I needed to create this gist as a joke). "Works" for every global function you create in the browser. Just copy and paste this code int…
View schroedinger.js
function notFunny() {
function s(fn = () => {}) {
return () => {
const fnStr = fn.toString();
console.log(fnStr);
const keywords = ['console', 'debugger'];
if (!keywords.find(key => fnStr.includes(key)))
throw new Error(`Uncaught ReferenceError: ${fn.toString().slice(0, 10)} is not defined`);
fn();
}