Skip to content

Instantly share code, notes, and snippets.

View mcnemesis's full-sized avatar
💭
DNAP hackathons on days with good weather ;-)

Nemesis Fixx Da JWL mcnemesis

💭
DNAP hackathons on days with good weather ;-)
View GitHub Profile
Telling Exim4 to allow users on external networks to use the mail server as a relay:
So, for example your mail server has local ip:
192.168.1.1
In that case, if you only wish let you local users use the mail server to send mail, then configure the relay host as this:
In `/etc/exim4/update-exim4.conf.conf`, set the relay network to only allow local machines for example (probably filter with a Class C mask)
@mcnemesis
mcnemesis / Python_Imaging_Bug_on_Debian-711343.py
Created June 2, 2014 13:57
Highlighting some nasty bug in Python Imaging, common to Debian currently
>>> import Image
>>> Image.open("file.png")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 2020, in open
raise IOError("cannot identify image file")
IOError: cannot identify image file
>>> from PIL import Image
>>> Image.open("file.png")
<PngImagePlugin.PngImageFile image mode=RGB size=40x40 at 0x25690E0>
@mcnemesis
mcnemesis / troublesomw_import_django-stdimage.py
Created June 2, 2014 14:05
The troublesome import in django-stdimage/stdimage/fields.py
try:
import Image, ImageOps
except ImportError:
from PIL import Image, ImageOps
@mcnemesis
mcnemesis / the_fix.py
Created June 2, 2014 14:13
Fixes the nasty bug!
try:
from PIL import Image, ImageOps
except ImportError:
import Image, ImageOps
@mcnemesis
mcnemesis / trace_debug_azure_website.ps1
Created January 14, 2015 18:56
This gist shows how you can trace debug your website (e.g a php site) that's on Azure, directly from the Powershell command line.
azure account import PATH_TO_YOUR_AZURE_PUBLISH_SETTINGS_FILE
azure site log tail YOUR_AZURE_WEBSITE_NAME
@mcnemesis
mcnemesis / upgrade_wordpress_wpcli.sh
Last active August 29, 2015 14:25
This is how to upgrade your WordPress site, its plugins and themes automatically via a shell, using wp-cli
#!/bin/bash
#requires: wp-cli installed
# run all the following commands inside your wordpress root directory
wp core update #updates wp itself
wp plugin update --all #update all plugins
wp theme update -all #update all themes
- ensure to have the `~/.vim/plugin` directory
- clone the vim-autopep8 plugin git repo into your .vim:
git clone https://github.com/tell-k/vim-autopep8.git
- symlink the plugin file into your vim plugins directory
ln -s $(realpath -f vim-autopep8/ftplugin/python_autopep8.vim) plugin
- open your python file using vim
@mcnemesis
mcnemesis / df_mail_alert.sh
Created November 26, 2012 14:42
linux : mail-report on low disk-space in one line!
df -h | grep -e "/home$" | awk '{print $5}' | tr '%' ' ' | xargs -n 1 -I{} echo {} | xargs -n1 -I_percent -- sh -c '[ _percent -ge 70 ] && echo "Low Space on server:/home (_percent% full)" | mail -s "Disk Space Alert" johndoe@site.com'
@mcnemesis
mcnemesis / pg_col_resize.sh
Created May 21, 2013 16:56
A Bash script to help re-size a PostgreSQL VARCHAR column to a NEW SIZE, taking care to adjust for required meta-data space. This kind of script greatly helps in scenarios where an existing table (probably with tons of data already) suddenly becomes restricting for certain longer values to be inserted. You might also use it to re-size to a small…
#!/usr/bin/sh
if [ -z "$1" ]
then
echo "Usage: "$0" DBUSER DB TABLE COL NEWSIZE"
else
USER=$1
DB=$2
TABLE=$3
COL=$4
SIZE=$5
@mcnemesis
mcnemesis / wsgi.py
Created May 24, 2013 19:52
My Django WSGI bootstrap script that is *so generic* it might work as a default replacement in any standard Django project. If you created your project using the default: django-admin.py startproject PROJECT, then just try switching your PROJECT/PROJECT/wsgi.py with this.
import os, sys
base = os.path.dirname(os.path.dirname(__file__))
base_parent = os.path.dirname(base)
sys.path.append(base)
sys.path.append(base_parent)
os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % os.path.basename( os.path.dirname(__file__) )