Skip to content

Instantly share code, notes, and snippets.

Avatar

Adrien adrienlachaize

View GitHub Profile
@ShantanuJoshi
ShantanuJoshi / compressMe.py
Last active Sep 29, 2020
Python Image Compress
View compressMe.py
#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
jamesbrobb / multiform.py
Last active Nov 26, 2020 — 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
View multiform.py
class MultiFormMixin(ContextMixin):
form_classes = {}
prefixes = {}
success_urls = {}
grouped_forms = {}
initial = {}
prefix = None
success_url = None
@tomdyson
tomdyson / getting-started-with-wagtail.md
Last active Nov 12, 2020
Getting started with Wagtail
View getting-started-with-wagtail.md

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
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
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
aortbals / dispatch.py
Last active Oct 17, 2020
Synchronize two folders using python.
View dispatch.py
#! /usr/bin/python
# Dispatch - synchronize two folders
import os
import filecmp
import shutil
from stat import *
class Dispatch:
''' This class represents a synchronization object '''
You can’t perform that action at this time.