Ubuntu 13.10 – Scrambled Screen Crash

October 24, 2013

I have been experiencing multiple crashes a day (some times more than 3 per hour) in Ubuntu since upgrading to 13.10 that results in a scrambled screen being shown. To recover I have to hard reset my laptop (Lenovo B590). I thought it was screen driver issues but could not get it resolved, so out of desperation I switched to Gnome3 and in 48 Hours I have had only one crash.

I have no intrest getting involved in the Unity vs The World debate, I just posted this here in the so that it might save some other poor Ubuntu user some frustration.

DX-Twitter – CL Twitter Interface

July 23, 2013

I have been doing a lot of refactoring of some of my existing projects and dx-twitter was the results of one of those refactoring sessions.

Like the repository says its a “A nearly usefull collection of lisp functions to use twitter api with”.

Well its a little more usefull now because I added a parser that translates tweets to cl objects for you so you don’t have to do the tedious bits of processing twitter stream feeds.

What is missing is some helper functions to handle continous streams from twitter.

As an asside I ended up with dx-oauth “a loose collection of functions to help with oauth”. A lot of the nasty bits where borrowed (with permission) from cl-oauth. dx-oauth focuses on what you need to use oauth with third party api’s like twitter and Facebook.

Yes dx-facebook is next, but I have not had the chance to push it to github yet but it will be there some time this month.

dx-twitter is simple, nothing fancy, but if you have ever tried to use social media api’s like the one for Twitter (or god forbid Facebook) you will know that there are a thousand little gotcha’s when calling api’s with oauth that can make life a missery. Hope fully dx-twitter can safe you some of that pain for the Twitter api.

If it looks a little rough around the edges it is because it is rough around the edges. However it will get smoothed out during the next month as I start using it in a commercial application.

WFX (CL web widgets) – Update

July 23, 2013

So I have not blogged for ages (more than a year, eish it feels like yesterday!), yeah I know it is bad form, but I have been busy. Well its a good excuse, if it means that some existing open source libs where updated and some new ones got birthed.

WFX a widget framework based on hunchentoot and cl-who has been receiving some much needed TLC. It now boasts an ajax grid and a lot of other basic widgets like linked drop downs etc.

Yes we have an ajax enabled acceptor with some functions to make using ajax simpler.

WFX also got some base widgets to help with integrating to html templates bought of the web, so now its easier to integrate that kewl admin template you got for a steel.

The changes have not been merged with the master branch because I am upgrading all my commercial sites with the changes first to make sure that what gets merged into the master is solid.

Yeah I should have kept my trap shut until all the changes where in master but I got excited because WFX will be easier to use now because a lot of the foot work has been done for you.

To make our lives even simpler there is dx-starter-site to help you kick start a site with security etc. but that needs some more work. The big question is do I add db support straight into it because we use xdb2 as our db for everything and I don’t know if that is what people would want. The idea with dx-strater site is that it should contain all the basics you need to start straight in with a web application instead having to do boring logins and other stuff to use out of the box.

If you are curious about the changes to WFX you can have a look at the expand-func branch.

Facebook with Hunchentoot and OAuth2

June 28, 2012

This is a quick and dirty to see how you can access Facebook stuff from Hunchentoot.

You will need Hunchentoot, Drakma, cl-who and cl-json to run this code. All of them can be gotten with Quicklisp.

You will also need a valid domain that points to localhost to test this code on your local machine. I just set up a subdomain on one of my servers that points to 127.0.0.1. If you don’t have access to your own domain server use localtunnel.com or something like it. What ever domain you decide on remember to set the site url in your Facebook app settings to the same domain.

When you want to access Facebook resources you need an access token and to get an access token you have to take the user to a facebook page that asks the user to log in and to give access to your app. Once the user has given access or denied access facebook redirects the user back to the callback uri that you specified, bringing them back to your web page.

If you look at the code you will see that we first get an access code from /dialog/oauth and then a token from /oauth/access_token, this is because we are using response_type=code. The reason we don’t use response_type=access_token is because what Facebook returns can’t be accessed by hunchentoot only javascript can get hold of the stuff after the # that is returned where you would expect a querystring.

Once we have an access token we fetch trivial data form Facebook for the user that authenticated.

The following code is not pretty but it is as short as I could get it without confusing the issues at hand.

There are various OAuth implementations for Common Lisp but if you are reading this you might have struggled with those and hopefully this code will help to clarify what is going on in those more involved implemetations of OAuth. (And none of them had Facebook examples that I could find.)

