Skip to content

Instantly share code, notes, and snippets.


Adrien adrienlachaize

View GitHub Profile
ShantanuJoshi /
Last active May 12, 2021
Python Image Compress
#run this in any directory add -v for verbose
#get Pillow (fork of PIL) from pip before running --> pip install Pillow
import os
import sys
from PIL import Image
def compressMe(file, verbose=False):
filepath = os.path.join(os.getcwd(), file)
oldsize = os.stat(filepath).st_size
jamesbrobb /
Last active Feb 9, 2021 — forked from michelts/gist:1029336
django multiform mixin and view that allows the submission of a) All forms b) Grouped forms c) An individual form
class MultiFormMixin(ContextMixin):
form_classes = {}
prefixes = {}
success_urls = {}
grouped_forms = {}
initial = {}
prefix = None
success_url = None
tomdyson /
Last active Nov 12, 2020
Getting started with Wagtail

Wagtail tutorial

Thanks to [Serafeim Papastefanos] for authoring this tutorial. Please note that the installation process is in flux; most of the steps here should soon be unnecessary.

[Wagtail] is a new Open Source [Django]-based CMS. In this 20 minute tutorial we will see how you can create a blog from scratch using Wagtail. If you want to see some more examples of usage please take a look at the [wagtaildemo] GitHub project.

To follow this tutorial you will need to have [Python] 2.7 installed with a working version of [pip] and [virtualenv].

Installing the wagtail dependencies

adrienlachaize / gist:8349832
Created Jan 10, 2014
Check if the given file is .txt
View gist:8349832
import mimetypes
def is_txt_file(file):
"""Test if the file is a txt file."""
mime = mimetypes.guess_type(file)
if mime[0] == 'text\plan':
return True
adrienlachaize / gist:8349814
Created Jan 10, 2014
Get system os struct.
View gist:8349814
import struct
def get_os_struct():
"""Get system os struct."""
return str(struct.calcsize('P') * 8)
aortbals /
Last active Apr 30, 2021
Synchronize two folders using python.
#! /usr/bin/python
# Dispatch - synchronize two folders
import os
import filecmp
import shutil
from stat import *
class Dispatch:
''' This class represents a synchronization object '''