Harry Percival @hjwp www.obeythetestinggoat.com www.pythonanywhere.com
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 subprocess | |
script = '/home/harry/.virtualenvs/my-project-name/bin/postactivate' # eg | |
env_to_json = 'import os, json; print(json.dumps(dict(os.environ)))' | |
environ_json = subprocess.check_output( | |
'. {} && python -c "{}"'.format(script, env_to_json), | |
shell=True, env={} | |
) | |
os.environ.update(json.loads(environ_json.decode('utf8'))) |
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
get_ipython().system(u'sqlite3 my.db') |
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
<script type="text/javascript"> | |
$(function() { | |
// normal application code goes here | |
// eg initialize Ace text editor | |
MyApp.do.myStuff("etc"); | |
// ... and then "reinitialize" togetherjs so that it finds all our dynamic ui stuff | |
TogetherJS.reinitialize(); | |
}); | |
</script> | |
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
def absolute(fn): | |
# this decorator currently does nothing | |
def modified_fn(x): | |
return fn(x) | |
return modified_fn | |
def foo(x): | |
return 1 - x |
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
x = None | |
class Parent: | |
def foo(self): | |
return 'parent' | |
class Child(Parent): | |
def foo(self): | |
if x: | |
return x |
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 ubuntu:trusty | |
MAINTAINER [email protected] | |
# Add the PostgreSQL PGP key to verify their Debian packages. | |
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc | |
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 | |
# Add PostgreSQL's repository. It contains the most recent stable release | |
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main 9.4" > /etc/apt/sources.list.d/pgdg.list |
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
grep "class.\+Test" appname/tests/test_file.py | awk '{print $2;}' | awk -F"(" '{print "appname."$1}' | xargs python manage.py test |
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 a/chapter_01.asciidoc b/chapter_01.asciidoc | |
index bee486f..f46cd90 100644 | |
--- a/chapter_01.asciidoc | |
+++ b/chapter_01.asciidoc | |
@@ -265,25 +265,24 @@ Next we can add the rest of the contents of the current folder, `.`: | |
---- | |
$ *git add .* | |
$ *git status* | |
-# On branch master | |
-# |
This Gist is just a minimal repro of a bug (I think) in Django's LiveServerTestCase.
Once a site has some static files (eg CSS), then clicking on a link produces an ugly uncaught exception from the LiveServer thread, like this:
Exception happened during processing of request from ('127.0.0.1', 1925)
Traceback (most recent call last):
File "c:\Python33\lib\site-packages\django\test\testcases.py", line 1035, in _handle_request_noblock
self.process_request(request, client_address)
File "c:\Python33\lib\socketserver.py", line 332, in process_request