Skip to content

Instantly share code, notes, and snippets.

View anacampesan's full-sized avatar
🏡
WFH

Ana Campesan anacampesan

🏡
WFH
View GitHub Profile
<html>
<body>
<!-- Add a placeholder for the Twitch embed -->
<div id="twitch-embed"></div>
<!-- Load the Twitch embed script -->
<script src="https://embed.twitch.tv/embed/v1.js"></script>
<!-- Create a Twitch.Embed object that will render within the "twitch-embed" root element. -->
<script type="text/javascript">
let img = new Image();
img.onload = function() {
let canvas = document.createElement('canvas');
let ctx = canvas.getContext('2d');
canvas.width = img.width;
canvas.height = img.height;
canvas.width = img.height;
canvas.height = img.width;
let animal = {
init: function(name, age) {
this.name = name;
this.age = age;
return this;
},
getName: function() {
return this.name;
},
getAge: function() {
<html>
<body>
<script>
let fps = 15;
let now, then = Date.now();
let first = then;
let interval = 1000 / fps; // 1000ms (1s) / fps
let diff, counter = 0;
(function draw() {
@anacampesan
anacampesan / gifFrameDisposal.js
Last active April 24, 2023 12:02
GIF Frame Disposal Correction Algorithm
function explodeGif(gifUrl) {
return gifler(gifUrl)._animatorPromise.then(function(gif) {
let current = createTempCanvas(gif.width, gif.height, 'current');
let currentCtx = current.getContext('2d');
let temp = createTempCanvas(gif.width, gif.height, 'temp');
let tempCtx = temp.getContext('2d');
gif._animationLength = 0;
for (let i = 0; i < gif._frames.length; i++) {
ffmpeg -r 1000/100 -f image2 -i img-%d.png -i ov.gif -filter_complex "[0:v][1:v]overlay=0:0" out.gif
// -r 1000 / fps
// -f image2 = list of image inputs matching the pattern
@anacampesan
anacampesan / aliases.sh
Last active November 2, 2018 15:51
Useful aliases/shortcuts
mkcd () { mkdir -p "$1" && cd "$1"; }
@anacampesan
anacampesan / modals.html
Created December 5, 2018 15:28
Simple implementation of modals
<html>
<head>
<style>
.modal {
display: none;
}
.modal-open {
display: block;
}
.myDiv {
border: 2px solid beige;
border-image: linear-gradient(to top, beige 95%, rgba(0,0,0,0) 95%); /* Change direction, color and height accordingly */
border-image-slice: 1;
}
function elementIsVisible(el) {
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
var elTop = $(el).offset().top;
var elBottom = elTop + $(el).height();
return ((elBottom - $(el).height() <= docViewBottom)
&& (elTop + $(el).height() >= docViewTop));
}