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
#ifdef GL_ES | |
precision highp float; | |
#endif | |
uniform sampler2D from, to; | |
uniform float progress; | |
uniform vec2 resolution; | |
uniform sampler2D lumaTex; | |
uniform bool invertLuma; | |
uniform float softness; |
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
import httplib | |
import filedata | |
def post_multipart(host, selector, files): | |
""" | |
Post files to an http host as multipart/form-data. | |
files is a sequence of (name, filename, value) elements for data to be uploaded as files | |
Return the server's response page. | |
""" |
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
import Foundation | |
typealias KVObserver = (source: NSObject, keyPath: String, change: [NSObject : AnyObject]) -> Void | |
class KVOContext { | |
private let source: NSObject | |
private let keyPath: String | |
private let observer: KVObserver | |
func __conversion() -> UnsafeMutablePointer<KVOContext> { |
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
{ | |
"Type" : "Notification", | |
"MessageId" : "d9217124-7fde-5ce1-9382-3d9cd955c2f8", | |
"TopicArn" : "arn:aws:sns:us-west-2:262456549263:NotificationDeliveryFailure-play", | |
"Subject" : "DeliveryFailure event for app com.cureatr.messenger.play (MPNS)", | |
"Message" : "{\"DeliveryAttempts\":1,\"EndpointArn\":\"arn:aws:sns:us-west-2:262456549263:endpoint/MPNS/com.cureatr.messenger.play/23d917f8-25ba-36ff-bf08-b5da28402d83\",\"EventType\":\"DeliveryFailure\",\"FailureMessage\":\"mpns behaved in an unexpected way\",\"FailureType\":\"DeliveryFailedPerm\",\"MessageId\":\"258d8a40-1e8c-553b-b3d5-c6f8b807e695\",\"Resource\":\"arn:aws:sns:us-west-2:262456549263:app/MPNS/com.cureatr.messenger.play\",\"Service\":\"SNS\",\"Time\":\"2014-10-15T16:43:55.894Z\"}", | |
"Timestamp" : "2014-10-15T16:43:55.945Z", | |
"SignatureVersion" : "1", | |
"Signature" : "a5jaug9K3/H6DTps492z9SUXHPKMtm1oGI43aKBoykI2ikR8y7SZXPAfcsqWROAnWz3EJxRlXUklLXWBx2AFMH8Twiroi8thjrXhB2HQpAaMC7Z/zkg8yYcFrHS79UcIVhjIOAptIgC6Pdpele+Y/moiU8vETI2TKtsRfYgrvyCnQ89fW |
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
>>> class F(object): | |
... __class__ = list | |
... | |
>>> f = F() | |
>>> f.__class__ | |
<type 'list'> | |
>>> isinstance(f, F) | |
True | |
>>> isinstance(f, list) | |
True |
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
[aw@jello tmp] $ python sort-slice.py | |
45920256 | |
[aw@jello tmp] $ python sort-heapq.py | |
5808128 |
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
struct tm time; | |
strptime("1934-11-02T10:45:11", "%FT%T%z", &time); | |
long ts = timegm(&time); | |
NSDate *d = [NSDate dateWithTimeIntervalSince1970:ts]; | |
NSLog(@"%@", d); |
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 abc import ABCMeta | |
class ListLike: | |
__metaclass__ = ABCMeta | |
ListLike.register(list) | |
ListLike.register(tuple) | |
ListLike.register(_FieldSequence) | |
>>> isinstance([], ListLike) |
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
class Enum(object): | |
def __init__(self, **kwargs): | |
self._values = set() | |
for k, v in kwargs.items(): | |
setattr(self, k, v) | |
self._values.add(v) | |
def validate(self, values): | |
return set(values).issubset(self._values) |
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
bounds_w = 100 | |
bounds_h = 100 | |
im_w, im_h = im.size | |
scales = (bounds_w / im_w, bounds_h / im_h) | |
if scale_type == "meet": | |
scale = min(scales) | |
elif scale_type == "fill": | |
scale = max(scales) |