(define-easy-handler (callback :uri "/callback") ()
  (if (not (parameter "code"))
    (with-html-output-to-string (*standard-output*)
      ;;Clicking on this link will get you an access code, if the user approves.
      (:a :href "https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&response_type=code
                  &redirect_uri=http://A_VALID_DOMAIN_THAT_POINTS_TO_LOCALHOST:8000/callback" 
               (str "Go Facebooking")))
    (multiple-value-bind (body status)
        ;;Use the access code to get a access token.
        (drakma:http-request 
         (format nil "https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID
                       &redirect_uri=http://A_VALID_DOMAIN_THAT_POINTS_TO_LOCALHOST:8000/callback
                       &client_secret=APP_SECRET=~A" 
                 (parameter "code")))

      ;;Check if all was well.
      (if (equal status 200)
          (let* ((querystring (split-string body #\&))
                 (access-token (split-string (first querystring) #\=))
                 ;;(expiry (split-string (second querystring) #\=))
                 )

            ;;Fetch something interesting with your access token.
            (multiple-value-bind (bodyx)
                (drakma:http-request 
                 (format nil "https://graph.facebook.com/me?access_token=~A" 
                         (second access-token)))
                (format nil "~A" (json::decode-json-from-string bodyx))))
          (format nil "Something went wrong:~%~A"
                  (json::decode-json-from-string body))))))

(defun split-string (string char)
    "Returns a list of substrings of string divided by char."
    (loop for i = 0 then (1+ j)
          as j = (position char string :start i)
          collect (subseq string i j)
          while j))

SBCL glibc Error on Ubuntu

June 15, 2012

I use Ubuntu and SBCL for all my lisp development but lately the latest versions of the two have not been playing nicely with each other.

This will effect some of the instructions to install SBCL in my other blogs.

To get around the problem install sbcl in the following manner:

sudo apt-get install build-essential
sudo apt-get install sbcl
sudo apt-get install time
wget http://sourceforge.net/projects/sbcl/files/sbcl/1.0.57/sbcl-1.0.57-source.tar.bz2
bzip2 -cd sbcl-1.0.57-source.tar.bz2 | tar xvf -
cd sbcl-1.0.57-source
sudo sh make.sh
sudo apt-get remove sbcl
sudo sh install.sh

To test SBCL:
/usr/local/bin/sbcl

WFX, XDB2 – Open sourced

June 15, 2012

Most of what I do is web based systems in Common Lisp using Hunchentoot. Over time me and some of my collueges have created one or two packages to help us with this type of development. Some of these we always wanted to open source but never got round to it because we have not had the time to do decent documentation (something of a pet pieve of mine).

However we came to a point where we felt that despite the lack of documentation these packages would be of use to other lispers, so we took the plunge and opened up WFX and XDB2 to the public. Both have a BSD 2 clause license so what and how you do anything with them is your problem.

WFX is a widget framework written for use with Hunchentoot.

XDB2 is a collection of interfaces that you can use as a in memory persistable transaction log with snapshots.

(As time permits I will blog more about these packages, but don’t hold your breath, time has been in short supply this year so far.)

Garage48 : Postmortem

December 9, 2011

These are just some of my thoughts regarding the garage48 event (Johannesburg) I took part in.

Assumptions:

I went in with the wrong assumptions. The event is about new ideas and how to bring them about more than it is about code or technology. Yes there is a place for amazing code and wow technology but the focus is on bringing a new product to market. When you look at how the event schedule is run you will see that in effect you only have 24 hours to code and the rest is all about presentation and marketing.

What to do better next time:

Plan what is needed in a prototype better. A successful prototype is one that can show outputs to prove an idea’s viability and not how you got those outputs into being. Don’t bother with behind the scenes input screens that are needed to setup your application, dump the data in which ever way and show of the output and all the funky technology stuff you came up with.

Come better prepared. Set up a trusted “tool set” and possibly required libraries before hand and practice some of those things you don’t do often but will need in the competition. Loosing an hour here or there because you are rusty at a particular aspect of coding will be detrimental to your team’s success.

If its mobile it rocks. Maybe it was because of the nature of our local sponsors, but the rule of thumb is that if you can use it on your phone then it is kewl and will get higher regard.

Money talks. If the idea and product that was birthed over the 48 hours will make tons of money then it is better.

These are just my thoughts and I don’t want to take away from the organizers or sponsors in any way. They all did us proud at this event and I for one will be back next year, a lot more prepared and a lot more psyched up!

Thanx to all involved again.

Garage48 :Johannesburg

December 3, 2011

I am taking part the “Johannesburg” Garage48 event which started today. I am using Common Lisp at this event and even though the project I chose to work on is not really ground breaking stuff I am hoping to garner some interest for lisp.

It is going to be tough going because I only learnt about the event this morning and did not have as much time as I would have wanted to prepare, but I think we will do ok.

If you want to follow the event go to www.garage48.org/johannesburg and if you want to follow the progress on our little project go to www.socialvillage.co.za.

May the source be with us!

Hunchentoot 1.2.1 Gotcha

November 15, 2011

So you have been running hunchentoot for ages and got your grubby paws on 1.2.1 (most likely from quicklisp.org) but now your sites are throwing stuff like the following at you:

[2011-11-15 22:17:15 [INFO]] No session for session identifier ‘2:9CA87E6B20EE1E45F2637A82CD267198’ (User-Agent: ‘Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1’, IP: ‘127.0.0.1’)
127.0.0.1 – [2011-11-15 22:17:15] “GET /index HTTP/1.1” 404 184 “-” “Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1”

Well don’t dispair, you need to change the instances of hunchentoot:acceptor you create to start hunchentoot to hunchentoot:easy-acceptor. This is because all those funky create-*-dispatcher[-*] functions (used by define-easy-handler and maybe you directly) now belong to the “easy-handler framework”.

(Thanx H4ns for pointing that out.)

Thanx for SSD’s and 64 bit systems with lots of ram!

June 12, 2011

I was fortunate enough to have to upgrade my development machine. So I decided to throw in a SSD drive (a little 64gig thing) to put my operating system (Ubuntu – Natty) on and a few extra chips of ram (16 gigs to be exact).

Holy crap!!!

To start of with, I loaded Ubuntu in under 3 minutes from a cd! That includes answering questions like what drive do you want to install on, what is your location, what keyboard layout etc. In fact it was so fast that I decided to put my /home directory on a different disk to make loading different Linux systems easier, because at those speeds I am prepared to try some more systems.

I spend 12 to 16 hours a day working on my computer and you can not believe what a difference it makes to have a really decent system. Even my internet experience is far superior!

If you are a developer or/and just spend a lot of time on your system do yourself the favour and spend the extra bucks. And while you are at it throw in a bigger screen like a 20″ with senseye technology, its worth every cent.

I would never have imagined it would make such a big difference. It is really worth it!!


Follow

Get every new post delivered to your Inbox.