Skip to content

Instantly share code, notes, and snippets.

View bedekelly's full-sized avatar

Bede Kelly bedekelly

View GitHub Profile
@bedekelly
bedekelly / cleaned_exploit.py
Last active March 2, 2020 10:42
Cleanup in Progress - MS Word Exploit
import sys
import os
import warnings
import zlib
import struct
import random
import shutil
import zipfile
from zipfile import ZipFile
import time
@bedekelly
bedekelly / parallax.js
Last active September 26, 2019 11:29
Quick'n'dirty parallax for a bunch of stacked layers
MAX_TRANSLATE = 6;
const elements = [
"background", "clouds", "back-mountain", "front-mountain",
"hills-4", "hills-3", "hills-2", "hills-1", "birds"
].map(klass => document.querySelector(`.${klass}`));
function updatePositions(height, width) {
const maxVHTranslation = -height * MAX_TRANSLATE;
@bedekelly
bedekelly / nondeterminism.py
Created September 19, 2019 03:55
List monad (+alternative) for nondeterminism in Python
toss = {"Fair": ["Heads", "Tails"], "Biased": ["Heads", "Heads"]}
@do
def coins():
coin = yield ["Fair", "Biased"]
result = yield toss[coin]
_ = yield guard(result == "Heads")
return coin
# Probability of a biased coin, given you observed Heads, is 2/3.
@bedekelly
bedekelly / nondeterminism.hs
Created September 19, 2019 03:39
Haskell Nondeterminism
data CoinType = Fair | Biased deriving (Show)
data Coin = Head | Tail deriving (Eq,Show)
toss Fair = [Head, Tail]
toss Biased = [Head, Head]
pick = [Fair, Biased]
experiment = do
coin <- pick -- Pick a coin at random
@bedekelly
bedekelly / do_notation.py
Created September 18, 2019 10:02
Do Notation using Python's Yield Keyword
from functools import wraps
def do(f):
def partial_run(f, args, kwargs, values_so_far=()):
# First, create a NEW instance of the coroutine.
coroutine = f(*args, **kwargs)
# Advance the coroutine to the first yield point.
yielded_monad = next(coroutine)
@bedekelly
bedekelly / fixedPose.js
Last active April 2, 2019 16:07
Fixed Pose
import React, { useState } from "react";
import posed from "react-pose";
import "./App.css";
const Box = posed.div({
regular: { width: '10vw', height: '10vh', flip: true },
fullscreen: { width: "100vw", height: '100vh', flip: true }
});
@bedekelly
bedekelly / pose.js
Created April 2, 2019 15:45
Broken Pose
import React, { useState } from "react";
import posed from "react-pose";
import "./App.css";
export default function App() {
const [fullscreen, setFullscreen] = useState(false);
const toggle = () => setFullscreen(!fullscreen);
const pose = fullscreen ? 'fullscreen' : 'regular';
@bedekelly
bedekelly / parallaxListeners.js
Created March 31, 2019 15:36
Parallax Event Listeners
document.addEventListener("mousemove", event => {
const height = event.clientY / window.innerHeight;
const width = event.clientX / window.innerWidth;
updatePositions(height, width);
});
window.addEventListener("deviceorientation", event => {
const height = -event.beta / 90;
const width = event.gamma / 180;
@bedekelly
bedekelly / circle.html
Last active March 24, 2019 09:23
Simple circle to use for line-drawing
<svg width="120" height="120" class="ring two">
<circle class="path" cx="60" cy="60"
r="58" stroke="rgb(176, 168, 142)"
stroke-width="2" fill="none" />
</svg>
@bedekelly
bedekelly / circle-drawing.css
Created March 24, 2019 09:18
Animate Drawing a Circle
.ring.two {
stroke-dasharray: calc(2 * 3.1415 * 58);
stroke-dashoffset: calc(2 * 3.1415 * 58);
stroke-dashoffset: -calc(2 * 3.1415 * 58);
transform: rotate(-90deg);
transition: stroke-dashoffset linear 0.5s;
}
.button:hover .ring.two {
stroke-dashoffset: 0;