Skip to content

Instantly share code, notes, and snippets.

@mx-moth
mx-moth / event-crash.js
Created December 24, 2010 05:13
This program will segfault when the second text box is focused.
#!/usr/bin/env node
var fs, gtk;
gtk = require('node-gtk');
fs = require('fs');
process.nextTick(function() {
var crasher, good, event, hbox, submit, window, i, len;
gtk.init();
@mx-moth
mx-moth / index.html
Created May 17, 2012 05:43
General sibling selector + checkboxes = awesome
<!doctype html>
<html lang="en-AU">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" media="screen" href="style.css">
</head>
<body>
#!/usr/bin/env python
import sys
import subprocess
colour_codes = {
'none': '\033[0m',
'red': '\033[91m',
'green': '\033[92m',
'yellow': '\033[93m',

Thinking this idea out to its fullest extent, brings up five possible forms:

  1. Always output content, assignment via as varname is not allowed. The built in {% now %} is an example.
  2. Always output content, assignment via as varname is optional. The built in {% cycle %} is an example.
  3. Some times output, some times assign, depending upon the presence of as varname. The built in {% url %} is an example.
  4. Always assign, as varname is optional. There is no built in example.
  5. Always assign, as varname is required. The built in {% regroup %} is an
@mx-moth
mx-moth / syncdir
Last active December 26, 2015 06:59
A bash script to copy music to my phone. The phone/mtpfs has issues staying connected, and file transfer speed is not great, so I did not want to overwrite existing files. MTP does not support renaming files, so `rsync` did not work. Finally, FAT does not support some characters in filenames (sorry, GY!BE, "Motherfucker=redeemer" does not work),…
#!/bin/bash
# A dodgy ripoff of rsync for my music files
#
# Usage: To copy the contents of "Zechs Marquise/Getting Paid/" and "Grails/"
# from your music library to your mounted phone:
#
# syncdir --source $HOME/Music \
# --destination /mnt/phone/Music \
# "Zechs Marquise/Getting Paid/" \
# "Grails/"
@mx-moth
mx-moth / crontab
Last active December 28, 2015 22:49
Set your desktop background to the latest image from NASAs Solar Dynamics Observatory.
# The images from the SDO are updated every 15 minutes, so this script should only be run every 15 minutes.
DISPLAY=:0
4-59/15 * * * * $HOME/sdo-update --silent --type "0171" --screen "screen0/monitor0"
5-59/15 * * * * $HOME/sdo-update --silent --type "0193" --screen "screen0/monitor1"
{% for user_item in user_items %}
<div class="item">
{% include "item.html" with item=user_item.item %}
</div>
<div class="actions">
<form action="{% url "mark_read" user_item_id=user_item.id %}" method="post">
<button>Mark as read</button>
</form>
</div>
{% endfor %}
@mx-moth
mx-moth / feed.html
Last active December 30, 2015 08:09
<form action="{% url 'mark_as_read' %}" method="post">
{{ mark_all_as_read_form }}
<button>Mark all as read</button>
</form>
{% for user_item, mark_as_read_form in user_items_forms %}
{% include "item.html" with item=user_item.item %}
<form action="{% url 'mark_as_read' %}" method="post">
{{ mark_as_read_form }}
<button>Mark as read</button>
@mx-moth
mx-moth / jquery.pluginName.js
Last active December 31, 2015 05:19
My preferred jQuery plugin boilerplate. Copy this in, replace 'pluginName'/PluginClass with your preferred name, and go
(function($) {
"use strict";
var pluginName = 'pluginName';
var PluginClass = function(el, options) {
this.$el = $(el);
// Set options for this instance, inheriting from the default options
this.opts = $.extend({}, plugin.defaults, options);
@mx-moth
mx-moth / daemontool run file
Created December 28, 2013 11:58
We use a combination of nginx and to run our Django things at work. It works well. The relevant configs are attached. http://cr.yp.to/daemontools.html
#!/usr/bin/env bash
type='django'
site='timheap.me'
project='tfs-roster'
sitepath="/var/www/$site/$project"
pid="$sitepath/var/pid"
socket="$sitepath/var/socket"
source "$sitepath/venv/bin/activate"