Skip to content

Instantly share code, notes, and snippets.

View Starou's full-sized avatar

Stanislas Guerra Starou

  • Slashdev s.a.r.l.
  • Pays de St-Malo
View GitHub Profile
@Starou
Starou / git_mv.sh
Last active May 31, 2024 08:59
Change the prefix of a bunch of files in Git.
#!/usr/bin/env sh
rx='(FMPLF)(.*)'
for f in FMPLF_SC_*
do
[[ "$f" =~ $rx ]]
new_f="${BASH_REMATCH[1]}_D${BASH_REMATCH[2]}"
echo "mv $f with $new_f"
git mv $f $new_f
@Starou
Starou / my_module.py
Created February 2, 2022 17:40
Trace function calls in a Python program but ignore standard and site-packages lib calls.
import sys
import trace
tracer = trace.Trace(
ignoredirs=[
'/usr/local/lib/python3.6', # adapt to your environment.
'/path/to/lib/python3.6/site-packages',
],
trace=1,
count=0,
@Starou
Starou / ftprmtree.py
Last active August 29, 2015 14:07 — forked from artlogic/ftprmtree.py
def rmtree_ftp(ftp, path):
"""Recursively delete a directory tree on a remote server."""
wd = ftp.pwd()
try:
names = ftp.nlst(path)
except ftplib.all_errors as e:
# some FTP servers complain when you try and list non-existent paths
#_log.debug('FtpRmTree: Could not remove {0}: {1}'.format(path, e))
return
@Starou
Starou / dumpdata_related.py
Created February 26, 2014 10:25
Fork of Django's dumpdata management command with an option to select related models to dump as well.
@Starou
Starou / admin_extras.py
Created October 27, 2013 13:57
A Django admin action to create fixtures from database.
# -*- coding: utf-8 -*-
from django.db import models
from django.contrib import admin
from django.core import serializers
from django.http import HttpResponse
class ModelAdmin(admin.ModelAdmin):
actions = ["dumpdata"]
@Starou
Starou / daterange.py
Last active September 26, 2015 01:27 — forked from jacobian/daterange.py
PEP8
# -*- coding: utf-8 -*-
"""
Example Usage
=============
>>> import datetime
>>> start = datetime.date(2009, 6, 21)