Skip to content

Instantly share code, notes, and snippets.

View donspaulding's full-sized avatar

Don Spaulding donspaulding

  • Mirus Research
  • Normal, IL
View GitHub Profile
@donspaulding
donspaulding / pooFlinger.js
Created July 13, 2015 21:32
Continually fling poo at someone...
'use strict';
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
function flingPoo(){
res.write("💩");
setTimeout(flingPoo, 1000);
}
flingPoo();
@donspaulding
donspaulding / csr_creation.py
Created September 11, 2014 20:58
Generating a CSR from python using sh
def generate_csr(domain):
import tempfile
import shutil
from sh import openssl
csr_data = "/C=%s/ST=%s/L=%s/O=%s/CN=www.%s" % (
domain.country.upper(),
domain.full_state,
domain.city,
domain.letterhead_name,
class MyBaseViewSet(viewsets.ModelViewSet):
def get_nested_serializer_class(self, serializer_class, related_name):
lookup_key = (serializer_class, related_name)
return serializers.NESTED_SERIALIZER_FIELD_MAP[lookup_key]
def get_serializer(self, *args, **kwargs):
serializer = super(MyBaseViewSet, self).get_serializer(*args, **kwargs)
context = self.get_serializer_context()
embed_str = context['request'].QUERY_PARAMS.get('embed', '')
if not embed_str:
def partially_nested(serializer, include_fields=None, exclude_fields=None):
partial_fields = set(include_fields or []) - set(exclude_fields or [])
serializer.opts.exclude = tuple(
set(serializer.get_fields()) - set(partial_fields)
)
serializer.fields = serializer.get_fields()
return serializer
@donspaulding
donspaulding / tiffwrapper.py
Created April 16, 2013 22:49
A pretty decent way to wrap the libtiff command-line tools from python. Pretty decent, that is, until you remember that `sh` exists and works even better... http://amoffat.github.io/sh/
import subprocess
def create_libtiff_tool(command_name):
try:
help_str = subprocess.check_output(
command_name,
stderr=subprocess.STDOUT
)
except subprocess.CalledProcessError, e:
help_str = e.output
@donspaulding
donspaulding / dabblet.css
Created December 23, 2011 15:08
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
/*background: linear-gradient(45deg, #f06, yellow);*/
min-height:100%;
@donspaulding
donspaulding / npm-debug.log
Created September 23, 2011 21:33
NPM install failure
don@box:~/Development/node/node/out/Release $ curl http://npmjs.org/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5100 100 5100 0 0 13892 0 --:--:-- --:--:-- --:--:-- 96226
fetching: http://registry.npmjs.org/npm/-/npm-1.0.30.tgz
0.5.5
1.0.30
cleanup prefix=/Users/don/Development/node/node/out
find: /Users/don/Development/node/node/out/share/man: No such file or directory
find: /Users/don/Development/node/node/out/share/man: No such file or directory