I discovered that you can use hilite.me to format source code so it looks nice on blogger.
Paste the source into hilite.me. It gives you pretty html that you can paste into an html editor
print("Hello World");
This blog helps me keep track of programming tricks I've learned, so I don't forget them later
I discovered that you can use hilite.me to format source code so it looks nice on blogger.
Paste the source into hilite.me. It gives you pretty html that you can paste into an html editor
print("Hello World");
I'm writing a library file for django, and I want it to store settings in the settings.py file, which is django's default configuration location for settings. However, I still want the library to work if django isn't installed. Here's how I did it :
This way, it doesn't crash if the reference doesn't exist
try: from django.conf import settings except ImportError: pass
Research online said python doesn't have a direct way to check if the reference exists, so you can use a try / except block instead
try: settings except NameError: settings = None
If settings exists, use the django settings.py file. Otherwise use a flat file
if settings != None: if not settings.configured: settings.configure() self._key_list = settings.MY_LIB_SETTINGS else: filename = "lib_api_config.txt" f = open(filename,"r") file_contents = f.read() f.close() self._key_list = json.loads(file_contents)
The edit api page has a sample html / javascript code that you can put on your server to display a "Hello World" type application that displays a map.
I had some issues, which I've noted above
<table id="tbData">You set up a template like this :
<tr><td>Name</td><td>Phone</td></tr>
<div id="phoneList">
</div>
</table>
<script id="phoneTmp" type="text/x-jquery-tmpl">If you do this, your header will show up at the bottom of the table in Firefox, but Internet Explorer will hate you. Or you will hate Internet Explorer. One of those. I get confused. The solution : use tbody tags instead of div tags when you're inserting, showing, or hiding rows in a table with jquery. This forces me to break my longstanding policy of not using any html tags developed after 2000, but it's saved me a lot of headaches.
<tr><td>${firstname},${lastname}</td><td>${address}</td><td>${phone}</td></tr>
</script>
<table id="tbData">Click "Result", or the little "play" arrow to see what this code does
<tr><td>Name</td><td>Phone</td></tr>
<tbody id="phoneList">
</tbody>
</table>