- Name: Guangzhou Xinyue Electronics Co., Ltd.
- Website: yx080.com
- Tel: 020-36776060
- Mobile: 13751729917
- Email: lur@yxin18.com
- QQ:1553069551
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 Descriptor: | |
... def __get__(self, instance, owner): | |
... print('__get__', instance, owner) | |
... print('called on a', 'class' if instance is None else 'instance') | |
... | |
>>> class Class: | |
... foo = Descriptor() | |
... | |
>>> Class.foo | |
__get__ None <class '__main__.Class'> |
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 io import BytesIO | |
from PIL import Image | |
def scale_image_max_width(image_bytes, max_width): | |
"""Scale ``image`` to honor the ``max_width`` constraint. | |
""" | |
image = Image.open(BytesIO(image_bytes)) |
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 find_fabfile(names=None): # pylint: disable=unused-argument | |
"""The absolute path of the cloudfab fabfile. | |
""" | |
return abspath(dirname(__file__)) |
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
help: | |
@cat README | |
server: | |
openssl req -new -config etc/server.conf -out certs/$(FQDN).csr -keyout certs/$(FQDN).key | |
openssl ca -config etc/signing-ca.conf -in certs/$(FQDN).csr -out certs/$(FQDN).crt -extensions server_ext | |
user: | |
openssl req -new -config etc/user.conf -out certs/$(NAME).csr -keyout certs/$(NAME).key | |
openssl ca -config etc/signing-ca.conf -in certs/$(NAME).csr -out certs/$(NAME).crt -extensions user_ext |
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 add(x, y): | |
return x + y | |
def dummy_decorator(func): | |
"""This decorator does NOT modify ``func`` behavior. | |
It only prints stuff. | |
""" | |
print 'creating wrapper' |
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 time | |
import logging | |
LOGGER = logging.getLogger(__name__) | |
class DurationLogger(object): | |
"""Log run time duration of an operation. |
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
$ puppet -V | |
2.7.17 | |
$ cat /tmp/wtf.pp | |
class foo { | |
warning('foo') | |
} | |
class bar::foo { |
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 | |
facter --timing 2>&1 | perl -ne '/^(.*): (\d+\.\d+)ms/ && print $2 . " " . $1 . "\n"' | sort -nu |
NewerOlder