Skip to content

Instantly share code, notes, and snippets.

View DazWorrall's full-sized avatar

Darren Worrall DazWorrall

  • UK
  • 01:01 (UTC)
View GitHub Profile
@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 / 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
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 / 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
@DazWorrall
DazWorrall / headers.out
Created January 19, 2018 11:32
Response headers downloading a file from a GCS bucket via storage.cloud.google.com
HTTP/2.0 200 OK
x-guploader-uploadid: AEnB2UpX1g6M8f1SQ2P_fEitVF68n45d9lPxTdCGPjAQYsSE3QKlGJzTuOmSMg2u3LbkRdiE9vkKTFl5wGwq2alhyBFN2OuH5Q
content-type: binary/octet-stream
etag: CKy+lqng4dgCEAE=
vary: Origin, X-Origin
x-goog-generation: 1516286750596908
x-goog-hash: crc32c=UekceA==,md5=QfHUMNq1qX9LyLU1hdQD7Q==
x-goog-metageneration: 1
x-goog-storage-class: MULTI_REGIONAL
cache-control: no-cache, no-store, max-age=0, must-revalidate
@DazWorrall
DazWorrall / iptables_policy.py
Created July 22, 2016 09:41
Ansible module to set the default policy on an iptables chain, tested on Debian and derivatives
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import os
import re
def get_policy(module, table, chain):
command = ['iptables', '-t{}'.format(table), '-L{}'.format(chain)]
rc, out, err = module.run_command(command)
if rc != 0:
raise RuntimeError("Unable to get policy: {}".format(err))
@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 / 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 / carbon-cache-1.log
Created January 29, 2016 11:32
1 carbon-relay in front of 4 x carbon-cache
29/01/2016 11:28:48 :: [query] 127.0.0.1:48390 connected
29/01/2016 11:28:48 :: [query] [127.0.0.1:48390] cache query bulk for "6" metrics returned 477 values
29/01/2016 11:28:48 :: [query] [127.0.0.1:37758] cache query bulk for "32" metrics returned 2025 values
29/01/2016 11:28:53 :: [query] [127.0.0.1:37758] cache query bulk for "33" metrics returned 1897 values
@DazWorrall
DazWorrall / logstash.conf
Last active November 3, 2015 12:00
Grok config for Magento exception.log
input {
file {
path => "/path/to/exception.log"
type => "magento_exception"
codec => multiline {
pattern => "^%{TIMESTAMP_ISO8601}"
negate => true
what => "previous"
}
}