Skip to content

Instantly share code, notes, and snippets.

View khchine5's full-sized avatar
🗺️
World citizen

Hamza Khchine khchine5

🗺️
World citizen
View GitHub Profile
@khchine5
khchine5 / gunicorn_start.bash
Created July 28, 2017 09:32 — forked from postrational/gunicorn_start.bash
Example of how to set up Django on Nginx with Gunicorn and supervisordhttp://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
#!/bin/bash
NAME="hello_app" # Name of the application
DJANGODIR=/webapps/hello_django/hello # Django project directory
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name
PdfFile = PdfFileReader(f)
if PdfFile.isEncrypted:
try:
PdfFile.decrypt('')
print 'File Decrypted (PyPDF2)'
except:
import os
command = "cp " + f.name + " /tmp/temp.pdf; qpdf --password='' --decrypt /tmp/temp.pdf " + f.name + "_new"
os.system(command)
print 'File Decrypted (qpdf)'
@khchine5
khchine5 / setting.py
Last active August 6, 2016 23:11
djangocms text ckeditor: Active all options of ckeditor as Font selection , image insertion, lineheight ...
CKEDITOR_SETTINGS = {
'language': '{{ language }}',
'skin': 'moono',
'toolbar_HTMLField': [
['Source', '-', 'Save', 'NewPage', 'DocProps', 'Preview', 'Print', '-', 'Templates'],
['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'],
['Find', 'Replace', '-', 'SelectAll', '-', 'SpellChecker', 'Scayt'],
['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton',
'HiddenField'],
['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'],
@khchine5
khchine5 / setting.py
Created August 6, 2016 22:47
djangocms text ckeditor: Active all options of ckeditor as Font selection , image insertion.
CKEDITOR_SETTINGS = {
'language': '{{ language }}',
'skin': 'moono',
'toolbar_HTMLField': [
['Source', '-', 'Save', 'NewPage', 'DocProps', 'Preview', 'Print', '-', 'Templates'],
['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'],
['Find', 'Replace', '-', 'SelectAll', '-', 'SpellChecker', 'Scayt'],
['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton',
'HiddenField'],
['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'],
@khchine5
khchine5 / Virtualenv with Python3
Last active January 22, 2016 04:25
Installing and using virtualenv with Python3
Update the server
$ apt-get update
Install pip3
$ sudo apt-get install pip3
Install virtualenv via pip
$ pip3 install virtualenv
Create a virtualenvs directory