Skip to content

Instantly share code, notes, and snippets.

View Krazete's full-sized avatar
💭
Perpetually behind on every project.

Ted Michael Celis Krazete

💭
Perpetually behind on every project.
View GitHub Profile
@Krazete
Krazete / force_controls.js
Created April 9, 2019 07:34
Force-Enable Video Controls
function forceControls () {
Array.from(document.getElementsByTagName("video")).forEach(video => {
video.setAttribute("controls", "true");
video.style.zIndex = "9999";
});
requestAnimationFrame(forceControls);
}
forceControls();
@Krazete
Krazete / pixiv_download.js
Last active November 17, 2018 21:46
Download Pixiv Canvas-Based Animated Images and Generate its Sprite Sheet
var xhr = new XMLHttpRequest();
xhr.open("GET", pixiv.context.ugokuIllustData.src, true);
xhr.responseType = "blob";
xhr.onload = function() {
var blob = this.response;
var a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.setAttribute("download", "compressed.zip");
a.click();
console.log(blob);
@Krazete
Krazete / cdf2pmf.js
Created November 30, 2017 01:27
convert cs122a midterm CDF to PMF
var cdf = [1, 1, 1, 1, 1, 1, 4, 5, 11, 21, 34, 56, 84, 126, 181, 226, 261, 294, 305, 311, 312];
var pdf = cdf.slice(0, 1).concat(cdf.map((e, i) => e - cdf[i - 1]).slice(1));
var max = pdf.reduce((a, b) => Math.max(a, b));
var log = "";
for (let r = 0; r <= max; r++) {
for (let c = 0; c < pdf.length; c++) {
var y = max - pdf[c];
if (y < r) {
log += "|++++| ";
}