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
from PIL import Image | |
def average_image_color(filename): | |
i = Image.open(filename) | |
h = i.histogram() | |
# split into red, green, blue | |
r = h[0:256] | |
g = h[256:256*2] | |
b = h[256*2: 256*3] |
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
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "pamhutils/messaging/models.py", line 15, in send | |
with JSONAMQPPublisher(amqp_dsn=amqp_dsn, queue=queue) as publisher: | |
File "pamhutils/amqp/publishers.py", line 12, in __init__ | |
self.setup() | |
File "pamhutils/amqp/publishers.py", line 32, in setup | |
promise = self.client.queue_declare(queue=self.queue, durable=True) | |
File "/Users/rtt/.../pamhutils/lib/python2.7/site-packages/puka/client.py", line 19, in wrapper | |
p = method(*args, **kwargs) |
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
b |
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
def itempath(pth, obj): | |
"""Evaluate a dotted 'item path' on object""" | |
parts = pth.split('.', 1) | |
try: | |
parts[0] = int(parts[0]) | |
except ValueError: | |
pass | |
if len(parts) == 1: | |
return obj[parts[0]] |
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
func DecodeJsonToDocCollection (blob []byte) *DocumentCollection { | |
var cont interface{} | |
err := json.Unmarshal(blob, &cont) | |
if err != nil { | |
fmt.Println("Decode error") | |
} | |
response := cont.(map[string] interface{})["response"] |
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
➜ /Users/richtaylor/go/solr ./solr-example | |
Query: *:* | |
Title: adadasdad | |
Latlng: 51.5171,-0.12 | |
Title: 2143wfads22 | |
Latlng: 51.5171,-0.12 | |
Title: asd213 |
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
/* | |
* Similar to python's itertools.izip_longest; | |
* takes an array and chunks it according to a given size | |
*/ | |
func chunk(s []interface{}, sz int) [][]interface{} { | |
r := [][]interface{}{} | |
j := len(s) | |
for i := 0; i < j; i+=sz { | |
r = append(r, s[i:i+sz]) | |
} |
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
> exit() | |
Mon Nov 26 11:46:30 ReferenceError: exit is not defined (shell):1 | |
> | |
> | |
> qut | |
Mon Nov 26 11:46:32 ReferenceError: qut is not defined (shell):1 | |
> quit | |
function () { | |
return nativeHelper.apply(quit_, arguments); | |
} |
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
def valid_loc(loc): | |
'''Validates a lat,lng string value to ensure both lat and lng are within their correct bounds''' | |
try: | |
lng, lat = loc.split(',') | |
lng = float(lng) | |
lat = float(lat) | |
except: | |
pass | |
else: |
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
<?php | |
$converters = array( | |
'string' => function($s) { return $s.' boobs'; }, | |
'integer' => function($i) { return $i + 1; } | |
); | |
$vals = array( | |
1 => 1, | |
'str' => 'moar', |
OlderNewer