Mar
30

Sphinx Docs

So we’re adding auto-doc’ing capabilities to Nudge, and I’m in charge of Sphinx docs right now.  They’re a PITA…  One space is off? FFFFFFUUUUUUUUUUUUUUUUUUU.  Yup about that awesome.  They also don’t like having table items be longer than the column separators.  I’m not sure what they’re really called, but they’re the set of = signs used to surround the column headers and the data.  SO, given the varied length data in a table, you have to do some fancy trickery to get them to line up perfectly.  TIL you can multiply a char (C) by an int (N) and get a resulting string of length N filled with C.

SO:
"x" * 2 = "xx"
and
"c"*4 = "cccc"

 

Fancypants! Any other language and it would probably barf on you saying you can’t multiply things of char type with things of int type.

 

Mar
27

POP!

Recently, whenever I have downtime on the couch I try to learn something new about Python.  For the moment that learning has come through reading other people’s questions on Stack Overflow or the Python subreddit.

Last week, I learned about setdefault(‘key’, default_value), and I got a lot of satisfaction while working on Nudge during the moments when I realized I could utilize my new knowledge.

Today I learned about pop for dictionaries.  Awesome…

http://stackoverflow.com/questions/5330626/pythonic-dictionary-traversal

Mar
23

Captcha Quirk

So, it’s come to my attention that when you enter a captcha, the only thing that has to actually match character for character is the first word. The second one just has to match in length, but as far as I can tell, it can be any mix of characters. I heard a rumor that this was to help with some sort of automatic character recognition algorithm, but I’m not sure where I read/heard that.

Mar
23

Things I should have known about Python #1

After the whirlwind that was Pycon 2011, I’ve started trying to learn as much as I can about Python.  I’ve even stumbled upon the Python subreddit gem.  I was reading this which pointed me to this, and came across a few things (of the many out there) I didn’t yet know:

  1. In the interactive interpreter there is a hidden temporary variable “_”.  It holds onto the last printed value that was not None.  Oh Python, why are you so sneaky?
  2. Dictionaries have a setdefault() method that allows you to bypass existence checks for keys and simply (get) or (set and get) in one go.  Fascinating.  SO MANY THINGS I NEED TO LEARN THAT ARE SO BASIC!!
  3. You can define the trueness of a user-defined class by overriding the built-in __len__ or __nonzero__ methods, with __len__ being preferred if your class is a container with a natural length.  Fascinating.  I want to find a reason to use this.  However, all of our classes are really just functional, and all of our data is JSON, so trueness is built-in.

Mar
21

Things I need to remember about Python #1

dicta.update(dictb) DOES NOT RETURN ANYTHING. It modifies the dictionary in place, so if you do
dicta = dicta.update(dictb)
dicta will now be None.

Thanks brain. Let’s hold onto this.

Jan
12

Splice: not good any way you cut it

borrowed from imdb.com

This movie has all the makings of an awesome sci-fi flick with a not-so-heavily-veiled moral about how human cloning or even human DNA splicing is wrong.  Sadly, it falls FAR below my expectations (which weren’t that high to begin with).  I’m always even more disappointed by movies that *could* have been so awesome, but were somehow magically executed so poorly.  I’m not sure what else to say but that it’s a completely unbelievable story with characters you don’t care about doing things no real human would do.  If you get the chance to watch this, pass, just pass.

Jan
08

PyCon Talk Declined

There is constant talk in every dev social group about the lack of not just diversity, but more specifically women.  This especially applies to women speakers at cons.  There is so much talk about how we never even try to give talks.  One of the problems is, there isn’t enough encouragement or support when the few brave women do put themselves out there.  There’s so much talk about why women don’t tend to try to give talks, but not much about why more talk proposals by women aren’t accepted to give our gender a boost of confidence.  This may be my hurt pride talking, but having my talk rejected makes me far less likely to want to try again.  I spent a bunch of time on my talk proposal and outline, and have spent extra hours of my off time working hard to get Nudge opensource (getting close), but now that it was declined, I don’t really want to try next year and get declined again.  It makes me think that there should be something akin to affirmative action for women in the tech world.  I mean, all the talk in the world about getting us to put in proposals doesn’t matter if we don’t get talks.  Maybe my talk proposal just sucked.  Could be, but doesn’t change my reaction to the decline or the fact that there seem to be only 2 female speakers at PyCon2011 and one of them is doing a talk incited by a gender/sex issue last year.  Just sayin’.

