Skip to content

Instantly share code, notes, and snippets.

# Useful snippet if you have a list of files with spaces in their names
# (I'm looking at you, OS X)
# path separators so I can use spaces in filenames
OLD_IFS=${IFS}
# just use a linebreak and remove the space character
IFS="
"
select opt in $list_of_files_with_spaces ; do
echo $opt
<?php
function string_convertFormVarToLocal_default($name, $default='') {
$tmp = $default;
if (isset($_GET[$name])) {
$tmp = strval($_GET[$name]);
} else if (isset($_POST[$name])) {
$tmp = strval($_POST[$name]);
} else {
return $tmp;
#!/usr/bin/env python
# Do this when your sudo password on a remote server is different to your local:
# for example, when you're unlocking a private key with a local password
from fabric import _lazy_format
def production():
set(fab_hosts=['myhost.com'])
# ask for remote sudo password
$(document).ready(function($) {
var toReplace = "/trans.gif";
$('img[src$=png]').each(function(i) {
var src = $(this).attr('src');
var styleBlock = {
'width': $(this).width() + 'px',
'height': $(this).height() + 'px',
'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"
};
$(this).css(styleBlock);
.cta {
overflow: hidden;
*zoom: 1;
}
.cta button,
.cta a {
border:0;
overflow: visible;
padding:0;
<script type="text/javascript">
// circumvent window opening issues
if (document.domain.indexOf('MYDOMAIN.com') != -1) {
document.domain = 'MYDOMAIN.com';
}
</script>
email_body = """From someone@gmail.com Sun Mar 15 01:04:01 2009
Return-Path: <someone@gmail.com>
X-Original-To: someone@somewhere.com
Delivered-To: someone@somewhere.com
Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.218.176; \
helo=mail-bw0-f176.google.com; envelope-f$
X-DKIM: Sendmail DKIM Filter v2.8.1 sth-ubuntu 289CF31836A
Authentication-Results: sth-ubuntu; dkim=pass (1024-bit key)
header.i=@gmail.com; dkim-adsp=none
Received: from mail-bw0-f176.google.com (mail-bw0-f176.google.com [209.85.218.176])
# settings.py
# go up two levels
MEDIA_ROOT = os.path.join(os.path.dirname(__file__), '../../www/')
# in bottom of urls.py
# this is for serving static files in development
if settings.DEBUG:
import os
# get the static path from settings
static_url = settings.MEDIA_URL
# Fix locales
sudo locale-gen en_GB.UTF-8 && sudo locale-gen en_US.UTF-8 && sudo dpkg-reconfigure locales
list1 = [
{'created':1},
{'created':0},
]
list2 = [
{'created':2}
]
combined = list1 + list2