Skip to content

Instantly share code, notes, and snippets.

@winhamwr
winhamwr / policystat_zendesk_uptime.html
Last active March 10, 2016 18:30
Zendesk home screen widget for displaying our uptime and satisfaction
<!------------------------------------------------------------------
Satisfied Customers / Application Uptime
------------------------------------------------------------------->
<!-- This code lives at: https://gist.github.com/winhamwr/5886065 Make all edits there, first -->
<style type="text/css" media="screen, projection">
@import url(https://policystat.zendesk.com/stylesheets/public_satisfaction.css);
.highlighted { color: #133672; }
.uptime-percentage {
font-weight: bold;
font-size: large;
@winhamwr
winhamwr / example-usage.html
Last active February 4, 2016 09:46
WYMeditor plugin for inserting "special" characters (HTML entities)
<html>
<head>
<link rel="stylesheet" type="text/css" href="wymeditor/skins/default/skin.css" />
</head>
<body>
<!-- Note: You'll need to put everything in a "plugins/special_chars" directory
and add your own "plugins/special_chars/char.gif" icon that will be used for the button. -->
<form>
<textarea class="my-wymeditor"></textarea>
</form>
@winhamwr
winhamwr / test.py
Last active December 27, 2015 17:29
My first real dynamic-typing bug in 6 years of doing python and Django. Luckily, we caught it in code review.
# This test passes, even though the existing-username validation is completely broken
class UsernameUpdateCSVTestCase(TestCase):
def test_new_username_already_exists_validation_error(self):
# If the new_username already exists on the same home site, we throw a
# validation error
site_admin_username, _ = split_username(self.site_admin_user.username)
UserFactory(
username='existing_username',
tenant=self.tenant,
)
@winhamwr
winhamwr / insert_date.py
Created October 14, 2013 17:04
Autohotkey script for inserting the Excel compliant current date and time any time you type Dnow http://www.autohotkey.com/
import datetime
format_str = '%Y-%m-%d %H:%M:%S'
now = datetime.datetime.now()
output = now.strftime(format_str)
keyboard.send_keys(output)
## Installation
@winhamwr
winhamwr / jquery.wymeditor.spellcheck.js
Created July 23, 2013 14:04
Semi-ghetto WYMeditor spellcheck plugin
var incorrect_spelling_style = {
'border-bottom': '1px dashed #FF0000'
};
var incorrect_spelling_class = 'incorrect';
// No constants for Node.* IE
var ELEMENT_NODE = 1;
var TEXT_NODE = 3;
WYMeditor.editor.prototype.spellcheck = function() {
@winhamwr
winhamwr / machine_setup.sh
Last active December 15, 2015 20:33
PolicyStat Ubuntu dev machine setup
#!/bin/bash
# Gist available at: https://gist.github.com/winhamwr/3bad9f4e05885b599a4e
set -e;
export JOB_IDLE_TIMEOUT=60
make --makefile=$WORKSPACE/scripts/hudson/Makefile log_job_started_for_idle_shutdown;
sudo apt-get update;
sudo apt-get install -y;
sudo apt-get install -y build-essential linux-headers-$(uname -r) nfs-kernel-server dkms dpkg-dev;
@winhamwr
winhamwr / scale_wym.js
Created January 18, 2013 21:39
Scale WYMeditor when the window size changes
function scaleEditor(wym) {
var min_width = 675;
var max_width = 850;
var min_height = 300;
var max_height = 600;
var width = $(window).width() - 50;
width = Math.max(width, min_width);
width = Math.min(width, max_width);
@winhamwr
winhamwr / gist:3035439
Created July 2, 2012 20:18
zenbox integration
<!--[if gt IE 7]><!-->
<script type="text/javascript" src="//assets.zendesk.com/external/zenbox/v2.4/zenbox.js"></script>
<style type="text/css" media="screen, projection">
@import url(//assets.zendesk.com/external/zenbox/v2.4/zenbox.css);
</style>
<script type="text/javascript">
if (typeof(Zenbox) !== "undefined") {
Zenbox.init({
dropboxID: "XXXXXXX",
url: "https://policystat.zendesk.com",
{% with table.rows as table_rows %}
{% autopaginate table_rows page_size %}
<table class="floating striped">
{% if max_matches %}
<caption>
<strong class="num_results">Over {{ max_matches }}</strong> Results
</caption>
{% else %}
@winhamwr
winhamwr / rotate_and_combine_frames.sh
Created April 8, 2012 19:01
Linux timelapse video scripts
#! /bin/bash
set -e;
set -x;
rm -rf build;
mkdir build;
echo "Rotating images";
find *.jpeg -type f -print | xargs -I {} convert {} -rotate 90 build/{};
echo "Building combined mp4"
rm -f time-lapse.mp4;
ffmpeg -i %06d.jpeg -r 30 -s hd480 -vcodec libx264 -vpre hq time-lapse.mp4;