Skip to content

Instantly share code, notes, and snippets.

View Pithikos's full-sized avatar

Manos Pithikos

  • UK
View GitHub Profile
@Pithikos
Pithikos / rich_text.py
Created July 22, 2020 14:58
richtext filter for Wagtail that creates relative links
"""
This overrides some of the default behaviour of richtext from Wagtail
"""
from wagtail.wagtailcore.rich_text import get_link_handler, extract_attrs, get_embed_handler, LINK_HANDLERS, FIND_A_TAG, FIND_EMBED_TAG
from wagtail.wagtailcore.rich_text import PageLinkHandler as OriginalPageLinkHandler
from wagtail.wagtailcore.models import Page
from django.utils.html import escape
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
/*
Malloc memory of argv sizes with an interval of 10ms in between.
*/
int main(int argc, char **argv)
@Pithikos
Pithikos / gist:24dbeffe700b6ecade2e
Created March 15, 2016 17:03
Rsync backup of home directory
#!/bin/bash
# (expiration is in days)
BACKUP_SRC=/home/manos
BACKUP_DEST=/media/manos/Backup
BACKUP_PREFIX=backup-
BACKUP_EXPIRY=365
# Remove old backups
@Pithikos
Pithikos / gist:09ed1aeabebad7b9eb87
Last active August 29, 2015 14:21
Traceback for specific packages
'''
A generic tracing class that can be used to trace packages.
This can be very helpful for trying to understand the flow
of a program or a package.
Usage:
tracer = Tracer()
tracer.watch_package('pyOCD')
sys.settrace(tracer.trace)
def find_cmd_abspath(cmd):
""" Returns the absolute path to a command.
None is returned if no absolute path was found.
"""
if exists(cmd) or exists(cmd + '.exe'):
return os.path.abspath(cmd)
if not 'PATH' in os.environ:
raise Exception("Can't find command path for current platform ('%s')" % sys.platform)
PATH = os.environ['PATH']
for path in PATH.split(os.path.pathsep):