This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
I’m wrapping up a little side project at the moment (more on that very soon) which required full-text search, autocomplete, and a few other bits of search related functionality.
After some research I landed upon the combination of Elasticsearch and the awesome Django application Haystack.
First step was to get Elasticsearch up and running locally on OS X…
3) Add the following to your .profile (allows you to run Elasticsearch from the command prompt without the full path):
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
4) Update the following values in the Elasticsearch config file:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
5) Ensure all requirements are installed (django-haystack, pyelasticsearch, requests, simplejson):
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Here’s a simple trick for viewing MySQL queries as they hit your server – enable query logging to a file and then tail -f the file:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
The default truncatechars template tag truncates a string if it is longer than the specified number of characters but does so exactly at the character count, irrespective of whether it’s the middle of a word or not.
Here’s a smarter version that clips the text at the word boundary:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Apple conveniently let’s users add any site to their home screen as a standalone web application that acts much like a native application.
But there’s one problem – by default all links open in Safari rather than in the web application. Very annoying.
I found a few bits of code out there to workaround this issue, the best of which came from Stanislav Kostadinov. Since we use mostly CoffeeScript, here’s a CS version:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Ran into a fun little bug with the LinkedIn API this morning:
'{"error":"server_error","error_description":"the authorization server encountered an unexpected condition : Unable to retrieve access token"}'
Turns out that if a user revokes access to your application using their LinkedIn security settings, the API will throw this error if they ever try to re-authorize the application.
The only way to resolve the issue is to create a new application in the developer portal and use the new API keys. Not good, especially considering that LinkedIn generates unique user IDs for each application. So if you’re making use of the user ID in any sort of way, you’d have to figure out a way to reconcile the users (perhaps via their email address).
LinkedIn is aware of the issue and has said the fix is ‘a few weeks’ away. At least it’s not a few months…