28 04 2014
I have an artist buddy who is working on an art installation and asked me if there was a way to display a realtime view of an instagram hashtag feed on a projector.
Unfortunately there isn’t anything right out of the box available, but I offered to write him a quick app that he could fire up that would give him what he wanted.
For the impatient, full source is available at my github.
One way to do this would be to hook into the instagram realtime API. Using the realtime API you subscribe to tags or users via their API and supply a url callback. Instagram will then callback to your endpoint with an HTTP GET, validate that you actually did request (via a handshake response), and then post to your endpoint whenever something on that subscription has changed. What it won’t do is actually give you … Read more
14 04 2014
Prefix trie‘s are cool data structures that let you compress a dictionary of words based on their shared prefix. If you think about it, this makes a lot of sense. Why store
abysmal when you only need to store
a,b,b,r,s,y,s,m,a,l. Only storing what you have to (based on prefix) in this example gives you a 70% compression ratio! Not too bad, and it would only get better the more words you added.
The classical way of dealing with prefix tries is to store the suffixes using a map, but for fun I tried something different and used a list.
The main data structure I had was like this
type Key a = [a]
data Trie key = Node (Maybe key) [Trie key] Bool deriving (Show, Eq, Read)
So a trie is really just a node that has a list of other tries … Read more
4 04 2014
I’ve blogged about this subject before, but I REALLY hate null refs. This is one of the reasons I love F# and other functional languages, null ref’s almost never happen. But, in the real world I work as a C# dev and have to live with C#’s… nuisances.
In the other post, a big problem with the dynamic proxy was that it only worked with virtual methods, so it wasn’t really all that practical. This time around I decided to try a different route and leverage expression tree’s to actually build out the if checks automatically.
For the impatient, full source available at my github and the library is available on nuget
Let me demonstrate the final usage first. If all of users properties and methods return null, executing this whole chain would fail starting at the null result of
GetSchool(). But, by using the Option static … Read more