Autosizing Floated html elements

p { overflow:hidden;} img {float:right;}

<p> Your text. <img src="path"></p>

The image tag is floated. We set overflow:hidden; on the parent tag, a paragraph tag in this case, and the box is autosized to fit all elements.

I would have put the exact example here but tumblr strips *some* tags of style and class delcarations.

dermiepie:

the sea and stars and Painkillers…good night.
I put my feet in the water. Open water, I’ll conquer you one day.

dermiepie:

the sea and stars and Painkillers…good night.

I put my feet in the water. Open water, I’ll conquer you one day.

(via dermiepie-deactivated20120118)

1 year ago 5 ♥
Twitter Stream

You can use curl to output the twitter steam to a file. 

curl http://stream.twitter.com/1/statuses/sample.json -u USERNAME:PASSWORD -o stream.json

After 24 seconds I had 1MB of data. I’m going to use this for data of a sample app I’m working on with CouchDB.

A Security Review of Happy Herbivore’s Shopping List

I had my first skype programming interview today. I was asked how I kept the shopping list feature on HappyHerbivore.com secure from injection and general mischief. While I did answer the question, I could have done much better.  Because writing can be therapeutic, I’m going to explain how the shopping list works and how it’s kept safe.

When adding an item to the shopping list, a POST request is submitted to the url http://happyherbivore.com/api/list/<recipe_id>/. The only input allowed is the recipe_id, the controller regex is configured to only match a numbers.

The form request is protected by a built-in and enabled by default, Cross Site Request Forgery, Django mechanism. Django’s CSRF protection which requires a valid csrf token limits a direct attack on the site.  

So what happens if it is given a bogus recipe_id? The api will accept the bogus recipe_id and add it to your session.  When the database is queried for that recipe it returns nothing and does not generate an error. In light of this, I believe I’ll added a simple check to prevent not existing recipe_id from being added. 

When I originally developed this feature, I did spend time reflecting about the different security issues and I think I cover myself pretty well.

Postgresql built-in Search & Replace function

I don’t know why this was so difficult to figure out but for now I’m going to blame the Postgresql documentation for not having enough examples.

The query search the db_field for ‘the wrong text’ and is replaced by the “the right text’ and is case-insensitive which is what the i flag is for.

UPDATE db_table SET db_field = REGEXP_REPLACE(db_field, 'the wrong text', 'the right text', 'i');

10 plays

j2d2:

At The Drive-In - Rascuache

pace maker, pace yourself

Lovely little rock tune. Will seek more “At The Drive-In”

(Source: jmsdnns)

1 year ago 4 ♥
Sister &amp; Brother together (Taken with picplz.)

Sister & Brother together (Taken with picplz.)

1 2 3 4 5