This file contains 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 | |
// Handy function for 2600 meeting websites | |
/** | |
* Return a unix timestamp for next "first Friday of the month", e.g. | |
* either the first Friday of the current month or if that date has already passed | |
* the first friday of the next month | |
* @return int unix timestamp | |
*/ | |
function getNextFirstFriday() { |
This file contains 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 | |
// How to lock a table using PEAR's DB_DataObject in a semi-OO way, | |
// note this still relies on the DB-dependant LOCK/UNLOCK syntax, | |
// change for the relevent RDBMS | |
// Lock | |
// You can also specify other options such as READ and the priority below | |
// see RDBMS docs, in this case MySQL | |
$object->getDatabaseConnection()->query('LOCK TABLES ' . $object->tableName() . ' WRITE'); | |
// Unlock |
This file contains 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
/* | |
Close a jQuery.UI modal dialog when the background overlay is clicked on, | |
ala most standard modal javascript overlays. | |
*/ | |
$('.ui-widget-overlay').click(function() { | |
// Where #dialog below should be a selector for the dialog you want to close | |
$('#dialog').dialog('close'); | |
}); |
This file contains 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 import serializers | |
from django.http import HttpResponse | |
from django.utils import simplejson | |
from django.db.models import Model | |
def jsonify(fn, *args, **kwargs): | |
""" Decorator that serializes the output of a function, most likely | |
a view, as JSON, and returns the JSON in a HttpResponse. | |
Inspired by Pylon's jsonify controller decorator. | |
""" |
This file contains 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/bash | |
# Replace <local_user> with your local username, <remote_user> with your username on <remote_host> etc. | |
# You'll need an SSH, <private_key>, setup with the remote host to not prompt for a password | |
# (either passphraseless or with ssh-agent running) | |
ssh -i /home/<local_user>/.ssh/<private_key> <remote_user>@<remote_host> "export DISPLAY=:0 && gnome-screensaver-command --lock" | |
gnome-screensaver-command --lock |
This file contains 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
<target name="wordpress.upgrade"> | |
<property name="tmp" value="/tmp" /> | |
<property name="src" value="${tmp}/wordpress" /> | |
<delete dir="${src}" includeemptydirs="true" failonerror="true" /> | |
<exec dir="${tmp}" command="curl -s http://wordpress.org/latest.tar.gz | tar -xz" /> | |
<delete dir="wp-admin" includeemptydirs="true" failonerror="true" /> | |
<delete dir="wp-includes" includeemptydirs="true" failonerror="true" /> | |
<move file="wp-config.php" tofile="wp-config.php.bak" overwrite="true"/> |
This file contains 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
#!/usr/bin/env python | |
from sys import argv | |
from pprint import pprint | |
try: | |
import json | |
except ImportError: | |
import simplejson as json | |
pprint(json.load(file(argv[1]))) |
This file contains 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
sudo add-apt-repository ppa:gnome3-team/gnome3 | |
# Remember to change your apt priorities so that the gnome3 PPA takes | |
# precedence over Canonical | |
sudo apt-get update | |
sudo apt-get dist-upgrade | |
sudo apt-get install gnome-shell gnome3-session | |
sudo apt-get remove unity | |
sudo vim /usr/share/xsessions/gnome.desktop | |
# change --session=ubuntu for --session=gnome | |
sudo shutdown -r now |
This file contains 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
"""Sometimes you just want to load your session based on a GET value, | |
without having an entire middleware installed to do it everytime, e.g. | |
just do it quickly in a view. | |
""" | |
def test_view(request): | |
# Assuming session key sent as 'sessionid' value in querystring | |
request.session = request.session.__class__(session_key=request.GET['sessionid']) |
This file contains 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
# Show current git branch or SVN subfolder in prompt. | |
GREEN="\[\033[0;32m\]" | |
LIGHT_GREEN="\[\033[1;32m\]" | |
GRAY="\[\033[1;30m\]" | |
LIGHT_BLUE="\[\033[1;34m\]" | |
LIGHT_GRAY="\[\033[0;37m\]" | |
COLOR_OFF="\[\e[0m\]" | |
LAST_GIT_DIR="!" | |
function prompt_func() { | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' |
OlderNewer