Skip to content

Instantly share code, notes, and snippets.

View Lucas-C's full-sized avatar

Lucas Cimon Lucas-C

View GitHub Profile
# LibreOffice macro script
import uno
def changeFontsWithin(object_list, to_font, to_weight=None):
for i in range(object_list.getCount()):
shape = object_list.getByIndex(i)
the_type = shape.getShapeType()
assert(shape.supportsService(the_type))
if shape.supportsService('com.sun.star.drawing.TextProperties'):
if to_font:
@Lucas-C
Lucas-C / build_stats_page.py
Last active October 8, 2019 16:42
Generate an HTML page with graphs representing the evolution of issues & PRs for a given GitHub repo
#!/usr/bin/env python3
# Inspired by https://nf-co.re/stats#github_prs
# Original code by Phil Ewens, cf. https://github.com/nf-core/nf-co.re/issues/190
# This code is under MIT License, as the original nf-co.re website is
# INSTALL: pip install jinja2 livereload requests xreload
# USAGE: ./build_stats_page.py [--use-dump] [--watch-and-serve] org/repo
import argparse, json, os, sys, types, webbrowser
@Lucas-C
Lucas-C / isso_watcher.py
Last active September 19, 2019 21:56
A script to cron in order to get notified by email on new isso comments: https://posativ.org/isso - The bash script calls the Python one
#!/usr/bin/env python3 import sqlite3, sys
from collections import namedtuple
Comment = namedtuple('_Comment', ('id', 'text', 'author', 'uri'))
QUERY = 'SELECT comments.id, text, author, uri FROM comments INNER JOIN threads on comments.tid = threads.id'
last_comment_id_filepath = sys.argv[1]
isso_db_filepath = sys.argv[2]
uri_prefix = sys.argv[3] if len(sys.argv) == 4 else ''
@Lucas-C
Lucas-C / nginx_redirect_generator_for_ghost.py
Last active August 18, 2017 22:57
Generate a .redirects file to include in nginx, from a Ghost blog JSON export
#!/usr/bin/env python
# USAGE: ./nginx_redirect_generator.py /lucas/blog < ghost_export.json
import datetime, json, os, sys
path_prefix = sys.argv[1]
ghost_db = json.loads(sys.stdin.read())
posts = ghost_db['db'][0]['data']['posts']
@Lucas-C
Lucas-C / webpage_modification_notifier.sh
Last active September 19, 2017 11:32
Bash script to use in a cron job in order to receive an email when a web page changes
#!/bin/bash
# USAGE: ./webpage_modification_notifier.sh $URL
set -o pipefail -o errexit -o nounset
date
cd $(dirname "${BASH_SOURCE[0]}")
url="${1?'Argument required'}"
echo $url
last_version=${url//[^[:alpha:]]/}.html
@Lucas-C
Lucas-C / parse_ghost_backup.py
Last active March 22, 2019 18:34 — forked from lazypower/parse_ghost_backup.py
A quick and dirty data munger/parser for migrating from ghost to raw markdown - Tested with Ghost v0.11.8
#!/usr/bin/env python
import json
import os
import sys
import datetime
with open("old.json", "r") as f:
raw = f.read()
@Lucas-C
Lucas-C / convert_report_to_cucumber_format.py
Last active March 7, 2018 14:40
Behave to Cucumber JSON report converter
#!/usr/bin/env python
# USAGE: ./convert_report_to_cucumber_format.py --behave-report bdd/report.json [--json-schema cucumber-report-schema.json]
import argparse, json, sys
from jsonschema import Draft4Validator
def main(argv=None):
args = parse_args(argv)
@Lucas-C
Lucas-C / index.rst.patch
Created August 24, 2015 20:51
Patch to document the changes detailed in https://github.com/amoffat/sh/issues/269
--- index.txt 2015-08-24 22:48:41.587933500 +0200
+++ index.txt.new 2015-08-24 22:41:03.269527000 +0200
@@ -381,6 +381,20 @@
print(myserver.tail("/var/log/dumb_daemon.log", n=100))
+.. _special_arguments_defaults:
+
+Special arguments defaults
+--------------------------