Skip to content

Instantly share code, notes, and snippets.

@winhamwr
winhamwr / jquery.wymeditor.attachments.js
Created April 19, 2011 18:12
Jquery plugin for file upload and optional WYMeditor image insertion
(function($){
$.Attachments = {
defaults: {
editLoader: '<div class="contentLoading formloader"><img src="/site_media/images/loading.gif" alt="Loading data, please wait...">',
editLoaderS: 'div.formloader',
listLoader: '<div class="contentLoading listloader"><img src="/site_media/images/loading.gif" alt="Loading data, please wait...">',
@winhamwr
winhamwr / jquery.wymeditor.spellcheck.js
Created April 19, 2011 18:57
WYMeditor plugin to provide spellchecking
var spellcheck_type = 'google';
var correction_list = null;
// No constants for Node.* IE
var ELEMENT_NODE = 1;
var TEXT_NODE = 3;
WYMeditor.editor.prototype.spellcheck = function() {
if (!$.browser.msie) { return };
@winhamwr
winhamwr / update_reqs.py
Created July 21, 2011 14:32
Python script to install some pip-based requirements reliably in a virtualenv
#! /usr/bin/env python
"""
Update a set of virtualenvs based on a given set of pip requirements files
whenever those files change. Keeps track of requirements file changes by md5
hashing the files and storing that hash in the virtualenv. That means that
only updates to the files themselves will trigger updating (changes to a
repository won't be caught).
Optionally also supports uploading/downloading a full bundle of all requirements
to/from Amazon S3 based on the requirements hash in order to ensure that
@winhamwr
winhamwr / fabfile.py
Created July 27, 2011 16:55
Fabric script to bundle an ami
def bundle_ami():
require('dev_aws_userid')
require('dev_aws_access_key_id')
require('dev_aws_secret_access_key')
require('ami_bucket')
require('config_folder')
require('hudson_slave_ami_name')
env.ami_name = env.hudson_slave_ami_name
@winhamwr
winhamwr / test.py
Created August 2, 2011 17:10
Nose generator tests example
from nose.tools import assert_equal
addition_cases = [
(
'2 + 2',
2,
2,
4
),
(
@winhamwr
winhamwr / ramdisk_mysql.sh
Created August 17, 2011 20:37
Script to put mysqld on a ram disk in ubuntu 10.04. Runs on every hudson slave boot
sudo cp -r /home/hudson/.ssh /root/;
sudo chown -R root:root /root/.ssh;
sudo service mysql stop;
sudo cp -pRL /var/lib/mysql /dev/shm/mysql;
sudo echo "[mysqld]
datadir = /dev/shm/mysql
" > /tmp/ramdisk.cnf;
sudo mv /tmp/ramdisk.cnf /etc/mysql/conf.d/ramdisk.cnf;
sudo echo "
@winhamwr
winhamwr / models.py
Created August 23, 2011 13:22
Stop a signal from running on a fixture-style load
def my_signal_handler(sender, instance, raw, **kwargs):
if raw:
# This is a fixture-style load. Don't run the handler
return
print "totally handling a signal"
@winhamwr
winhamwr / override.css
Created August 30, 2011 16:21
CSS style override for a large-screen kanbantool.com board
/** https://gist.github.com/1181282 **/
ul.task_list {
height: 1024px;
}
ul.task_list li {
height: auto;
max-height: 20em;
@winhamwr
winhamwr / jquery.wymeditor.inlinestyler.js
Created February 27, 2012 15:22
Ghetto WYMeditor plugin to do inline styling
//Extend WYMeditor
WYMeditor.editor.prototype.inlineStyler = function(options) {
if(jQuery.browser.msie == true){
//No support
}else if (jQuery.browser.opera == true){
//No support
}else if (jQuery.browser.safari == true && jQuery.browser.version < 1.9){
//No support
}else{
var inlineStyler = new InlineStyler(options, this);
@winhamwr
winhamwr / gist:2116251
Created March 19, 2012 15:28
WYMeditor customization example
$(document).ready(function() {
$('#id_doc-html').wymeditor(
{
jQueryPath: "https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",
wymPath: "/site_media/lib/wymeditor/wymeditor/jquery.wymeditor.js",
toolsItems: "[ {'name': 'Bold', 'title': 'Strong', 'css': 'wym_tools_strong'}, {'name': 'Italic', 'title': 'Emphasis', 'css': 'wym_tools_emphasis'}, {'name': 'Superscript', 'title': 'Superscript', 'css': 'wym_tools_superscript'}, {'name': 'Subscript', 'title': 'Subscript', 'css': 'wym_tools_subscript'}, {'name': 'InsertOrderedList', 'title': 'Ordered_List', 'css': 'wym_tools_ordered_list'}, {'name': 'InsertUnorderedList', 'title': 'Unordered_List', 'css': 'wym_tools_unordered_list'}, {'name': 'Indent', 'title': 'Indent', 'css': 'wym_tools_indent'}, {'name': 'Outdent', 'title': 'Outdent', 'css': 'wym_tools_outdent'}, {'name': 'CreateLink', 'title': 'Link', 'css': 'wym_tools_link'}, {'name': 'Unlink', 'title': 'Unlink', 'css': 'wym_tools_unlink'}, {'name': 'InsertImage'