This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// truncate string to specified length with ... at end | |
////////////////////////////////////////////////////////////// | |
function jaStrTrunc($str, $size) | |
{ | |
$slen = strlen($str); | |
if ($slen < $size){ | |
return $str; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# By Val Neekman [[email protected] | |
# Outsourcefactor.com | |
# | |
ScreenFlow Settings. | |
File -> Export | |
Preset = Web High | |
File -> Export -> Customize -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start and stop headless VMs | |
# Val Neekman @ Neekware Inc. | |
# [email protected] | |
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# By Val Neekman ([email protected]) | |
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 = "[email protected]" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.cache import cache | |
from django.conf import settings | |
from django.contrib.auth.models import User | |
ONLINE_THRESHOLD = getattr(settings, 'ONLINE_THRESHOLD', 60 * 15) | |
ONLINE_MAX = getattr(settings, 'ONLINE_MAX', 50) | |
def get_online_now(self): | |
return User.objects.filter(id__in=self.online_now_ids or []) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# git-create-branch <branch_name> | |
if [ $# -ne 1 ]; then | |
echo 1>&2 Usage: $0 branch_name | |
exit 127 | |
fi | |
set branch_name = $1 | |
git push origin origin:refs/heads/${branch_name} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.template import Library | |
from django.utils.encoding import force_unicode | |
from django.utils.functional import allow_lazy | |
from django.template.defaultfilters import stringfilter | |
register = Library() | |
def truncate_chars(s, num): | |
""" | |
Template filter to truncate a string to at most num characters respecting word |