johnk's blog

My Google calendar shows up on iPhone under iCloud, but it is not in iCloud...

This is freaking weird. My personal calendar, kept on Google, showed up in an iPhone I set up, right after the phone was set up. It showed up as an iCloud calendar.

Too weird. So I have to find out what's going on - and how to stop it.

I looked at - there were only two calendars there, Home and Work, neither of them the Google calendar. I don't use iCloud, really.

I put a new event in my calendar. This was on my Linux desktop. It didn't sync to the iPhone!

The Mac was off! So it's probably syncing via the Mac. I turn it on. Nothing.

JSON for Tables, kind of like CSV

CSV is one of those great old formats that seem to be perfect... until you write a parser for it and find out all the escapes and string issue are hard to handle. You end up writing a character-at-a-time parser, and then realize that was what people were writing back in the 70s.

Django Edge

Edge 2 looks nice. I'm kind of surprised I haven't heard of it before.

Also, while I'm keying up this tutorial series, it's dawning on me that it would be good to state that I'm aware that the "in" thing is moving away from apps with templates, and toward REST and real-time. I am learning Django because I started out with Django REST Framework - and the DRF material didn't really cover the various authentication, authorization, and general programming issues.

Using List Comprehensions in Python to Look at Lists of Objects

List comprehensions are a difficult-to-learn feature of Python that seem unnecessarily terse, but that's because the examples aren't that practical. It's really a powerful tool.

I was using Tweepy to get some tweets from the Twitter API, and it was a LOT of data. You'd think a 140 character string isn't that big, but Twitter delivers a lot of metadata. It's around 7K of metadata per tweet.

So, I had 15 tweets in a list, or around 100K worth of __str__ representing dozens of objects. How do you slice that up?

You use dir() to explore the properties of the different objects.

Django 1.8 Tutorial - 4. Integrating the Default Login Screens, Adding HTML Email

So, I started implementing the Django provided user login screens yesterday and it was requiring a ton of reading to get the different parts working. It seems so simple, from the outside, but all the configuration options made it seem more difficult than it really is.

In the attached file, a few of the old configs and views have been deleted, but I'm not going to cover that here. Just do diffs between the contents of the attached tgz files to see the differences.

Create a file in your global templates, templates/registration/login.html:

{% extends "base.html" %}

A Depressing Realization about Tutorials on the Web

I love the people who write tutorials (and fixes) on the web. I owe the vast community of writers so much, because they've taught me so much. It's the reason why I write these short notes, to be found by search engines, to help someone in a small jam.

Syntastic is Fantastic for the Anal Stage

Syntastic checks your syntax when you write your file, and flags all the little mistakes. It works with the pyflakes script. It's amazing.

Web API Design book I'm reading

This is a few years old, but it's a good overview of APIs and some good design patterns. There's a signup page.

Web API Design - Crafting Interfaces that Developers Love

It's good advice and easy reading, but there's what I consider an error in there. Over on page 26, they suggest that it's OK to make a request like "GET /foo/123?method=delete" that will delete the resource.

Django error: Reverse for 'some-name' with arguments '(1,)' and keyword arguments '{}' not found. 0 pattern(s) tried: []

A nice feature of the URL matching rules is that even if you have named arguments in the url(), like so:

 url(r'^items/(?P<pk>[0-9]+)/$', ItemDetailView.as_view(), name='item_detail'),

the system will accept a positional parameter, like so:

{% url 'item_detail' %}

I was thinking that it was going to be particular about named parameters, and I was searching for information about passing named parameters to url, but it wasn't necessary. Once again, misdirected by an error message.

Python Performance Rabbithole

I was looking for Django podcasts, and being that it's a community within a community found only a couple, and they were both not in operation anymore. I started to worry - was the project waning? It looked like updates and significant improvements were coming out at a fast pace.

Was Node taking over? I had to "research". Off to craigslist - nope. Node is popular, but there are still plenty of references to Django.... more actually. Then, I started to worry about whether nonblocking I/O was an issue - I know all the big, intepreted app servers like Django and ROR are slow - but really?

DIY Fixing ic! Berlin glasses if you sat or stepped on them

So, when I had some money, I blew it on these "designer" ic! Berlin frames. They look really high tech and cool, and they allegedly avoid damage by having these hinges that pop apart under pressure.

Here's a video of how it's supposed to work:

Here's another one:

Too bad the ones I got don't actually pop apart under pressure. I'll explain how to fix them in this blog post.

def fn(arg1,x=arg2,y=10,*args,**kwargs): GO PYTHON!

def fn(arg1,x=arg2,y=10,*args,**kwargs):

That's kind of ugly, but the design is elegant. With that declaration, the function supports positional arguments, required named arguments, optional arguments, an arbitrary number of additional unnamed arguments, and additional arbitrary named arguments.

It allows function calls to be simpler and more readable than they would be without this flexibility.

Metro PCS contract, and an opt-out letter to preserve your right to a court trial.

I was getting an annoying update of the Metro PCS contract, and ended up reading it. Attached is a marked-up contract with interesting parts highlighted. The plain contract is available on their website - this is highlighted as a kind of commentary.

The most irritating part is where the company forces you into arbitration, and then into relinquishing a trial by jury. While I'm not that opposed to arbitration, it is not nice to give up the right to be seen in court.

Open Source as Marketing for SAAS

Probably not news to anyone, but the idea is that you run a hosting company that offers a specific hosted software, and also hires out people to modify the software. Then, you give some of the software away - the most feature rich part generally - as bait. Developers sell these features to clients. They find they cannot really charge what they need to for hosting, because it takes time to keep the software up-to-date and also to modify their add-ons to work with the changes, and also deal with security. They end up re-selling the hosting services.

Django URL Namespaces and Templates... kind of not pretty

So, I shouldn't admit it, but I'm a Django beginner. (I've done a lot of other frameworks, but Django is new to me.) It has a really nice feature to write URLs for you; you don't code URLs into the pages, but use a name to find a URL's associated pattern, and generate based on the pattern. It's really nice.

Syndicate content