Skip to content

Instantly share code, notes, and snippets.

@anacampesan
anacampesan / modals.html
Created December 5, 2018 15:28
Simple implementation of modals
<html>
<head>
<style>
.modal {
display: none;
}
.modal-open {
display: block;
}
@anacampesan
anacampesan / aliases.sh
Last active November 2, 2018 15:51
Useful aliases/shortcuts
mkcd () { mkdir -p "$1" && cd "$1"; }
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 / 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++) {
<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() {
let animal = {
init: function(name, age) {
this.name = name;
this.age = age;
return this;
},
getName: function() {
return this.name;
},
getAge: function() {
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;
<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">
@anacampesan
anacampesan / user.py
Created November 15, 2017 16:21
OOP in Python
class User:
role = 'user'
def __init__(self, name):
self.name = name
def get_name(self):
print(self.name)
@classmethod
@anacampesan
anacampesan / wit1.py
Last active November 8, 2017 17:02
Wit Free Text
import json
obj = json.loads('{"msg_id":"07kg0Z1uAQMmLN6lM","_text":"i want links to racing and horses","entities":{"links_category":[{"suggested":true,"confidence":0.97013993755778,"value":"racing","type":"value"},{"suggested":true,"confidence":0.94886424860786,"value":"horses","type":"value"}]}}')
entities = obj['entities']
intents = []
for key in entities:
aux = []
for entity in entities[key]: