Friday, April 29, 2016

talk: Functional Programming and Django QuerySets

thanks everyone for coming, for Media Temple for hosting, and for Esther for coordinating! I thought Justin's talk (his first!) on Swagger was fun and extremely useful. I hope everyone had a good time.

Here are the slides and notes for "Functional Programming and Django QuerySets" (2016 edition) -- have fun!

Friday, April 15, 2016

talk: Functional Programming and Django QuerySets soon!

I'll be speaking at the next SoCal Python meetup! If you want to go, sign up soon, there are only a few spots left.

This talk is mostly about Functional Programming in the Python world.  FP is great for testing, but it can be a bit mysterious at times. I highlight the awesomeness of FP, the dangerous bit, and how it is related to Django QuerySets.

I've given this talk a few times, and people always get excited about it. FP is not magic!  It's a clean and graceful way to write code.

Here's a link with my previous version's slides, notes, and other references:
Each time I give a talk I change it up a little or a lot. This time I'll probably add more cat photos.

Thursday, March 24, 2016

UPDATED: quickly download lots of Python packages

This trick downloads Python packages up to 9x faster than normal:

egrep -o '^([A-Za-z].*==[^ ]+)' requirements.txt | xargs -n1 -P9 pip download

After things are downloaded, actually build and install the packages:

pip install -r requirements.txt

EDIT: original code gave `egrep: Invalid range end` -- fixed. Also added "-n1" to xargs so it'll download in parallel, vs sequentially.

Monday, March 7, 2016

great developer podcasts: Accidental Creative

I commute in Los Angeles. Since I started listening to podcasts on my drive, the long rides have become a lot easier, and I am inspired and smarter and more knowledgable. I highly recommend using podcasts as a tool to expand your horizons.

Here are my favorite podcasts.

Oddly for a senior DevOps guy, my #1 is not technical at all. One podcast above all others serves to inspire me and help me move forward in my career: Accidental Creative by Todd Henry. His aim is to assist the working creative professional be productive and organized. His audience is the corporate "create on demand" class: designers, marketers, writers.  As a DevOps guy I find his work refreshing, it helps me open up my brain, to relax and focus my whole being on solving mysterious code or server problems.

Each short (ten minute) podcast has a clear idea. He then briefly and directly supports that idea, often by interviewing someone.  Recently there was an episode on doing "deep work."  By dedicating a few hours at a time, we can have great ideas that we can flesh out during the normal work week. That is, in contrast to the traditional work style of trying to make progress by herding chickens, one creates a vision then works towards it.

This is similar to John Cleese's theory: creativity is a shy turtle. Your creativity is shy, so if you create a reliable "safe haven" for it, it might poke its head out and share something awesome with you. This sounds exactly like the "deep work" idea of setting aside reliable quiet time to work on larger ideas.

Wednesday, February 17, 2016

Jog to get Smarter

Exercise affects the brain as well as the body.  I've acquired the habit of running around the block 1-2 times per day as a way to get up, get the blood to circulate, and to focus my attention on what I'm working on.  It turns out, recent research says this makes me smarter!  Especially if I do distance jogging, and I'm a rat.

I'll stick to running around the block.

Wednesday, December 2, 2015

calling programs/REST URLs from Postgres

Postgres already has good JSON support. It can copy to/from external files, which is great for easily exporting a table or three, or importing data from a CSV file.  As of 9.3, it can copy from a program or URL!


# CREATE TABLE worldbank_json (data json);

# COPY worldbank_json FROM PROGRAM 'curl ""';
# COPY worldbank_json FROM PROGRAM 'curl ""';
# COPY worldbank_json FROM PROGRAM 'curl ""';

WITH je AS (
            SELECT json_array_elements(data->1) AS jd FROM  worldbank_json
SELECT jd->>'id' AS id, jd->>'name' As country, 
jd#>>'{adminregion,id}' As region_id
FROM je limit 20;

 id  |       country        | region_id
 ABW | Aruba                |
 AFG | Afghanistan          | SAS
 AFR | Africa               |
 AGO | Angola               | SSA
 ALB | Albania              | ECA
 AND | Andorra              |
 ANR | Andean Region        |
 ARB | Arab World           |
 ARE | United Arab Emirates |
 ARG | Argentina            |
 ARM | Armenia              | ECA
 ASM | American Samoa       | EAP
 ATG | Antigua and Barbuda  |
 AUS | Australia            |
 AUT | Austria              |
 AZE | Azerbaijan           | ECA
 BDI | Burundi              | SSA
 BEL | Belgium              |
 BEN | Benin                | SSA
 BFA | Burkina Faso         | SSA
 (20 rows)

Rows marked with "#" are typed into the Postgres PSQL prompt.

Unsurprisingly, there are limitations:
- you must be superuser

Borrowed from

Friday, October 2, 2015

Learning Python Programming

I give a number of talks on Python and other subjects. The two universal questions I get are:

- how can I... learn Python? get better at Python? learn programming?

- which web framework should I use?

There's a number of resources for learning programming with Python. Here are my favorites:

- Girl Develop It

This (USA) national organization helps train women (and men) in learning web and software development. In the Los Angeles area they have classes nearly every weekend. My girlfriend took the "CSS" and "Javascript" classes and found them rewarding.

As an experienced dev who wants teaching experience, the organization itself is pretty easy to get in to. You can be a TA (teacher assistant) or work up to being a Teacher.  You can be paid or donate your salary to the national nonprofit.

I've taught a number of people, and found working with beginners to be humbling. They always ask insightful questions. As a teacher, to be clear and patient is a wonderful skill.

- MakerSquare

This organization has an intensive "boot camp" in which you work, full time, for three months on training up to become a professional Javascript programmer. They also have "keep your day job" night class sessions.  Reportedly 96% of graduates get a professional Programming job in three months! Locations in Austin, San Francisco, and Los Angeles.

- Hack Night at Carbon Five

It's great fun to bring your laptop and projects to meet other geeks. This event is super chill and it's easy to talk to people and learn new things!

- Learn to Code with Us

I've been to the Culver City location (at Crash Space, a great hacker space), and it was a lot of fun. Lots of people work on projects. Michelle is very quiet and open, doing one-on-ones with people to help install Python or other software, or she'll help with general programming questions.