Yesterday I ran into a problem trying to implement Sign In with Twitter using PHP. I had implemented the feature and got everything working good, but after I deployed it out to my production server it wouldn't work. The sign in process would just halt dead in the tracks. Took me a while to figure out why - the OAuth library I was using made use of the cURL PHP extension. As it turns out, the production PHP server this was running on was configured with the '--without-curl' flag, so curl_exec would just fall flat on its face.
After talking with the sysadmin for that server, and being told that there was no chance of recompiling the PHP installation on the server in order to enable this feature, it was back to the drawing board. Unfortunately, after a bit of research, I found that every single Sign In with Twitter PHP library uses cURL. Every one.
Then, luckily, I found the most wonderful little PHP library that acts as a cURL emulator. It is from a site called Blitzaffe Code. After adding the files to your project, you simply include a single php file into your source code, and you are then guaranteed some sort of cURL support, regardless of where you run your code.
It will first try to use the standard cURL extension, and if it is available then this library does nothing. If it isn't available, it next tries to use the command line version of cURL. If that is also unavailable, it finally falls back on its own pure PHP implementation of the cURL methods.
After I added this into my source and redeployed to production, everything worked great! It was a real life saver, so I thought I would pass along a shout out to them.
You can get the library from here: http://code.blitzaffe.com/pages/phpclasses/files/libcurl_emulator_52-7
Friday, November 30, 2012
Wednesday, August 8, 2012
iPhone App Development
Hey everyone. Long time no see - again. Sorry about that. I have been quite busy lately. Let me give some detail as to why.
Last January, I finally got my hands on something that I have been wanting for quite some time - a Macbook Pro. Having now made the switch to Mac, I don't think I could go back. One of the best things that having a Mac lets me do, though, is develop iPhone applications, which has been a dream of mine for quite some time. Last February, I stumbled upon just the idea to work on.
I was on vacation with my wife in San Francisco, which is a favorite spot of ours. While we were there, we went back to the spot where we very first laid eyes on the Golden Gate Bridge - the top of the stairs at George Sterling Park. I noticed that in the time since we first saw it, several things had changed - a lot of the trees were bigger now, that sort of thing. I thought to myself "Wouldn't it be cool to recreate one of the pictures we took here during our first trip? Then we'd really be able to see everything that changed...". With that, my idea was born.
Retake is the product of that brainstorm, and it was released in the App Store on August 3rd. Retake is a camera app with the purpose of retaking existing pictures to accentuate the differences between past and present. It does this by launching the camera with the old picture of your choice displayed semi-transparent on top of the camera interface. You can use anything in the picture that hasn't changed to line up your position, rotation and zoom until you are sure you are taking the exact same picture.
To give you an idea of what you can accomplish with Retake, let me show you an example. This picture is a picture that my wife took three years ago. It is of a building on the University of Kansas campus called The Oread. When this picture was taken, it was under construction still. It was taken with a Canon point and shoot.
Just last week, I went to KU's campus, went to approximately the same area, and I fired up Retake. Using the app, I was able to find the exact location to take a new picture from, so it would match the old picture. As a result, I was able to take this:
Because the pictures are almost identical in position, it really highlights the features that have changed in the last three years. You can see the tree in the front left has grown significantly, and the yellow poles in the far center have been added, and the tree on the right has been trimmed up from where it was.
It has been a really interesting road, learning to develop for Apple. I plan on posting again soon some of the more difficult problems that I encountered along the way. Just wanted to get a bit of the backstory out before jumping into the meat.
Last January, I finally got my hands on something that I have been wanting for quite some time - a Macbook Pro. Having now made the switch to Mac, I don't think I could go back. One of the best things that having a Mac lets me do, though, is develop iPhone applications, which has been a dream of mine for quite some time. Last February, I stumbled upon just the idea to work on.
I was on vacation with my wife in San Francisco, which is a favorite spot of ours. While we were there, we went back to the spot where we very first laid eyes on the Golden Gate Bridge - the top of the stairs at George Sterling Park. I noticed that in the time since we first saw it, several things had changed - a lot of the trees were bigger now, that sort of thing. I thought to myself "Wouldn't it be cool to recreate one of the pictures we took here during our first trip? Then we'd really be able to see everything that changed...". With that, my idea was born.
Retake is the product of that brainstorm, and it was released in the App Store on August 3rd. Retake is a camera app with the purpose of retaking existing pictures to accentuate the differences between past and present. It does this by launching the camera with the old picture of your choice displayed semi-transparent on top of the camera interface. You can use anything in the picture that hasn't changed to line up your position, rotation and zoom until you are sure you are taking the exact same picture.
To give you an idea of what you can accomplish with Retake, let me show you an example. This picture is a picture that my wife took three years ago. It is of a building on the University of Kansas campus called The Oread. When this picture was taken, it was under construction still. It was taken with a Canon point and shoot.
Just last week, I went to KU's campus, went to approximately the same area, and I fired up Retake. Using the app, I was able to find the exact location to take a new picture from, so it would match the old picture. As a result, I was able to take this:
Because the pictures are almost identical in position, it really highlights the features that have changed in the last three years. You can see the tree in the front left has grown significantly, and the yellow poles in the far center have been added, and the tree on the right has been trimmed up from where it was.
It has been a really interesting road, learning to develop for Apple. I plan on posting again soon some of the more difficult problems that I encountered along the way. Just wanted to get a bit of the backstory out before jumping into the meat.
Saturday, April 28, 2012
Keyword column names with Hibernate
I ran in to an interesting problem today, and I thought I might as well help pass it around. I was attempting to create a new Hibernate class for a new table I had created. One of the column names for this table was "index" - which, unfortunately, is a keyword in MySQL. So the Hibernate code I wrote looked something like this:
When I attempted to run my new code, I was getting a very uninformative error attempting to write to that table:
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'index, blahblahotherstufffrommyquery... ' at line 2
Excellent. Perfectly clear. Yeah.
After turning on show sql and going over to MySQLWorkbench, I found that I was getting an error there too - as it turns out, the column "index" needed to be escaped with back ticks, "`index`". Why Hibernate does not do this by default, I don't know. Luckily, as it turns out, it is a fairly easy fix - just add the back ticks to the column name in the annotation, like such:
This makes things work much easier. Just something to bear in mind for future reference.
@Column(name="index") public int getIndex() { return index; }
When I attempted to run my new code, I was getting a very uninformative error attempting to write to that table:
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'index, blahblahotherstufffrommyquery... ' at line 2
Excellent. Perfectly clear. Yeah.
After turning on show sql and going over to MySQLWorkbench, I found that I was getting an error there too - as it turns out, the column "index" needed to be escaped with back ticks, "`index`". Why Hibernate does not do this by default, I don't know. Luckily, as it turns out, it is a fairly easy fix - just add the back ticks to the column name in the annotation, like such:
@Column(name="`index`") public int getIndex() { return index; }
This makes things work much easier. Just something to bear in mind for future reference.
Friday, April 20, 2012
Moving a jQuery Date Picker
In case you haven't noticed by this point, I am a jQuery fan. It makes working with javascript about a million times easier. Every once in a while, I stumble upon a little quirk, though, that ends up sinking hours of time trying to track down. This is one of those quirks.
I needed to make use of the jQuery UI Date Picker feature. Lovely little tool for dropping in an easy date picker. However, I was also doing some other jQuery magic with it - the date picker was in a form that could be used to edit multiple different instances on the page. I had it start out as hidden, then move it to the appropriate location and show it. Here is the code:
There was one problem - the date picker, which I initialized on page load, would no longer open up the calendar. Took me forever to figure out why, as there was no javascript errors, nothing at all to indicate a problem. As it turns out, if you remove an initialized date picker from the page, and then add it back in somewhere else, the date picker functionality gets all foobarred.
With a little experimentation, I found that what I had to do was destroy the date picker before removing it from the page, then re-init it after I inserted it back in. The updated code looked more like this:
I don't know why it messes up when that happens, but regardless, this patches it back up again.
I needed to make use of the jQuery UI Date Picker feature. Lovely little tool for dropping in an easy date picker. However, I was also doing some other jQuery magic with it - the date picker was in a form that could be used to edit multiple different instances on the page. I had it start out as hidden, then move it to the appropriate location and show it. Here is the code:
function moveEditForm(newLocation) { $('#my-edit-form').remove().insertAfter(newLocation).show(); }
There was one problem - the date picker, which I initialized on page load, would no longer open up the calendar. Took me forever to figure out why, as there was no javascript errors, nothing at all to indicate a problem. As it turns out, if you remove an initialized date picker from the page, and then add it back in somewhere else, the date picker functionality gets all foobarred.
With a little experimentation, I found that what I had to do was destroy the date picker before removing it from the page, then re-init it after I inserted it back in. The updated code looked more like this:
function moveEditForm(newLocation) { $( "#my-datepicker" ).datepicker("destroy"); $('#my-edit-form').remove().insertAfter(newLocation).show(); $( "#my-datepicker" ).datepicker(); }
I don't know why it messes up when that happens, but regardless, this patches it back up again.
Tuesday, April 17, 2012
Just a quick update
Once again, an extraordinary amount of time has passed since my last post. This time, though, I have a really good excuse - in that time, I have switched jobs, and it's taken a while for me to get back into a normal pattern. I am still developing in Java, but now solely as a web service backend, working with a flex frontend.
Learning to code in flex has been very interesting to say the least. Some of the things that are so annoying to get right in other platforms are just an easy, simple tag in flex. Of course, as with anything else, there are drawbacks. There can be times when something messes up in flex for no particular reason, and it takes forever to track down, eating up a good chunk of the productivity gained from the easy nature of flex. Also, there is some concern about the portability to other platforms, though we have not experienced that as of yet. So far, I'm fairly happy with the new processes.
One big change with this new job is that I have switched away from using Eclipse, and I now use Intellij IDEA full time. The difference in my productivity has been remarkable. IDEA is not free, which is a big drawback compared to Eclipse, but in my mind the cost is easily worth it. Particularly for development in multiple languages - IDEA intelligently handles Java, Flex, PHP and Javascript practically out of the box, with all the normal IDE bells and whistles, such as code completion, go to function definition, etc. Eclipse can do these things, but it always seemed to take a huge amount of effort to get it to work properly with any language other than Java. If you've never tried IDEA, I highly recommend you go give it a shot. They have a 30 day free trial.
Anyway, that's the state of things. Hopefully I can get back into writing a few more posts now and then. Thanks for reading!
Learning to code in flex has been very interesting to say the least. Some of the things that are so annoying to get right in other platforms are just an easy, simple tag in flex. Of course, as with anything else, there are drawbacks. There can be times when something messes up in flex for no particular reason, and it takes forever to track down, eating up a good chunk of the productivity gained from the easy nature of flex. Also, there is some concern about the portability to other platforms, though we have not experienced that as of yet. So far, I'm fairly happy with the new processes.
One big change with this new job is that I have switched away from using Eclipse, and I now use Intellij IDEA full time. The difference in my productivity has been remarkable. IDEA is not free, which is a big drawback compared to Eclipse, but in my mind the cost is easily worth it. Particularly for development in multiple languages - IDEA intelligently handles Java, Flex, PHP and Javascript practically out of the box, with all the normal IDE bells and whistles, such as code completion, go to function definition, etc. Eclipse can do these things, but it always seemed to take a huge amount of effort to get it to work properly with any language other than Java. If you've never tried IDEA, I highly recommend you go give it a shot. They have a 30 day free trial.
Anyway, that's the state of things. Hopefully I can get back into writing a few more posts now and then. Thanks for reading!
Subscribe to:
Posts (Atom)