Monday, May 30, 2016

Creativity

In my creative and job work, I've learned how to move around and have great ideas.

It turns out these things are related.

In "Doodle Revolution", Sunni Brown points out that moving and creative thinking are related.  Steve Jobs would go on "power walks" not to clear his mind but to focus and to work through creative blocks.  Einstein would play the violin, improvising melodies while pondering complicated problems. Tesla could design and run machines in his mind, not bothering to draw them out!

At work I walk around as much as possible. Often I'll jog around the block to stimulate the little gray cells. Before or after lunch I'll draw my coworkers or tourists or cute dogs. At meetings and when learning new material I'll take notes on paper, adding lines and diagrams and fonts as much as possible. It's fun, and it helps me concentrate on the material, and integrate into my brain.

I recommend everyone go out at buy Brown's book, or at least watch her TED talk "Doodlers, unite!" She's on the twitters at @SunniBrown 

Here's my notes from 2015's Continuous Delivery "cdSummit SoCal" conference

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! http://johntellsall.github.io/johntellsall.com/class/django-queryset3/_build/

Friday, April 15, 2016

talk: Functional Programming and Django QuerySets soon!



I'll be speaking at the next SoCal Python meetup! http://www.meetup.com/socalpython/events/230329648/ 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: http://johntellsall.blogspot.com/2014/05/talk-functional-programming-and-django.html
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.

NYT: Which Type of Exercise Is Best for the Brain?

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!

Example:

# CREATE TABLE worldbank_json (data json);
CREATE TABLE


# COPY worldbank_json FROM PROGRAM 'curl "http://api.worldbank.org/countries?format=json&per_page=100&page=1"';
COPY 1
# COPY worldbank_json FROM PROGRAM 'curl "http://api.worldbank.org/countries?format=json&per_page=100&page=2"';
COPY 1
# COPY worldbank_json FROM PROGRAM 'curl "http://api.worldbank.org/countries?format=json&per_page=100&page=3"';
COPY 1

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 http://www.postgresonline.com/journal/archives/325-Using-wget-directly-from-PostgreSQL-using-COPY-FROM-PROGRAM.html