Skip to content

Instantly share code, notes, and snippets.

View scriptify's full-sized avatar
🏆
Working towards my goals, every day!

Maximilian Torggler scriptify

🏆
Working towards my goals, every day!
View GitHub Profile
@scriptify
scriptify / julius.js
Created May 28, 2019 19:52
Simple Caesar Decryption in JavaScript
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 December 18, 2018 10:06
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…
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();
}