Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
import unittest | |
class TestProblem(unittest.TestCase): | |
def test_sample(self): | |
self.assertEqual(1, 1) | |
if __name__ == '__main__': | |
unittest.main() |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#!/usr/bin/env python | |
""" | |
===================================== | |
PEP 20 (The Zen of Python) by example | |
===================================== | |
Usage: %prog | |
:Author: Hunter Blanks, [email protected] / [email protected] |
Inspired by this article. Neat tricks for speeding up integer computations.
Note: cin.sync_with_stdio(false);
disables synchronous IO and gives you a performance boost.
If used, you should only use cin
for reading input
(don't use both cin
and scanf
when sync is disabled, for example)
or you will get unexpected results.
x = x << 1; // x = x * 2
class Product(models.Model): | |
# other fields | |
image = models.FileField(storage = MogileFSStorage(), upload_to = 'product_images') | |
from django.core.files import File | |
from django.core.files.temp import NamedTemporaryFile | |
product = Product() | |
# set all your variables here | |
product.save() |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
0. SSH to server | |
1. Edit /opt/bitnami/apps/jenkins/jenkins_home/config.xml | |
2. set userSecurity to false: <userSecurity>false</userSecurity> | |
3. delete | |
<authorizationStrategy> and <securityRealm> | |
4. /etc/init.d/bitnami restart |
Authored by Peter Rybin , Chrome DevTools team
In this short guide we'll review some new Chrome DevTools features for "function scope" and "internal properties" by exploring some base JavaScript language concepts.
Let's start with closures – one of the most famous things in JS. A closure is a function, that uses variables from outside. See an example:
##To reproduce:
In addition to the charts that follow, you might want to consider the Frequently Asked Questions section for a selection of common questions about MongoDB.
The following table presents the MySQL/Oracle executables and the corresponding MongoDB executables.