This file contains hidden or 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
# Add this to your .bash_profile | |
function git_init_fnc () { | |
\git "$@" | |
if [[ $1 == "init" ]];then | |
if [[ -n "$2" ]]; then | |
git_dir="$2"; | |
else | |
git_dir=`pwd`; | |
fi |
This file contains hidden or 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 python:2-alpine | |
RUN apk add --no-cache gphoto2 | |
RUN pip install --no-cache requests | |
RUN mkdir /root/.gphoto | |
ADD gphoto-settings /root/.gphoto/settings | |
ADD sony-pm-alt/sony-pm-alt.py /sony-pm-alt.py | |
VOLUME /var/lib/Sony | |
CMD exec python /sony-pm-alt.py |
This file contains hidden or 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 python | |
# | |
# Building a tar file chunk-by-chunk. | |
# | |
# This is a quick bit of sample code for streaming data to a tar file, | |
# building it piece-by-piece. The tarfile is built on-the-fly and streamed | |
# back out. This is useful for web applications that need to dynamically | |
# build a tar file without swamping the server. | |
from io import BytesIO | |
from os import walk |
This file contains hidden or 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 os | |
import pickle | |
import operator | |
from snimpy import mib, manager | |
from snimpy.smi import smi, ffi | |
_cache_file = '/tmp/smi_mib_cache' | |
class LazyLoad(object): |
This file contains hidden or 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 weakref | |
import threading | |
from twisted.python.threadpool import ThreadPool | |
from crochet import EventualResult | |
_blocked_pool_threads = weakref.WeakKeyDictionary() | |
_orig_pool_limits = weakref.WeakKeyDictionary() | |
_originals = {} |
This file contains hidden or 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 os | |
import re | |
import StringIO | |
import cStringIO | |
import contextlib | |
# caching the compilation of the regex used | |
# to check for lookup calls within data | |
LOOKUP_REGEX=re.compile(r'lookup\s*\(') |
This file contains hidden or 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
diff --git c/lib/ansible/utils/__init__.py i/lib/ansible/utils/__init__.py | |
index 5da39ac..696f1a7 100644 | |
--- c/lib/ansible/utils/__init__.py | |
+++ i/lib/ansible/utils/__init__.py | |
@@ -33,7 +33,7 @@ from ansible.module_utils.splitter import split_args, unquote | |
import ansible.constants as C | |
import ast | |
import time | |
-import StringIO | |
+import cStringIO |
This file contains hidden or 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 <dlfcn.h> | |
int | |
PreInit() { | |
void* cocoa_lib; | |
cocoa_lib = dlopen( "/System/Library/Frameworks/Cocoa.framework/Cocoa", RTLD_LAZY ); |
This file contains hidden or 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
f = open('file.txt', 'w') | |
f.write('hi') | |
f.close() | |
# Better | |
with open('file.txt', 'w') as f: | |
f.write('hi') | |
with pytest.raises(ValueError): | |
int('hi') |
This file contains hidden or 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/python | |
''' | |
From gdb 7 onwards, gdb's build can be configured --with-python, allowing gdb | |
to be extended with Python code e.g. for library-specific data visualizations, | |
such as for the C++ STL types. Documentation on this API can be seen at: | |
http://sourceware.org/gdb/current/onlinedocs/gdb/Python-API.html | |
This python module deals with the case when the process being debugged (the | |
"inferior process" in gdb parlance) is itself python, or more specifically, |
NewerOlder