Skip to content

Instantly share code, notes, and snippets.

View gglanzani's full-sized avatar

Giovanni Lanzani gglanzani

View GitHub Profile
@gglanzani
gglanzani / migrate-bitbucket.sh
Created December 29, 2025 14:07
Migrate bitbucket repositories to GitHub
#!/usr/bin/env bash
set -euo pipefail
# usage (assuming the `gh` CLI is installed and you're authenticated):
#
#
# BB_WORKSPACE=your_bitbucket_workspace \
# GH_OWNER=your_github_username \
# ./migrate-bitbucket.sh repos.txt
# ----------------------------
@gglanzani
gglanzani / add_tags.py
Created December 28, 2025 22:07
Script to automatically add tags to markdown blog posts (with YAML front matter) using OpenAI GPT-4 for content analysis.
#!/usr/bin/env python3
"""
Script to automatically add tags to blog posts using OpenAI GPT-4 for content analysis.
Analyzes the content and generates relevant tags for each post.
"""
import os
import json
import yaml
import time
@gglanzani
gglanzani / opengraph.html
Created March 14, 2024 11:19
opengraph.html with hugo{
{{- if .IsPage }}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
<meta property="article:section" content="{{ .Section }}" />
{{ with .PublishDate }}<meta property="article:published_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
{{ with .Lastmod }}<meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
{{- end -}}
{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
{{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }}
{{- with .Site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }}
@gglanzani
gglanzani / app.conf
Last active April 20, 2022 11:48
miniflux, docker-compose, nginx
server {
listen 80;
server_name <my_domain>;
server_tokens off;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
"""
When deploying new jars used by NiFi's ExecuteScript processor, it is necessary to stop and restart all the
processors manually to have them pick up the new jars. This script solves this issue.
"""
import json
from urllib import request
from urllib import error
from typing import Dict, Iterator, List
from http.client import HTTPResponse
@gglanzani
gglanzani / index.html
Last active June 16, 2017 09:51
accelerator tshirt
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg)">
<scene id="scene1">
@gglanzani
gglanzani / .theanorc
Created October 3, 2016 07:41
Theano + CUDA on Windows
[general]
device=gpu
floatX=float32
[cuda]
root=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0
[nvcc]
compiler_bindir=C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin
[lib]
cnmem=0.2
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gglanzani
gglanzani / erlang-shell
Created January 13, 2015 11:16
riak-python-client#396
riakc_pb_socket:mapred( Client, [
{<<"SCF">>,<<"satellite_00BCD806247A70C80E9780BBC274C42CB06F3047E03CABC0652F72FB0A2C55A0_False_2013-1">>},
{<<"SCF">>,<<"satellite_00BCD806247A70C80E9780BBC274C42CB06F3047E03CABC0652F72FB0A2C55A0_False_2013-3">>},
{<<"SCF">>,<<"satellite_00BCD806247A70C80E9780BBC274C42CB06F3047E03CABC0652F72FB0A2C55A0_False_2013-4">>},
{<<"SCF">>,<<"satellite_00BCD806247A70C80E9780BBC274C42CB06F3047E03CABC0652F72FB0A2C55A0_False_2013-5">>},
{<<"SCF">>,<<"satellite_00BCD806247A70C80E9780BBC274C42CB06F3047E03CABC0652F72FB0A2C55A0_False_2013-6">>},
{<<"SCF">>,<<"satellite_00BCD806247A70C80E9780BBC274C42CB06F3047E03CABC0652F72FB0A2C55A0_False_2013-7">>},
{<<"SCF">>,<<"satellite_00BCD806247A70C80E9780BBC274C42CB06F3047E03CABC0652F72FB0A2C55A0_False_2013-8">>},
from riak import RiakClient
from riak import RiakMapReduce
riak = RiakClient(protocol='pbc', host='172.17.12.22', http_port=8087)
bucket = riak.bucket("STATS")
mr = RiakMapReduce(riak)
keys = [d['_yz_rk'] for d in bucket.search(query="industry_id:[1 TO 22]", index="grid_stats", rows=1000)['docs']]
mr.add("STATS", keys[:40])
len(set(map(lambda x: x[:-5], keys[:40]))) # number of unique keys, 31 in this case