Scala OAuth Works!


My Scala OAuth client more or less works now. I have sent HMAC-SHA1 and Plaintext signed token and access requests to both Twitter and Yahoo APIs using both GET and POST. I have also sent tweets to twitter, received my timeline, etc.

My primary goal was for a very simple to use library rather than one that does everything. I think I've more or less accomplished that. Only two objects are needed, one for the initial token request and access request and then the second for making signed requests. Currently only POST and GET are supported and only text/string responses. …

→ read more

Django Syndication Framework


I've been looking for more to do with Django. I took a look at some of the common additional addons for Django and decided to use the syndication framework to add an RSS feed of the latest posts.

This basic usage was pretty simple to get up and running. It required adding one simple class which inherits from django.contrib.syndication.views.Feed, which I put in a new feeds.py file, and of course adding a line to urls.py.

from django.contrib.syndication.views import Feed
from cms.models import *

class BlogFeedRss(Feed):
    """RSS feed of latest posts"""
    title = "Bash-Shell.Net Posts"
    link = …
→ read more

Implementing OAuth In Scala


So I really liked Scala when I worked with it in the Seven Languages book. I've also been meaning to write an OAuth library for some time. I decided that this would be an interesting first project in Scala. It's not overly complex, but not so simple that I won't learn anything either.

So far I've written just enough to make the first request for a request_token from an OAuth provider. I used traits, treating them more or less like a Java abstract class, to create classes to sign the messages using HMAC-SHA1 or plaintext methods and will be adding …

→ read more

Seven Languages in Seven Weeks Wrap-Up


So I'm done with Seven Languages aside from maybe going back to do some of the exercises that gave me trouble at some point. I really enjoyed working my way through this book, even when it occasionally got frustrating. I've always been a firm believer that being familiar with more languages, styles, and paradigms will make you a stronger programmer, even if you don't use most of them often (or ever) after getting the base knowledge. I believe it gives you more ideas for how to solve problems and a better understanding of how things work. I highly recommend this …

→ read more

Seven Languages in Seven Weeks Part 13: Haskell Day 3


Well, this is the end of the book. Day 3 of Haskell. So far most stuff hasn't been too difficult with Haskell, but I do feel like I'm fighting with the syntax to express the logic more often than I am happy with.

The first exercise of day 3 is to create a hash table with has other hash tables as elements and a function that uses the Maybe monad to find elements in the hash table. Haskell already has Data.HashTable which does this, so I am assuming I'm not supposed to just use that, because that's a pretty pointless …

→ read more

Django FileField Delete


So I started with Django awhile back using The Definitive Guide To Django which covers Django 1.1. The book says that 1.x versions of Django are backwards compatible, so anything from this book will work in future 1.x releases. Unfortunately, I discovered this week that that isn't 100% true. In Django 1.2.5 FileField was changed so that deleting objects with a FileField doesn't delete the actual file, leaving a bunch of files in your media directory that have no ties to objects in the database.

Some solutions to this that I saw overrode the delete() method on a model to …

→ read more

Seven Languages in Seven Weeks Part 12: Haskell Day 2


It's been awhile, but day 2 of Haskell is complete. I've got a lot less spare time for doing these now that classes have changed up. I'm at work full time and then in class from 6pm to 10pm three days a week plus doing homework, etc. The house also got struck by lightning (everyone is ok and even the damage isn't too bad, all things considered) earlier this week which added more delays.

The first exercise was fairly simple, write a function that takes a list and returns a sorted list. I kind of feel like I cheated on …

→ read more

Seven Languages in Seven Weeks Part 11: Haskell Day 1


On to Haskell! There were 5 exercises for day one. The first just really didn't interest me, the second, third, and fourth I did, and the fifth I started but didn't know where to go with it so there's only one solution.

The exercise I did was to write a function that takes a list and returns it reversed. This actually took longer than it should have. The logic is simple enough, but I didn't find anything that alluded to the correct syntax to append a single character to the end of a list for awhile. I only saw ++ …

→ read more

Seven Languages in Seven Weeks Part: Io Recursion Revisited


I got bored and decided to do a better recursive Fibonacci method in Io. My previous one worked, but it had extra stuff in it that didn't need to be there. Here's a new one which has less garbage, but I think is still more efficient than the traditional recursive Fibonacci example that is used.

fib_recursive_2 := method(count,previous,current,

    if(count == nil, iteration := 0)
    if(previous == nil, previous := 0)
    if(current == nil, current := 1)

    if(count != 1 …
→ read more

Seven Languages in Seven Weeks Part 10: Clojure Day 3


I finally got through day 3 of Clojure. The last exercise was pretty rough and took several hours to get figured out. I also never posted the day 2 stuff, so I'll toss that in here. I was only able to do one day 2 exercise. The version of Clojure that comes with Debian 6 is only 1.1 and so does not support defprotocol and defrecord and I didn't feel like downloading and building a newer version since I'm not likely to use it again.

The day 2 exercise I completed was to implement an unless statement with an else …

→ read more

A Short Update


Well, things have been crazy. Work is keeping me busy, classes have started again, cars have died and needed replaced. I haven't had much time for writing code just for fun or closely monitoring stack overflow for questions to answer. I've been working on Clojure still and have completed the first of the day 3 exercises. The second one is requiring some thought, but I'll figure it out. I'll post those solutions and the Clojure day 2 solutions once I've got the last one finished.

I have nearly completed a Django application at work which does some cool stuff. It …

→ read more

Seven Languages in Seven Weeks Part 10: Clojure Day 1


So I finished the Erlang chapter and have moved on to Clojure. Before I talk about Clojure I'll wrap up Erlang briefly. I'm not posting the Erlang Day 3 bits because they weren't terribly interesting. The first exercise was incredibly simple and was nearly a copy and paste of examples already given. The second I could find no way to do, no examples, etc. The third was basically copying the first again. The bonus exercises appeared to be too much dull boilerplate and configuration to bother with.

Clojure seems alright so far. Unfortunately I suspect I may spend as much …

→ read more

Seven Languages in Seven Weeks Part 9: Erlang Day 2


Alright, day 2 of Erlang is done. I have not done the bonus problem yet and I probably won't unless a good idea strikes me.

Day 2 focused on list functionality like foreach, map, folds, etc. as has already been seen with the other languages. It also threw in list comprehensions which mostly feel like maybe a slightly shorter way to write out a map in certain cases. The book does mention that there's a lot more functionality with list comprehensions that was not covered, so maybe they would seem more special if I worked with the extra stuff. Python …

→ read more

Seven Languages in Seven Weeks Part 8: Erlang Day 1


I think I hate Erlang. Sure, it has cool features and nctionality, but this Prolog based syntax is terrible. I would never want to work on a large project using this. I think for real work I'll stick with these OO based languages that mix in functional features where it makes sense.

On to the exercises. First, a function that calls itself recursively to count to 10.

-module(count).
-export([counter/0, counter/1]).

counter() -> count:counter(1).
counter(N) ->
           if
           N < 10 ->
             io …
→ read more

Seven Languages in Seven Weeks Part 7: Scala Day 3


Day three got into concurrency, XML, and pattern matching in Scala. The concurrency uses the Actor model and it's easy enough to work with. I don't see the huge improvement in usability and simplicity over other threaded models I've worked with, but I haven't done very much (limited to Android AsyncTask and plain threads using the Thread() class with receivers in Java), so I'm probably just not experienced enough.

The pattern matching is what you'd expect. It works well, it handles regular expressions, etc. I like how you can just write out your regular expression as a string and use …

→ read more