Skip to content

Instantly share code, notes, and snippets.

View bblanchon's full-sized avatar
🌟
No more counting dollars we’ll be counting stars

Benoît Blanchon bblanchon

🌟
No more counting dollars we’ll be counting stars
View GitHub Profile
@bblanchon
bblanchon / slideshow.sh
Created February 16, 2021 21:05
GIF Slideshow with ImageMagick
magick \
\( -delay 100 image-00.png \) \
\( -delay 10 image-00.png image-01.png -morph 3 -delete 0 \) \
\( -delay 100 image-01.png \) \
\( -delay 10 image-01.png image-02.png -morph 3 -delete 0 \) \
\( -delay 100 image-02.png \) \
\( -delay 10 image-02.png image-03.png -morph 3 -delete 0 \) \
\( -delay 100 image-03.png \) \
\( -delay 10 image-03.png image-04.png -morph 3 -delete 0 \) \
\( -delay 200 image-04.png \) \
@bblanchon
bblanchon / StringDeduplicationDemo.ino
Created August 1, 2020 08:08
See ArduinoJson memory usage and speed with string deduplication
#include <ArduinoJson.h>
void setup() {
Serial.begin(9600);
while (!Serial) continue;
StaticJsonDocument<516> doc;
const char* json = R"({"list":[{"temperature":21.2,"humidity":68.9,"weather":"overcast clouds"},{"temperature":19.7,"humidity":62.1,"weather":"clear sky"},{"temperature":18.6,"humidity":59.8,"weather":"clear sky"}]})";
@bblanchon
bblanchon / lambda_function.py
Last active March 8, 2021 14:02
AWS Lambda: start EC2 instances
import boto3
region = 'eu-west-3'
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
instances = event['instances']
ec2.start_instances(InstanceIds=instances)
@bblanchon
bblanchon / redirect_jekyll_posts.py
Created February 28, 2020 16:20
Add redirect_from to all Jekyll posts
from pathlib import Path
for file in Path('_posts').glob('*.md'):
print(file.name)
year = file.name[0:4]
month = file.name[5:7]
day = file.name[8:10]
title = file.name[11:-3]
oldurl = f'/{year}/{month}/{day}/{title}/'
print(oldurl)
@bblanchon
bblanchon / redirect_jekyll_posts.py
Created February 28, 2020 16:20
Add redirect_from to all Jekyll posts
from pathlib import Path
for file in Path('_posts').glob('*.md'):
print(file.name)
year = file.name[0:4]
month = file.name[5:7]
day = file.name[8:10]
title = file.name[11:-3]
oldurl = f'/{year}/{month}/{day}/{title}/'
print(oldurl)
@bblanchon
bblanchon / in-design-export.bas
Last active June 8, 2020 13:37
Excel macro to export CSV for InDesign
Sub InDesignExport()
Dim csvFilename As String
Dim transpose As Boolean
csvFilename = Mid(ActiveWorkbook.FullName, 1, InStrRev(ActiveWorkbook.FullName, ".")) & "txt"
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
@bblanchon
bblanchon / gcc-predefined-macros-loop.sh
Created April 21, 2019 12:23
Script I used to generate github.com/bblanchon/predefined-macros
export FOLDER='predefined-macros'
export VERSIONS=(4.4 4.6 4.7 4.8 4.9 5 6 7 8)
mkdir "$FOLDER"
cd "$FOLDER"
git init
for v in "${VERSIONS[@]}";
do
@bblanchon
bblanchon / ga.example.com.conf
Created January 7, 2019 14:31
NGINX proxy for Google Analytics, allows you to bypass ad blockers
# /etc/nginx/sites-available/ga.example.com.conf
#
# Example of an host that uses the snippet
server {
listen 80;
server_name ga.example.com;
# verify that the query relates to my account
if ($arg_tid !~ "^$|^UA-XXXXXXXX-") {
@bblanchon
bblanchon / random_secret_key.py
Created December 17, 2018 13:00
Django generate random secret key
from django.core.management.utils import get_random_secret_key
get_random_secret_key()
@bblanchon
bblanchon / payhip-success.json
Created December 4, 2018 08:14
PayHip: object passed to the success callback
{
"transactionKey": "43ffa7e64bdd0c1ffa3bfcbc551e466aa5346293",
"buyer": "buyer@example.com",
"total": "12.34",
"currency": "USD",
"user_id_hash": "O1wW94N4KT",
"items": [
{
"productName": "My Awesome Product",
"productLink": "oU5g",