Skip to content

Instantly share code, notes, and snippets.

async function getQuote() {
let response = await fetch(
"https://api.chucknorris.io/jokes/random"
);
let data = await response.json();
return data;
}
@jbidoret
jbidoret / removebg.py
Last active October 5, 2022 11:09
Utility to remove the white rectangle that browsers add to any pdf generated via print method
#!/usr/bin/python3
# Utility to remove (in fact, resize) the white rectangle that browsers add to any pdf generated via print method
# Usage :
# python removebg.py browser_generated_file.pdf
# Depends on QPDF https://qpdf.readthedocs.io/
# https://tex.stackexchange.com/questions/50069/how-to-change-white-background-of-an-included-pdf-to-transparent
@jbidoret
jbidoret / removebg.py
Created August 11, 2022 19:18
Remove (white) background from pdfs generated by browsers
#!/usr/bin/python3
# https://tex.stackexchange.com/questions/50069/how-to-change-white-background-of-an-included-pdf-to-transparent
# use :
# python3 removebg.py filewithbackground.pdf
# the script is not smart at all : it resizes every “full page” element that is a background
import os
import sys
class FluxFixer extends Paged.Handler {
constructor(chunker, polisher, caller) {
super(chunker, polisher, caller);
this.styleSheet = polisher.styleSheet;
this.fluxRules = [];
// this.fluxRulesSelectors = [];
// this.fluxRulesStyles = [];
}
onRule(ruleNode){
@jbidoret
jbidoret / randomvar.py
Created September 18, 2021 14:42
Random CSS font variations
#!/usr/bin/python3
#-*- coding: utf-8 -*-
# imports
import random
with open('vars.css', 'w') as f:
for i in range(90):
for j in range(6):
wdth = random.randint(0, 1000)
@jbidoret
jbidoret / dropCap.php
Created September 17, 2021 06:33
Simple drop cap (aka lettrine) regex in php
<?php
/*
input : <p>« L’apostrophe.</p>
output: <p><span class="first-char">« </span><span class="first-letter">L’</span>apostrophe.</p>
*/
function dropCap($p){
$search = '^<p>([\W]*)([\w])([’]?)(.+)*<\/p>';
$replacement = '<p><span class="first-char">\\1</span><span class="first-letter">\\2\\3</span>\\4</p>';
$new = mb_ereg_replace( $search, $replacement, $p);
return $new;
@jbidoret
jbidoret / gist:bbb86ebb3ab74ae0935811cfe7e49e0f
Created May 3, 2016 01:49
Vérifier la valeur d’un champ
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>GAME</title>
<style type="text/css">
* { margin:0; padding: 0;}
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
codebase="http://www.apple.com/qtactivex/qtplugin.cab"
width="200" height="16">
<param name="src" value="movie.mov" />
<param name="autoplay" value="true" />
<param name="pluginspage" value="http://www.apple.com/quicktime/download/" />
<param name="controller" value="true" />
<!--[if !IE]> <-->
<object data="movie.mov" width="200" height="16" type="video/quicktime">
<param name="pluginurl" value="http://www.apple.com/quicktime/download/" />
<video width="640" height="360" controls="controls">
<source src="__VIDEO__.MP4" type="video/mp4" />
<source src="__VIDEO__.OGV" type="video/ogg" />
<object width="640" height="360" type="application/x-shockwave-flash" data="__FLASH__.SWF">
<param name="movie" value="__FLASH__.SWF" />
<param name="wmode" value="transparent" />
<param name="flashvars" value="controlbar=over&amp;image=__POSTER__.JPG&amp;file=__VIDEO__.MP4" />
<img src="__VIDEO__.JPG" width="640" height="360" alt="__TITLE__" title="No video…" />
</object>
</video>
<iframe src="http://player.vimeo.com/video/8981918?title=0&amp;byline=0&amp;portrait=0&amp;badge=0&amp;color=ffffff&autoplay=true&amp;loop=true&amp;control=false"></iframe>
<div id="container">—</div>