Skip to content

Instantly share code, notes, and snippets.

@alexhayes
alexhayes / Reaper DDP Creation, Verification & Burn.rst
Last active December 11, 2022 06:08
Reaper DDP Creation, Verification and Burn Instructions.

DDP Creation, Verification & Burn

DDP creation, verification & burn using Reaper, ddpinfo and ImgBurn.

Reaper

TLDR

class OrderedDictSerializer(serializers.ListSerializer):
"""
django-rest-framework serializer that a list or queryset into an OrderedDict.
"""
def to_representation(self, data):
"""
OrderedDict of object instances -> OrderedDict of dicts of primitive datatypes.
"""
# Dealing with nested relationships, data can be a Manager,
@alexhayes
alexhayes / Force All Email Delivery To A Single Email Address.rst
Last active December 8, 2015 00:27
Force all email delivery in Ubuntu to a particular address

Force All Email Delivery To A Single Email Address

So, you're a developer testing lots of codes and you want to ensure that you don't accidentally send out email to people during testing.

However, you also want to actually view emails in a real email client, not a console.

This is how you can do it using Ubuntu and Exim ensuring that the email gets sent out through Google apps.

@alexhayes
alexhayes / ReactPureRenderMixinInES6.jsx
Created November 10, 2015 11:32
react-addons-pure-render-mixin using ES6 classes in React
import React from 'react'
import {shouldComponentUpdate} from 'react-addons-pure-render-mixin'
export default class extends React.Component {
shouldComponentUpdate = shouldComponentUpdate
static propTypes ={
disabled: React.PropTypes.bool,
}
}
@alexhayes
alexhayes / australian-postcodes.sql
Created October 19, 2015 04:10 — forked from randomecho/australian-postcodes.sql
Australian postcodes (with states and suburb names) geocoded with latitude and longitude.
/*
Taken and cribbed from blog.datalicious.com/free-download-all-australian-postcodes-geocod
May contain errors where latitude and longitude are off. Use at own non-validated risk.
*/
SET NAMES utf8;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS postcodes_geo;
@alexhayes
alexhayes / .multitailrc
Last active September 8, 2021 08:57
multitail python log formatting
colorscheme:python-log
cs_re_s:blue:[DEBUG|INFO|WARNING|CRITICAL|ERROR] ([a-z\.0-9\_]+):
cs_re_s:white,magenta,bold:(\sDEBUG\s)
cs_re:magenta:.*DEBUG.*
cs_re_s:white,green,bold:(\sINFO\s)
cs_re:green:.*INFO.*
cs_re_s:white,yellow,bold:(\sWARNING\s)
cs_re:yellow:.*WARNING.*
cs_re_s:white,red,bold:(\sCRITICAL\s)
cs_re:red:.*CRITICAL.*
@alexhayes
alexhayes / README.md
Created June 15, 2015 02:01
Celery Model Serializer

Usage

app = Celery('myapp')

@app.task(serializer='django-model')
def test(x):
    print x
    
obj = MyModel.objects.get(pk=12)
@alexhayes
alexhayes / celery.py
Last active August 29, 2015 14:22
Setup celery logging with worker name in format
from celery.signals import celeryd_init, after_setup_task_logger
app = Celery('myapp')
# ...
# ...
# ...
@celeryd_init.connect
def configure_workers(sender=None, conf=None, **kwargs):
@alexhayes
alexhayes / doesnt-work.log
Created March 3, 2015 22:29
Celery task signature passed as dict
[2015-03-04 09:15:15,852: INFO/MainProcess] Received task: meh.tasks.a[ac7bb67f-5cc2-4c38-8608-66bf7dbdd7c1]
[2015-03-04 09:15:15,852: INFO/MainProcess] Received task: meh.tasks.a[d252459b-87d7-4ed5-a73d-af30eb748317]
[2015-03-04 09:15:15,852: INFO/MainProcess] Received task: meh.tasks.a[9d628c31-2529-40e7-8e94-09a93351b5e5]
[2015-03-04 09:15:15,853: INFO/MainProcess] Received task: meh.tasks.a[a07b2dff-089b-40cb-8f2a-c17011296db3]
[2015-03-04 09:15:15,854: WARNING/Worker-8] ~~~A~~~
[2015-03-04 09:15:15,854: WARNING/Worker-7] ~~~A~~~
[2015-03-04 09:15:15,854: WARNING/Worker-4] ~~~A~~~
[2015-03-04 09:15:15,854: WARNING/Worker-8] 3
[2015-03-04 09:15:15,854: WARNING/Worker-7] 2
[2015-03-04 09:15:15,854: WARNING/Worker-4] 1
@alexhayes
alexhayes / README.md
Last active August 29, 2015 14:11
SLS require that only has an include fails

It appears that if you have a require with sls: foo and foo.sls itself only has include: statements the requirement fails.

When the command salt \* state.highstate test=True the following is output;

example.com:
----------
          ID: eggs
    Function: cmd.run
 Name: echo "I should be required..."