Primarily technical blog on Lisp, .NET, C# development.

Friday, December 7, 2012

LightSwitch Publish to Azure Issue

This one I got last week, as I was publishing an update for a LightSwitch application, to Azure. I made a change, published, all was good. Then I made some more changes, and when I tried to publish it again, I got this weird error about the authorization header:
Deployment failed : Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature
After some searching about this error on Google, I found out that this is a somewhat general error that might show up for different reasons. Great! After a lot of reading about the probable causes for the issue, I stumbled on this cryptic last post on one of the several MSDN topics on the subject:
Check your system time. it wrong. Problem solved - Artemov Ivan
Well, I had to check everything, so I went on and checked my clock. I had recently changed my motherboard so I thought there was a good chance my computer clock was messed up. Well, it wasn't. Then, suddenly it occurred to me that the Azure service was probably in an area that entered in daylight saving time. So I went ahead and added an hour to my computer clock, clicked the publish button and voilĂ , got it working! Back to work, then. Thanks, Artemov Ivan. EDIT: It turns out that after reinstalling SqlExpress2008 (I had only SqlExpress2012 installed), the system was finally able to publish without needing this weird computer clock workaround.

Tuesday, July 3, 2012

VMWare Player. Failed to lock the file error.

I had a power outage today while I was working with a virtual machine using the vmware player 4.0.4. When I got back to vmware and tried to start the virtual machine, I got this "VMware player cannot open disk ... Failed to lock the file" error message. After a little google search I found out that maybe a lock file could be causing this so I went to the folder where I had my virtual machine in and just deleted the lck file in the .vmdk.lck folder. Keeping it here for future reference.

Friday, November 4, 2011

Changing Connection String in Lightswitch

This has been annoying me on my work with Lightswitch, great tool for building business applications. Finally I found this information on a forum. It didn't get a high score there, but it was spot on.

With you want to change the connection strings in debug/release mode, search for Web.Config in project tree under the ServerGenerated folder. There you will find the connection string that is used by Lightswitch in design time.

You will have to close and reopen the solution so the change takes effect...

Thanks to Nehemiah Willis post at: Original forum post

Friday, July 22, 2011

Company Logo

I am finally in the process of starting my own business. Today, I received the logo/brand name. Here it is.


I am obviously biased, but I think it looks great.

Thursday, February 17, 2011

Quicklisp is great!

After a long time not doing anything Lisp, I decided to check my installation just to see if my code was still OK. It turns out that something was broken with my libraries and its dependencies.

The everyday in Lisp programming.

This time I decided to go look for something different and decided to give Quicklisp a try.
Just for the record, if you haven't tried it yet. Try it now. It exceeded all my expectations.

I was able to get an old project ready in less than 5min with all the right libraries up and running.

So, thank you Zach Beane, for Quicklisp!

Check it out at: http://www.quicklisp.org/

Thursday, May 13, 2010

Lisp style

Consider the following snippets of code:


(let ((probed-path)
(not-found t))
(dolist (registry-expression asdf:*central-registry*)
(when not-found
(setf probed-path (eval registry-expression)))
(when (probe-file (merge-pathnames "asd-library.asd" probed-path))
(setf not-found nil)))
probed-path)

(first (remove-if #'null
(mapcar #'(lambda (x)
(when (probe-file
(merge-pathnames "asd-library.asd" (eval x)))
(eval x)))
asdf:*central-registry*)))

Both codes perform the same task. The first one is more like a procedural/imperative code in style than the more functional second one.

By the way, they return the path for a registered library. It is not very useful since ADSF provides the same thing easily with a single function call:

(asdf:system-relative-pathname :asd-library "")

But I like to get back to it as a reference of lisp styles.

Thursday, April 29, 2010

How to make Postmodern ignore incomplete mapped DAO

Yesterday I was working with a database using Postmodern (http://marijn.haverbeke.nl/postmodern/) and I ran into an issue trying to adding a column to one of my databases. 

According to its current implementation, postmodern raises an error if the DAO and the table scheme are not matching. In order words, the DAO class must have all fields from the table it maps to. 

In a real world environment, a web application running live for example, it might not be acceptable to bring the application down just because a new column was added to the table it uses. 

Sometimes, depending on the database design, a table can contain information from several DAO's, specially if they have a parent-child object relationship. 

In order to remove this validation from postmodern allowing you to have DAO's mapping to a subset of the fields of a table all it is needed is a little patch on the postmodern table.lisp file on the function as follows:

(defun dao-row-reader (class)
  "Defines a row-reader for objects of a given class."
  (row-reader (query-fields)
    (let ((column-map (append *custom-column-writers* (dao-column-map class))))
      (loop :while (next-row)
            :collect (let ((instance (allocate-instance class)))
                       (loop :for field :across query-fields
                             :for writer := (cdr (assoc (field-name field) column-map :test #'string=))
                             :do (etypecase writer
                                   (null (next-field field))
                                   (symbol (setf (slot-value instance writer) (next-field field)))
                                   (function (funcall writer instance (next-field field)))))
                       (initialize-instance instance)
                       instance)))))

Compare with the current version code where if the field is not found it raises an error:

(defun dao-row-reader (class)
  "Defines a row-reader for objects of a given class."
  (row-reader (query-fields)
    (let ((column-map (append *custom-column-writers* (dao-column-map class))))
      (loop :while (next-row)
            :collect (let ((instance (allocate-instance class)))
                       (loop :for field :across query-fields
                             :for writer := (cdr (assoc (field-name field) column-map :test #'string=))
                             :do (etypecase writer
                                   (null (error "No slot named ~a in class ~a. DAO out of sync with table, or incorrect query used."
                                                (field-name field) (class-name class)))
                                   (symbol (setf (slot-value instance writer) (next-field field)))
                                   (function (funcall writer instance (next-field field)))))
                       (initialize-instance instance)
                       instance)))))