Skip to content

Instantly share code, notes, and snippets.

View tail-call's full-sized avatar
🐚
Conch

Maria tail-call

🐚
Conch
View GitHub Profile
@tail-call
tail-call / serve-zip.py
Created July 15, 2020 02:19
Serve ZIP file contents as a local static website
#!/usr/bin/env python3
import time
from http.server import HTTPServer
from http.server import BaseHTTPRequestHandler
from zipfile import ZipFile
HOST_NAME = 'localhost'
PORT_NUMBER = 8000
source = ZipFile('files.zip', 'r')
@tail-call
tail-call / compress.js
Created July 12, 2020 16:04
Failed attempt at sequence compressor
function add(arr1, arr2) {
return arr1.map((x, i) => x + (arr2[i] || 0));
}
function mult(arr1, arr2) {
return arr1.map((x, i) => x * (arr2[i] || 0));
}
function sum(arr) {
return arr.reduce((acc, x) => acc + x);
[
{
"name" : "Ace",
"gender" : "male",
"image" : "https://dodo.ac/np/images/thumb/4/4f/Ace_PG.png/30px-Ace_PG.png",
"species" : "bird",
"personality" : "jock"
},
{
"personality" : "cranky",
@tail-call
tail-call / theme.html
Created July 12, 2020 15:59
CSS variables theming demo that fits in a tweet
<style>body{--b:#0cf;--f:#fff}.d{--b:#009;--f:#ddd;background: gray}x{display:flex;justify-content:center;background:var(--b)}z{color:var(--f)}</style><x><z>wow demo<button onclick="(o=document.body).className=o.className?'':'d'">+
@tail-call
tail-call / prime.js
Created July 12, 2020 15:56
I wanted a very big sequence of primes but why
const seq1 = [2, 3];
const seq2 = [2, 3, 5];
const seq3 = [5, 7, 11, 13, 17];
const seq4 = [7, 11, 13, 17, 19, 23, 29];
const length = seq1.length * seq2.length * seq3.length * seq4.length;
const p = (seq, i) => seq[i % seq.length];
for (let i = 0; i < length; i++) {
@tail-call
tail-call / removeRulesThatApplyTo.js
Last active June 6, 2020 15:09
Evil CSSStyleSheet manipulations: removing all css rules that apply to a specific element
function removeRulesThatApplyTo(element) {
for (let sheet of [...document.styleSheets]) {
for (let rule of [...sheet.cssRules]) {
if (element.matches(rule.selectorText)) {
sheet.removeRule([...sheet.cssRules].indexOf(rule));
}
}
}
}
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
end
end
end
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<canvas width="790" height="813">M5314
8098 c-16 -11 -69 -61 -119 -109 -79 -77 -97 -90 -150 -104 -68 -19 -113
-56 -151 -124 -13 -24 -24 -56 -24 -72 0 -15 -9 -54 -21 -85 -17 -46 -25
-55 -40 -51 -30 8 -72 -81 -73 -155 -1 -31 -5 -61 -11 -67 -5 -5 -30 -11
@tail-call
tail-call / easy-dictionary-merge.swift
Created January 23, 2020 06:57
Merging dictionaries in Swift easily (JS-like behavior)
import Cocoa
let a: [String: String] = [
"k1": "a1",
"k2": "a2",
"ka": "a3",
]
let b: [String: String] = [
"k1": "b1",
@tail-call
tail-call / worst-idea-ever.js
Created January 20, 2020 06:42
Imagine someone writing a whole app like this
function subtract({ [subtract.minuend]: minuend, [subtract.subtrahend]: subtrahend }) {
return {
[subtract.difference]: minuend - subtrahend
};
}
subtract.minuend = Symbol('subtract.minuend');
subtract.subtrahend = Symbol('subtract.subtrahend');
subtract.difference = Symbol('subtract.difference');