If it won't be simple, it simply won't be. [Hire me , source code] by Miki Tebeka, CEO, 353Solutions
Wednesday, November 26, 2014
Generate QR Code Using Google Charts API
Here's a small utility to generate QR
code image using Google
Charts API.
Note the hand crafted Python 2/3 support, for more advanced stuff you might want to have a look at six. However for this script I wanted to stay without external dependencies.
Note the hand crafted Python 2/3 support, for more advanced stuff you might want to have a look at six. However for this script I wanted to stay without external dependencies.
Sunday, November 16, 2014
Common Errors
"Experience is the name every one gives to their mistakes."
- Oscar Wilde
NameError
- You forgot to import a module
- You made a typo
AttributeError: 'NoneType' object has no attribute ...
- You forgot a return in your function
AttributeError
- Typo on dot lookup (obj.foo)
- Object is different type from what you think (str vs int)
- Object does not implement a dunder method (e.g. __len__)
There's also the 3'rd party didyoumean module, which might be interesting for beginners. It changes the default stack trace to add a hint about what might be the problem.
Monday, November 03, 2014
A Streaming Chart using Flask and flot
I was teaching a course
on "Python Analytics" (pandas, scikit-learn,
matplotlib ...) and was asked to provide
an example of streaming chart - ones that updates periodically. I''ve showed a
couple of examples one by generating image using matplotlib and another with bokeh-server. After a couple of days I remembered
another way - using flot to render
the chart. Here''s a small example using Flask
as the web server (the code works both on Python 2 and 3).
Few comments:
Few comments:
- Don''t use debug=True in production :)
- For simplicity everything is in one file. However for larger application you might want to take the HTML template(s) out
- Data is in memory, a restart will wipe it out. If you need data persistence - pick a database (shelve, sqlite3 ...)
- A big shoutout to Continuum Analytics - Anaconda (and conda) has made my life so much easier teaching this workshop.
Subscribe to:
Comments (Atom)
Blog Archive
-
2016
(17)
- December (1)
- November (2)
- October (1)
- September (1)
- August (2)
- July (1)
- June (1)
- May (1)
- April (1)
- March (3)
- February (1)
- January (2)
-
2015
(18)
- December (2)
- November (1)
- September (2)
- August (1)
- July (2)
- June (3)
- May (1)
- April (2)
- February (2)
- January (2)
-
2014
(24)
- December (3)
- November (3)
- October (4)
- September (2)
- August (1)
- July (3)
- June (2)
- May (1)
- April (2)
- February (1)
- January (2)
-
2013
(35)
- December (1)
- November (4)
- October (4)
- September (6)
- August (4)
- July (2)
- May (3)
- April (4)
- March (4)
- February (2)
- January (1)
-
2012
(22)
- December (2)
- November (2)
- October (3)
- September (3)
- August (1)
- July (2)
- June (1)
- May (1)
- April (1)
- March (2)
- February (2)
- January (2)
-
2011
(29)
- December (3)
- November (2)
- October (2)
- September (4)
- August (2)
- July (2)
- June (2)
- May (4)
- April (1)
- March (3)
- February (1)
- January (3)
-
2010
(17)
- December (1)
- November (1)
- September (1)
- August (2)
- July (1)
- June (3)
- May (1)
- April (2)
- March (2)
- February (2)
- January (1)
-
2009
(38)
- December (4)
- November (1)
- October (3)
- September (3)
- August (3)
- July (5)
- June (5)
- May (2)
- April (2)
- March (2)
- February (4)
- January (4)
-
2008
(45)
- December (1)
- November (3)
- October (1)
- September (6)
- August (3)
- July (6)
- June (3)
- May (4)
- April (5)
- March (3)
- February (7)
- January (3)