Skip to content

Instantly share code, notes, and snippets.

Nemesis Fixx mcnemesis

Block or report user

Report or block mcnemesis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View exim4_dc_relay_nets_example
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 / troublesomw_import_django-stdimage.py
Created Jun 2, 2014
The troublesome import in django-stdimage/stdimage/fields.py
View troublesomw_import_django-stdimage.py
try:
import Image, ImageOps
except ImportError:
from PIL import Image, ImageOps
@mcnemesis
mcnemesis / Python_Imaging_Bug_on_Debian-711343.py
Created Jun 2, 2014
Highlighting some nasty bug in Python Imaging, common to Debian currently
View Python_Imaging_Bug_on_Debian-711343.py
>>> 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 / the_fix.py
Created Jun 2, 2014
Fixes the nasty bug!
View the_fix.py
try:
from PIL import Image, ImageOps
except ImportError:
import Image, ImageOps
@mcnemesis
mcnemesis / trace_debug_azure_website.ps1
Created Jan 14, 2015
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.
View trace_debug_azure_website.ps1
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 Aug 29, 2015
This is how to upgrade your WordPress site, its plugins and themes automatically via a shell, using wp-cli
View upgrade_wordpress_wpcli.sh
#!/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
View Use AutoPep8 in your Python projects via Vim
- 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 Nov 26, 2012
linux : mail-report on low disk-space in one line!
View df_mail_alert.sh
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
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…
View pg_col_resize.sh
#!/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
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.
View wsgi.py
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__) )
You can’t perform that action at this time.