A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
// class w/construct | |
var happy = function (msg) { | |
this.message = msg; | |
}; | |
// method | |
happy.prototype.hello = function(){ | |
console.log('hi'); | |
console.log(this.message) | |
} |
d = dict() | |
d['a'] = 1 | |
d.update( | |
{ | |
'a': 2 | |
} | |
) | |
print d |
import calendar | |
from time import gmtime | |
print calendar.timegm(gmtime()) | |
################################### | |
# Follow Me on Twitter @datamafia # | |
################################### |
"""because the instructions were not clear to me, if I missed | |
something or this does not work drop a comment and I will fix. | |
After figuring this out I just wanted to put the solution | |
somewhere. Code pulled from working project.""" | |
from __future__ import print_function | |
import os, urllib, url | |
buffer_base_url = 'https://api.bufferapp.com' |
[section] | |
key=value | |
otherKey=otherValue |
"""Check the validity of URL for maximum compliance, return "ready to | |
use" url address (with http:// as needed) on success | |
Abstract: Be dry. URL verification is a persistent need, this iteration | |
has been very handy for website use, such as profile creation and seems | |
to have a near total compliance with the changing URL schemas. | |
No code is prefect, olease let me know if you find error or have a proposed | |
patch. |
<!-- List tags for product --> | |
{% if product.tags.size > 0 %} | |
<div><span class="mellow" >tags:</span> | |
{% for tag in product.tags %} | |
<a href="/collections/all/{{ tag | replace: ' ','-' }}">{{ tag }}</a> | |
{% endfor %} | |
</div> | |
{% endif %} |
<?php | |
/* | |
Install this in your theme header.php as the first statement | |
(next line right after the <?php opening tag) | |
Change $magic_word to what ever variable you want to use, | |
default is "preview" | |
To use this, go to yoursite.com?preview and a session will | |
be created and access to the site will last as long as the |
#!/usr/bin/env python | |
class A(object): | |
var = 'A' | |
def __init__(self): | |
self.test() | |
def test(self): | |
print 'Class A: '+self.var |