Skip to content

Instantly share code, notes, and snippets.

View DazWorrall's full-sized avatar

Darren Worrall DazWorrall

  • UK
  • 18:01 (UTC +01:00)
View GitHub Profile
@DazWorrall
DazWorrall / Output
Created February 9, 2012 13:06
Testing file upload handling in Flask
in upload handler
in file close
..
----------------------------------------------------------------------
Ran 2 tests in 0.021s
OK
@DazWorrall
DazWorrall / out.log
Created December 31, 2023 11:16
unifi-protect-backup error
2023-12-31 11:13:12 [ ERROR ] pyunifiprotect.websocket : Error processing websocket message
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/pyunifiprotect/websocket.py", line 82, in _process_message
sub(msg)
File "/usr/lib/python3.11/site-packages/pyunifiprotect/api.py", line 691, in _process_ws_message
processed_message = self.bootstrap.process_ws_packet(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/pyunifiprotect/data/bootstrap.py", line 561, in process_ws_packet
return self._process_remove_packet(packet, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@DazWorrall
DazWorrall / foo.rb
Created March 1, 2019 09:39
Redis sorted sets with timestamps for scores
require 'redis'
require 'active_support/time'
redis = Redis.new
# members are added with a score that is a timestamp of when they should expire
redis.zadd('test-sset', 10.minutes.from_now.to_i, 'app1')
# let's add one in the past so we can test some more
redis.zadd('test-sset', 10.minutes.ago.to_i, 'app2')
@DazWorrall
DazWorrall / app.py
Created July 26, 2012 07:54
Flask maintenance mode
from flask import Flask, redirect, url_for, request
app = Flask(__name__)
is_maintenance_mode = True
# Always throw a 503 during maintenance: http://is.gd/DksGDm
@app.before_request
def check_for_maintenance():
@DazWorrall
DazWorrall / interfaces
Created February 11, 2016 15:04
Interfaces file with vlans and vxlans
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
@DazWorrall
DazWorrall / strapwrap.sh
Created December 13, 2012 15:42
Little script to create a minimal ubuntu using debootstrap and bring it up to date
#!/bin/bash
set -e
DEFAULT_PACKAGES=ssh,language-pack-en-base
DEFAULT_COMPONENTS=main,universe
DEBOOTSTRAP=/usr/sbin/debootstrap
DEFAULT_MIRROR=http://archive.ubuntu.com/ubuntu
DEFAULT_VARIANT=minbase
MIRROR=${STRAP_MIRROR:-$DEFAULT_MIRROR}
ROOTFS=$1
@DazWorrall
DazWorrall / config.json
Created March 22, 2016 09:21
Faking RHEV in qemu under packer so that cloud init takes its user data from a floppy disk
{
"builders":
[
{
"type": "qemu",
"output_directory": "output",
"iso_url": "trusty-server-cloudimg-amd64-disk1.img",
"iso_checksum": "cf12c9878c9fb71c95d8f8c288761a99",
"iso_checksum_type": "md5",
"ssh_wait_timeout": "300s",
@DazWorrall
DazWorrall / flick.py
Created November 26, 2012 13:59
Find a random image on flickr
#!/usr/bin/env python
'''
$ pip install flickrapi
....
$ FLICKR_API_KEY=mykey ./flick.py tag1[,tag2,tag3...]
'''
# http://www.flickr.com/services/api/flickr.photos.search.html
import flickrapi
@DazWorrall
DazWorrall / zoom_toggle.py
Last active June 26, 2019 13:10
Figuring out kitty stack layout with borders
def main(args):
pass
def enable_borders(tab):
tm = tab.tab_manager_ref()
if tm is None:
return
w = tab.active_window
tab.borders(
[w], w, tab.current_layout, tm.blank_rects, True
@DazWorrall
DazWorrall / foo.rb
Last active February 28, 2019 12:51
This inheritance behaviour gets me every time
class Foo
A = true
def m
A
end
def n
self.class::A
end