Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Owlstone - Chemical Detection and Chemical Sensing</title>
<link href="https://plus.google.com/103452364153605968626" rel="publisher" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="x-dns-prefetch-control" content="on" />
<link rel="dns-prefetch" href="//www.owlstone.net" />
@mozz100
mozz100 / python-package-update.sh
Last active August 29, 2015 14:05
Patch updates for pinned python packages
# Use sed to replace '==x.y' with '<x.y.999'
# and save results to a file
sed -r -e "s/==([0-9]+\.[0-9]+)(\..+)?/<\1.999/" requirements.txt > /tmp/requirements2.txt
# It works by transforming the file like this:
# Django==1.4.8 >> Django<1.4.999
# Jinja2==2.5 >> Jinja2<2.5.999
# M2Crypto==0.19.1 >> M2Crypto<0.19.999
# MySQL-python==1.2.5 >> MySQL-python<1.2.999
# Pillow==2.5.1 >> Pillow<2.5.999
@mozz100
mozz100 / bookmarklet.js
Created June 26, 2014 09:20
Bookmarklet: Jump between envisage staging/production
javascript:(function(){var where=document.location.toString();if(where.indexOf('envisage-system.co.uk')>=0){document.location=where.replace('envisage-system.co.uk','envisage-staging.co.uk');}if(where.indexOf('envisage-staging.co.uk')>=0){document.location=where.replace('envisage-staging.co.uk','envisage-system.co.uk');}})()
@mozz100
mozz100 / pdf_magic.js
Last active July 27, 2017 00:48
Zendesk embedded PDF viewer via Google Docs
// add this javascript to your Zendesk Help Center pages
(function($) {
$(function() {
// for all attachment links whose URLs end with .pdf (case sensitive)...
var pdfs = $('.attachments a[href$=".pdf"]');
var eleBody = $('div.article-body');
if (pdfs.length > 0) {
@mozz100
mozz100 / renamer.py
Created May 11, 2014 20:41
Rename files in order, move to a directory
#!/usr/bin/python
import sys, csv, os, shutil
pattern = "Vol09-%04d.jpg"
original_filename = sys.argv[1]
output_path = sys.argv[2]
output_csv = os.path.join(output_path, "original_filenames.csv")
next_index = 0
@mozz100
mozz100 / xbee.js
Last active April 16, 2016 21:48
Node.js, xbee and promises
var SerialPort = require('serialport').SerialPort;
var xbee_api = require('xbee-api');
var C = xbee_api.constants;
var Q = require('q');
// following settings work for me on my Raspberry pi, your config may differ!
var xbeeAPI = new xbee_api.XBeeAPI({
api_mode: 1
});
var serialport = new SerialPort("/dev/ttyAMA0", {
@mozz100
mozz100 / mozzicon.py
Last active December 26, 2015 10:09
Mozzicon: html/python implementation of https://github.com/cupcake/sigil
def mozzicon(md5):
# Inspired by (!) https://github.com/cupcake/sigil
# return a 5 by 5 grid of divs with horizontal plane of symmetry
# (css used to rotate by 90deg)
# md5 is a string like "9eadbe04ba0a832eecbd0a27f563e0a6"
# use first char of hash to pick a color from 7
colors = ('2d4fff', 'feb42c', 'e279ea', '1eb3fd', 'e84d41', '31cb73', '8d45aa', )
@mozz100
mozz100 / gmail_snooze.js
Created October 22, 2013 14:48
GMail snooze, with some mozz modifications
// see http://googleappsdeveloper.blogspot.co.uk/2011/07/gmail-snooze-with-apps-script.html
// Should be set to run every day at midnight, and moves emails one label 'nearer' to the inbox
var MARK_UNREAD = false;
var ADD_UNSNOOZED_LABEL = true;
function getLabelName(i) {
return "Snooze/Snooze " + i + " days";
}
@mozz100
mozz100 / utc-timestamp.py
Created October 1, 2013 09:13
Get UTC timestamp in python. Is there a better way? This seems highly verbose.
from datetime import tzinfo, timedelta, datetime
import calendar
class UTC(tzinfo):
"""UTC"""
def utcoffset(self, dt):
return timedelta(0)
def tzname(self, dt):
return "UTC"
def dst(self, dt):
return timedelta(0)
@mozz100
mozz100 / collapse_categories.js
Last active December 15, 2015 04:49 — forked from Mikhail-Zakharov/Collapse categories_Ver2.js
Add this as a global javascript widget in Zendesk to achieve collapsible category headers.
var collapsed_by_default = false; // set this to true if you prefer collapsed by default
function HideCategory(id, IsAgent, animation) {
// Function hides category
$j("div#category_" + id).hide(animation);
SetDownArrow(id, IsAgent);
$j.cookie('hide_category_' + id, 'yes', { expires: 180 });
$j("div#category_header_" + id).attr("onclick", "ShowCategory(" + id + "," +IsAgent+ ",'blind')");
};