#Taller CartoDB Mexico
About Santiago:
- Civic Technologist @CartoDB
- santiago@cartodb.com
- @namessanti
#Taller CartoDB Mexico
About Santiago:
I currently use Python for nearly all of my data science and wrangling work these days but usually find myself switching to R to visualize data using ggplot2. This is due in part to ggplot2's general excellence, but also because I had a lot of trouble learning Python's most popular viz library, matplotlib on my own...its homepage is decent enough...but its variety of plotting APIs (--pylab? OOP? %matplotlib???) has led to widely differing examples and best practices among the many online matplotlib guides (not dissimilar to the general problem of trying to practice either Python 2.x or 3.x).
That changed yesterday when I stumbled across [Nicolas P. Rougier's beautifully designed and com
| """ | |
| Tweeting by controlling Firefox via Python + selenium | |
| http://selenium-python.readthedocs.org/ | |
| This script: | |
| - Opens up Firefox | |
| - Goes to https://www.twitter.com | |
| - Clicks the login button | |
| - logs you in (assuming you have your twitter password in a file named `mypassword.txt`...) |
As websites become more JavaScript heavy, it's harder to automate things like screenshotting for archival purposes. I've seen examples and suggestions to use PhantomJS for visual testing/archiving of websites, but have run into issues such as the non-rendering of webfonts. I've never tried out Selenium until today...and while I'm not thinking about performance implications yet, Selenium seems far more accurate than PhantomJS...which makes sense since it actually opens a real browser. And it's not too hard to script to do complex interactions: here's an [example of how to log in to Twitter, write a tweet, upload an image, and send a tweet via Selenium and DOM element selection](https://gist.github.com/dannguyen/8a6fa49253c1d6a0eb92
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// see: https://github.com/chadoe/docker-cleanup-volumes
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
Git for Windows comes bundled with the "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.
The basic idea is that C:\Program Files\Git\mingw64\ is your / directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git, the mingw64 in this directory is your root. Find it by using pwd -W).
If you go to that directory, you will find the typical linux root folder structure (bin, etc, lib and so on).
If you are missing a utility, such as wget, track down a binary for windows and copy the files to the corresponding directories. Sometimes the windows binary have funny prefixes, so
| """Run Length Encoding utilities for NumPy arrays. | |
| Authors | |
| ------- | |
| - Nezar Abdennur | |
| - Anton Goloborodko | |
| """ | |
| from __future__ import division, print_function | |
| import numpy as np |
$ uname -r
| from types import MethodType | |
| from pandas import DataFrame | |
| def func(arg=None, n=0): | |
| print(arg) | |
| print(arg.a+arg.b+n) | |
| class C: | |
| b=1 | |
| def __init__(self, a=2): |