Skip to content

Instantly share code, notes, and snippets.

@winhamwr
winhamwr / jquery.wymeditor.inlinestyler.js
Created Feb 27, 2012
Ghetto WYMeditor plugin to do inline styling
View jquery.wymeditor.inlinestyler.js
//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 / wym_autosave.js
Created Nov 1, 2011
Javascript to do autosave on a form using WYMeditor
View wym_autosave.js
/**
Automatically saves a policy every REFRESH milliseconds through AJAX,
but only when the .autosave form has changed. To use, add the class autosave
to your form.
Note: REFRESH must always be bigger than SAVE_TIMEOUT, otherwise a broken
save will cause deadlock for pending.
**/
function processJson(data) {
@winhamwr
winhamwr / override.css
Created Aug 30, 2011
CSS style override for a large-screen kanbantool.com board
View override.css
/** https://gist.github.com/1181282 **/
ul.task_list {
height: 1024px;
}
ul.task_list li {
height: auto;
max-height: 20em;
@winhamwr
winhamwr / models.py
Created Aug 23, 2011
Stop a signal from running on a fixture-style load
View models.py
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 / ramdisk_mysql.sh
Created Aug 17, 2011
Script to put mysqld on a ram disk in ubuntu 10.04. Runs on every hudson slave boot
View ramdisk_mysql.sh
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 / test.py
Created Aug 2, 2011
Nose generator tests example
View test.py
from nose.tools import assert_equal
addition_cases = [
(
'2 + 2',
2,
2,
4
),
(
@winhamwr
winhamwr / fabfile.py
Created Jul 27, 2011
Fabric script to bundle an ami
View fabfile.py
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 / update_reqs.py
Created Jul 21, 2011
Python script to install some pip-based requirements reliably in a virtualenv
View update_reqs.py
#! /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 / jquery.wymeditor.spellcheck.js
Created Apr 19, 2011
WYMeditor plugin to provide spellchecking
View jquery.wymeditor.spellcheck.js
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 / jquery.wymeditor.attachments.js
Created Apr 19, 2011
Jquery plugin for file upload and optional WYMeditor image insertion
View jquery.wymeditor.attachments.js
(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...">',