Skip to content

Instantly share code, notes, and snippets.

@jacoduplessis
jacoduplessis / pdf.js
Created October 1, 2016 01:36
Create PDF including SVGs
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Gradient</title>
<style type="text/css">
.quadrant-text {
text-anchor: middle;
font-weight: 600;
import subprocess
import sys
"""
get single frame at specific time
=================================
ffmpeg -i "input.mp4" -ss <time> -vframes 1 single.png
get file length in seconds
@jacoduplessis
jacoduplessis / polyfills.html
Last active September 6, 2018 12:15
Load Promise and Fetch polyfills conditionally (updated 8 Jan 2016)
<script>
window.Promise || document.write('<script src="https://unpkg.com/es6-promise@4.0.5/dist/es6-promise.min.js"><\/script>');
window.fetch || document.write('<script src="https://unpkg.com/whatwg-fetch@1.1.1/fetch.js"><\/script>');
</script>
@jacoduplessis
jacoduplessis / decrypt.sh
Created February 5, 2017 14:16
Decrypt cloudron backup
openssl aes-256-cbc -d -in app_b6666e9-76b3-4b36-b2e2-06da1a4efga4_2000-02-04-190024-556_v0.4.5.tar.gz -out decrypted.tar.gz
@jacoduplessis
jacoduplessis / video.md
Last active May 5, 2022 21:56
How to create an image slideshow with images from different devices and of different formats, both image and landscape, using ffmpeg, exiftool and imagemagick
  1. Use exiftool to sort according to exif data (apt-get install exiftool)
exiftool "-FileName<DateTimeOriginal" -d "sorted/%Y%m%d_%H%M%S.%%e" .
  1. Rotate and resize
mogrify * -auto-orient -resize 1920x1080
@jacoduplessis
jacoduplessis / ngrok.py
Created May 31, 2017 15:48
Management command to set Django Site 1 domain to ngrok public url. In an app, add this file under `/management/commands/` as `ngrok.py`. Remember the `__init__.py` files. Run with `python manage.py ngrok`.
import json
from urllib.request import urlopen
from django.contrib.sites.models import Site
from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
help = 'Sets site domain to ngrok url and update telegram bot webhook'
import multiprocessing
import subprocess
import json
with open('json/__all__.json', 'r') as index:
birds = json.loads(index.read())
def screenshot(slug):
subprocess.run([
'google-chrome-unstable',
@jacoduplessis
jacoduplessis / index.js
Created September 16, 2017 13:07
Async Batch Processing
// just a function to simulate IO
function getDouble(n) {
const time = Math.floor(Math.random() * 10 * 1000)
return new Promise((resolve) => {
setTimeout(function() {
console.log(n*2)
resolve(n*2)
}, time)
})
}
@jacoduplessis
jacoduplessis / build.sh
Created June 8, 2018 18:42
Compile libvips for use with h2non/bimg
#!/bin/bash
apt-get install automake build-essential gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg-dev libpng12-dev libwebp-dev libtiff5-dev libexif-dev libgsf-1-dev liblcms2-dev libxml2-dev swig libmagickcore-dev curl
LIBVIPS_VERSION=8.6.3
cd /tmp
curl -OL https://github.com/jcupitt/libvips/releases/download/v${LIBVIPS_VERSION}/vips-${LIBVIPS_VERSION}.tar.gz
tar zvxf vips-${LIBVIPS_VERSION}.tar.gz
cd /tmp/vips-${LIBVIPS_VERSION}
@jacoduplessis
jacoduplessis / remove-mac.sh
Last active June 9, 2018 18:23
Remove mac files
find . -name "*.DS_Store" -delete
find . -name "*._*" -delete