Skip to content

Instantly share code, notes, and snippets.

View un33k's full-sized avatar
🎯
Focusing

Val Neekman un33k

🎯
Focusing
View GitHub Profile
@un33k
un33k / slash_middleware.py
Created July 5, 2012 11:53 — forked from gregplaysguitar/slash_middleware.py
Append OR remove slash in django - like APPEND_SLASH but smarter.
from django import http
from django.utils.http import urlquote
from django.core import urlresolvers
class AppendOrRemoveSlashMiddleware(object):
"""
Like django's built in APPEND_SLASH functionality, but also works in reverse. Eg
will remove the slash if a slash-appended url won't resolve, but its non-slashed
counterpart will.
@un33k
un33k / SingleSlash
Created July 5, 2012 11:56
This middleware removes extra back2back slashes from incoming request
from django.http import HttpResponseRedirect
import re
slash_re = re.compile('/{2,}')
class SingleSlashes:
""" This middleware removes extra back2back slashes from an incoming request """
def process_request(self, request):
if '//' in request.path:
new_path = slash_re.sub('/', request.path)
@un33k
un33k / vmware_fusion_shared_folder.txt
Last active September 1, 2020 10:05
Enable Shared Folders on vmware Fusion 4.x, 5.x & 6.x (Linux Ubuntu 12.x as guest OS)
Enable Shared Folders on vmware Fusion (4.x)+ (Example OS: Linux Ubuntu 12.x as guest OS)
1. First update your linux system:
sudo apt-get update
sudo apt-get install -y build-essential
sudo aptitude -y safe-upgrade
2. Reboot your system just in case you have a new kernel
sudo shutdown -r now
@un33k
un33k / loto_robo.py
Created July 26, 2012 13:40
simple script to scrape (http://www.calottery.com) winning numbers and email it out.
# By Val Neekman (val@neekware.com)
import os, urllib2, sys, re, datetime, smtplib
## HOWTO:
# Change the following settings then run this script as "python loto_robo.py"
###### Settings ########
SEND_EMAIL = True
FROMADDR = "val@neekware.com"
@un33k
un33k / vmware_fusion_headless.sh
Created July 30, 2012 01:43
Run Fusion 3.x OR 4.x in headless mode
# Start and stop headless VMs
# Val Neekman @ Neekware Inc.
# un33kvu@gmail.com
# You need to fix this to point to the right directory on your MAC
VMHOME="${HOME}/Documents/VMs"
if [ -z $1 ]
then echo "Usage: vm stop|start|stopall"
exit 1
@un33k
un33k / screenflow_export_settings.txt
Created July 30, 2012 22:18
ScreenFlow Export Settings (HD)
# By Val Neekman [val@neekware.com
# Outsourcefactor.com
#
ScreenFlow Settings.
File -> Export
Preset = Web High
File -> Export -> Customize ->
@un33k
un33k / samplecode.php
Created September 5, 2012 17:56
Some sample code in PHP
<?php
// truncate string to specified length with ... at end
//////////////////////////////////////////////////////////////
function jaStrTrunc($str, $size)
{
$slen = strlen($str);
if ($slen < $size){
return $str;
}
@un33k
un33k / redirect_to_local_port.txt
Created September 11, 2012 22:41
Redirect an integration domain name to a local port to test oAut
RewriteEngine On
RewriteRule ^(.*)$ http://192.168.224.128:8080/$1 [R=301,L]
@un33k
un33k / Conways_Game_Of_Life.py
Created October 8, 2012 03:42
Conway's Game of Life
#!/usr/bin/env python
# one approach to the Conway's Game of Life
# http://en.wikipedia.org/wiki/Conway's_Game_of_Life
# Val Neekman val@neekware.com
# Open a terminal (Mac) 170 x 40, then run this script and see it for yourself
# It is fun
import os
@un33k
un33k / gist:3886896
Created October 14, 2012 01:28 — forked from EspadaV8/gist:1357237
Script to import Geonames into PostgreSQL taken from http://forum.geonames.org/gforum/posts/list/15/926.page
#!/bin/bash
#===============================================================================
#
# FILE: getgeo.sh
#
# USAGE: ./getgeo.sh
#
# DESCRIPTION: run the script so that the geodata will be downloaded and inserted into your
# database
#