UPDATE:

PyCon was amazing.  It was hands down, the best conference I’ve ever been to.  I got to know the reasons why it was turned down and they were valid.  Nudge wasn’t yet open source, and really, given the talks I saw, I really wasn’t ready.  Given the caliber of the talks, I would have been alone in a room, and that would have killed any desire to speak again.  Now that I’ve had a chance to get a feel for PyCon, I’m re-energized and ready to try for round 2 next year!  Maybe I’ll start it out easy with a lightning talk!

Dec
09

Playing with Google AppEngine (part 1)

So, I’ve been playing around with some CRUD appengine services, and I found something interesting.

Let’s say you have:

class Person(db.Model):
firstname = db.StringProperty()
lastname = db.StringProperty()

and you do something like pass the following dictionary through the POST body:

p = {"firstname":"foo","lastname":"bar"}

then you instantiate a Person as follows (I’m ignoring all data validation for brevity’s sake):

person1 = Person(**p)
result = person1.put()

You can then do:

result.id()

HOWEVER, once you do:

q = Person.gql('WHERE firstname = :name', name="foo")
result = q.fetch(1)
p = result[0]

You can no longer do p.id().  You have to do p.key().id().  Weird.  Super weird.

Nov
03

Way to go SanFran!

I was listening to NPR this morning and heard about a ban passed in San Francisco that removes toys from and limits the caloric content/fat distribution in Happy Meals.  I’m excited about the ban, but it is sad that it takes legislation to stop being able to feed our kids awful awful AWFUL foods.  People are apparently unhappy with this according to Mickey D’s.  They’re “disappointed” in the ban and are upset because their customers didn’t ask for it and don’t want it.  If they really didn’t want it, then it wouldn’t have passed.  Parents shouldn’t be feeding their children McDonald’s anyway.  I understand it’s hard sometimes, esp. if you’re a household where both parents work minimum wage jobs, to have the time to feed your children good healthy food, but come on.  You could stay up later to make a large batch of food that will last the week.  Roast a ton of chicken breasts and have salad greens around.  Then teach your kids to make chicken sandwiches, salads with sliced chicken, chicken salad with a little mayo.  Seriously, you could make something that would last all week.  My mom does it.  You could just have cut fruits and veggies with low fat yogurt in the fridge for snacks.  Once your kids are a little older, even in elementary, they are capable of making their own food.  I wouldn’t recommend hot food without supervision, but making a pb&j should be no problem.  If it’s so hard to raise a child while consciously giving them as many advantages as possible (education, nutrition, socialization) there’s an easy answer.  DON’T HAVE KIDS!  Don’t half-ass being a parent because being a parent is hard.  Your kids deserve better.  Way to go San Fran!  I’m proud of you!

Nov
02

PyCon2011 Proposal

So,  Warren and I submitted a proposal to do a talk on Evite’s service publisher.  It’s better known as Nudge.  In true Monty Python spirit, the name was taken from this sketch: Monty Python: Nudge Nudge So, Is your service a “goer,” know what I mean?  I’m kind of excited!  I hope we get picked.  It will be the first talk I’ve ever given!  The service publisher has made our lives easier and cleaner through templatizing/generalizing/abstracting the actual REST service from the service layer, and I’m hoping to be able to share it with other Pythonistas.  I don’t want to give away too much detail, otherwise there will be no need for my talk, but imagine mixing and matching items using list operations so you can easily swap, remove, add Endpoints (url + http method) to different ports making deployment supremely easier.  This separation of web service and actual service also allows the dev to focus solely on one part or the other making swapping web servers/frameworks (Tornado/Django whatever) and testing easier too!

Older posts «

» Newer posts