Skip to content

Instantly share code, notes, and snippets.

View mcnemesis's full-sized avatar
💭
v:TEA|h:{know some u:code poetry?}|g!:_*\0/*_

Nemesis Fixx Da JWL mcnemesis

💭
v:TEA|h:{know some u:code poetry?}|g!:_*\0/*_
View GitHub Profile
@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 / history_viz.sh
Created December 28, 2012 18:55
A Bash One-liner to visualize one's command-usage based on frequencies in one's Bash History.
history | awk '{ print $2}' | sort | uniq -c | sort -n | tail -n 30 | sed -n '{s/^[ \t]*//};p' | gnuplot -p -e 'set xtics rotate out;set style data histogram;set style fill solid 1.0 border -1;plot "-" u 1:xtic(2) notitle'
@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__) )
@mcnemesis
mcnemesis / 350_exim4-config_virtual_aliases
Created July 4, 2013 14:43
Defining an Exim4 Router to allow Exim to route mails for virtual domains using custom virtual domains aliases.
#####################################################
# router/350_exim4-config_virtual_aliases
#####################################################
#---------------------------
# This router is added so that we can use this server for multiple domains
# And also be able to define custom aliases for each of these domains...
# NOTE : this router is placed before the system_aliases router so that virtual domain
# routing takes precedence over system_aliases
#----------------------------
@mcnemesis
mcnemesis / write_endings
Created July 19, 2013 12:50
[Stolen] Interesting Ways to End Letters and Email, until you die.
Normal, Funny, Unique, and Loving ways to end your letters, notes, e-mails, conversations, tweets, posts....
I love lists.....
Normal:
Best/Warm wishes,
Confidently yours,
Kind regards,
Respectfully Yours,
With anticipation,
Hugs,
@mcnemesis
mcnemesis / cups_cheetsheet.txt
Last active December 20, 2015 11:00
A CUPS Cheetsheet (under development) Originally based on the blog post: http://www.mybinarylife.net/2012/06/linux-cups-terminal-printer-quick.html
Linux CUPS terminal printer quick cheatsheet
=============================================
** Adding a new printer without a PPD:
lpadmin -p printer_name -E -v socket://192.168.1.9:9100
** Finding an existing PPD for your printer if required:
lpinfo --make-and-model 'LaserJet 3390' -m
@mcnemesis
mcnemesis / DataDictionary.cs
Created August 16, 2013 15:39
A Simple, 1-class non-obtrusive No-SQL DB for Windows Phone 8, Windows Store + (RT)
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
namespace MyCHILD
@mcnemesis
mcnemesis / RESTAPI.cs
Created August 16, 2013 15:42
1-File Robust RESTful API internal layer for Windows Phone 8
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
namespace RESTAPI
{
/// <summary>
/// Encapsulates functionality to make it possible to make
@mcnemesis
mcnemesis / CustomKeyGroup.cs
Created August 27, 2013 08:19
This class allows us to be able to create custom groups, with custom keys, that can be easily consumed by jump lists and used to group items in long list selector controls for Windows Phone 8. Jump-Style Yey!
using System;
using System.Collections.Generic;
using System.Linq;
namespace LongListSelectorUtils
{
/// <summary>
/// This class allows us to be able to create custom groups, with custom keys,
/// that can be easily consumed by jumplists and used to group items in longlist selector controls.
///