I needed to be able to filter which items of a ManyRelatedField
were returned, based on some attributes of the request user. Normally, all items in the relationship are returned, however I was able to override the ManyRelatedField.to_attribute()
function to enable additional filtering of the relationship.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"golang.org/x/crypto/openpgp" | |
"os" | |
) | |
func main() { | |
keyRingReader, err := os.Open("signer-pubkey.asc.txt") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import hashlib | |
import os | |
import base64 | |
from datetime import datetime | |
username = "admin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# As the "bufferbloat" folks have recently re-discovered and/or more widely | |
# publicized, congestion avoidance algorithms (such as those found in TCP) do | |
# a great job of allowing network endpoints to negotiate transfer rates that | |
# maximize a link's bandwidth usage without unduly penalizing any particular | |
# stream. This allows bulk transfer streams to use the maximum available | |
# bandwidth without affecting the latency of non-bulk (e.g. interactive) | |
# streams. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverseIp6 { | |
echo "$1" | awk -F: 'BEGIN {OFS=""; }{addCount = 9 - NF; for(i=1; i<=NF;i++){if(length($i) == 0){ for(j=1;j<=addCount;j++){$i = ($i "0000");} } else { $i = substr(("0000" $i), length($i)+5-4);}}; print}' | rev | sed -e "s/./&./g" | |
} | |
$(reverseIp6 "2001:db8:85a3::8a2e:370:7334")"ip6.arpa." | |
#Result: 4.3.3.7.0.7.3.0.e.2.a.8.0.0.0.0.0.0.0.0.3.a.5.8.8.b.d.0.1.0.0.2.ip6.arpa. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// Based on documentation found here: http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html | |
import ( | |
"crypto/hmac" | |
"crypto/sha1" | |
"encoding/hex" | |
"fmt" | |
"github.com/ncw/swift" |
- Emacs: shell-command-on-region
- Command: tmux load-buffer -
export EVENT_NOEPOLL=1 tmux/tmux#416
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On supervisor: | |
lvextend -L50G /dev/vg_kvmhost01/test-01.img | |
virsh qemu-monitor-command util-02 --hmp "info block" | |
virsh qemu-monitor-command util-02 --hmp "block_resize drive-virtio-disk0 50G" | |
On VM: | |
http://unix.stackexchange.com/a/42910 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Python IMAP with TLS/SSL support """ | |
## | |
## Author: Alexander Brill <alex@brill.no> | |
## Copyright (C) 2004 Alexander Brill | |
## | |
## This program is free software; you can redistribute it and/or | |
## modify it under the terms of the GNU General Public License | |
## as published by the Free Software Foundation; either version 2 | |
## of the License, or (at your option) any later version. | |
## |
I hereby claim:
- I am lsowen on github.
- I am lsowen (https://keybase.io/lsowen) on keybase.
- I have a public key whose fingerprint is 337C E5E0 6C9E 3677 CCC7 1A40 FECD 001B C751 40C0
To claim this, I am signing this object:
NewerOlder