Week Lessons 2

Use curl to post data

While developing an api, I needed to do some posts to a certain url. The fastest way I could think of was to use the command line curl command. However, by default curl does a GET request, and of course, sends no data. However a short googling trip took me to this superuser answer, which demonstrates how to do it. I was posting json to my api endpoint in no time. Example:

curl -X POST -d @filename.json http://example.com/api/endpoint/ --header "Content-Type:application/json"

Which will do a post using data from filename.json to the given url. The request header content type is also set to json. Of course if your not posting json this should be changed to reflect the data.

Week Lesson 1

Every week there are lot of small things I pick up that I think will be useful to remember, so I decided to start a weekly post with just such things. This is the first entry in the series.

Positioning the jQueryUI Dialog

when opening a jQuery UI dialog the position could be given as specified in the api. The short version is, you can give what part of the dialog is positioned relative to what part of which element. Quite nice and readable. giving the dict as the position entry in the dialog definition call will associate that position dict with the dialog element.

Firefox and css Sprites

Using css sprites relies on the usage of the background-position style property. When properly built, adding hover changes can be achieved by just altering the x or the y axe. I find this to be very elegant. This can be done using the background-position--x and background-position-y properties. Unfortunately, as of today, Firefox does not support x and y background position properties. So its back to x and y for hover effects until mozilla adds it.

MySQL foreign key constrain

When adding a foreign key constrain, it seems that both tables need to have the same engine. I was trying to add a constrain and it kept failing. I had no idea why till I came across a stack overflow question, where the answer specifies the engine should be the same. Mine weren't. Making them the same solved my problems.