Skip to content

Instantly share code, notes, and snippets.

@alexgarel
alexgarel / deliciouszotero.py
Created August 24, 2016 23:09
Transform a delicious export to a RIS file, that can be imported in Zotero
#!/usr/bin/env python3
"""Transform a delicious export to a RIS file, that can be imported in Zotero
You'll need lxml installed (python3-lxml)
"""
import datetime
import sys
from lxml import html
fname = sys.argv[1]
@alexgarel
alexgarel / fix_assets.py
Created September 25, 2015 21:19
Utility to fixe a not so broken joomla assets table. Provided all assets are there and parent_id is correct, it will recompute level, rgt and lft for all entries.
import argparse
import getpass
import sys
import mysql.connector
class AssetsFixer:
cols = ["id", "parent_id", "level", "lft", "rgt"]
@alexgarel
alexgarel / celery_test_util.py
Last active September 30, 2022 09:28
Helper for tests with celery, running tasks in main thread but keeping control on when (alternative to eager)
from functools import partial
from celery.app.task import Task
from celery.app.utils import find_app
class CeleryTestTask(object):
"""A context manager to patch task in order to queue delayed tasks
and eventually run them. This is for tests.
@alexgarel
alexgarel / pyflakes_out_for_geany.py
Created October 17, 2013 07:41
Using Geany and launching pyflakes or pep8 ? This script parse pyflakes / pep8 output and add line filename and line numbers and produce an output suitable for Geany (underlining errors and jumping to related line as you cilck on ouput).
#!/usr/bin/env python3
"""
Geany pyflakes and pep8 output reformater
When defining your compile command in geany use::
/path/to/pyflakes %f 2>&1 |/path/to/pyflakes_out_for_geany.py
/path/to/pep8 %f |/path/to/pyflakes_out_for_geany.py
"""
import sys
@alexgarel
alexgarel / jshint_out_for_geany.py
Created October 17, 2013 07:07
Using Geany and launching jshint ? This script parse jshint output and add line filename and line numbers and produce an output suitable for Geany (underlining errors and jumping to related line as you cilck on jshint ouput).
#!/usr/bin/env python3
"""
Geany jshint output reformater
When defining your compile command in geany
just use /path/to/jshint %f |/path/to/reformat_jshint.py
"""
import re
import sys
@alexgarel
alexgarel / jslint_out_for_geany.py
Created October 17, 2013 07:05
Using Geany and launching jslint (with eg.node-jslint). This script parse jslint output and add line filename and line numbers and produce an output suitable for Geany (underlining errors and jumping to related line as you cilck on jslint ouput).
#!/usr/bin/env python3
"""
Jslint output reformater for Geany
When defining your compile command in geany use::
/path/to/jslint %f |/path/to/jslint_out_for_geany.py
"""
import re