How to start with jQuery

Lately I have been working on several web applications, both as hobby projects and at work. I started using YUI3 a few years ago as a Javascript framework, and I liked it. But I kept hearing about jQuery, and the times I saw code snippets, I was intrigued. It looked different, but at the same time jQuery seemed very powerful and efficient.

So a while back I started looking closer at jQuery, and I found that it was extremely easy to learn. One need a decent understanding of HTML and the browser DOM (Document Object Model), as well as Javascript knowledge. Add some CSS to that, if you want the page to look good as well, and you are set.

So how do you start using jQuery? The easy way is to take advantage of companies like Google and Microsoft who are hosting different frameworks (including jQuery) on their servers for public use. You don’t have to worry about downloading and hosting it yourself, and you can get started in just minutes.

You add code to your page to utilize jQuery, then add some script. You have to allow the browser to wait for the webpage to fully load before you can start doing things, and this is done using $(document).ready(). When that event is triggered, the code you have added there will be executed.

It is very easy to address elements on your webpage. If I have an element (could be a button, a span/div section, a link or even an image) with the id “messageBox”, I can address it like this: $(“#messageBox”). I then have different properties and methods for that element.

But I have always believed in “show me the code”. I created a very simple demo. The webpage contains a button and a div where we want to display a text when the button is clicked. I have some CSS to make the text look nice, and a few lines of jQuery code to do the work.

<html>
  <head>
    <title>Hello, jQuery</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
  </head>

  <script>
  // The following function is executed after page is fully loaded
  $(document).ready(function () {
    // Setup the element with id "btnSave" to react on click
    $("#btnSave").click( function() {
      // When clicked, set the innerHTML of the element with
      // id "messageBox" to the specified html string.
      $("#messageBox").html("You clicked the <strong>Save</strong> button.");
      $("#messageBox").addClass("statusMessage");
    });
  });
  </script>

  <style>
    .statusMessage {
      font-family: Arial;
      font-size: 0.9em;
      color: #AA0000;
    }
  </style>

  <body>
    <button id="btnSave">Save</button>
    <div id="messageBox"></div>
  </body>
</html>

That’s it. Try it yourself, paste this code into a text file and call it jQuery.html, then open it in your browser.

Result of jQuery.html
The result. Click for a larger version.

Now when you understand the basics, you can learn more advanced things. I am using jQuery to very easily perform Ajax calls, even calling Lotusscript web agents to return data from a Domino database to my webpage. I also use it for all kinds of dynamic updates to webpages.

A while back I started on a Domino-based web chat as a hobby project. I started building it using YUI3, but after finishing the initial landing page, I started using jQuery on the actual room pages. The other night I simply ripped out the YUI3 code and replaced it with (much less) jQuery code. It took my just an hour or two. The site/chat is currently in Swedish, but I plan to translate it to other languages, and I will blog more about this project soon. Feel free to try it out, or just look at the source code for the pages. I am sure you will very quickly understand how it works. On that page I use jQuery to call server agent to return the number of users (and their names) present in the different rooms. I also check values in field, as well as update fields, hiding/showing elements on the page depending on field values, etc.
I also use a jQuery plugin to display bubbles with information (pulled in real time from the Domino database using a web agent) when hovering over the count of users in a given room.

 

0 Comments

Lightbox Plus – Thanks Bob Balfe!

Earlier today, Bob Balfe wrote a blog post about installing Lightbox Plus on his blog. I decided to test it on this blog as well, and I really like it. I might make the images I post slightly smaller in the future, as the plugin does not scale down the full-size image is it is larger than the browser window.

Installing the plugin was as easy as it could be. I just selected “Add New”, searched for the plugin,clicked the install button and then activated it. There was a warning that the plugin might not work with the newer version of WordPress I am running, but it all worked for me without any issue. I did not even have to configure anything, the images started showing up in the lightbox automatically. There are a few settings, mainly for the style of the lightbox. But you don’t even need to touch that if you don’t want.

Thanks Bob for posting about this!

1 Comment

Photo – Thunderbirds in Ft Worth

I took this picture the other weekend, and it is one of my favorites from the Air Show. I always enjoyed these kind of demonstrations. It is a little like programming, man in charge of machine. Well, in most cases…

You may not be able to tell, but the number 5 right behind the air intake on the lower F-16 is actually painted upside down, so it appears correct to the spectators. This is because this particular position is flying mostly upside down…

US Air Force Thunderbirds
Thunderbirds performing at the 2012 Ft Worth Airshow.
0 Comments

Fort Worth Airshow 2012

While going to the 2012 Ft Worth Airshow two weekends ago, I took a few pictures. Like a little over 2000… 🙂 I have processed a few of them, and wanted to show a few HDR pictures I took. The day of the airshow was cloudy and windy, so the sky was fairly gray, and it was a bit dark as well. Perfect conditions to test some more HDR…

A Soviet era Mi-24 Hind.
Here I played a little bit more with the picture…
2 Comments

Moving blog posts from Connections to WordPress

As I switched from IBM Connection to WordPress for my blog, I started thinking about my existing content. Was there a way to move them all over without having to manually copy and paste and recreate all 268 entries?

Well, there is, and this is how I did it, using just a  few tools. First I used Wget to retrieve my old blog. This put all the posts on one folder (entries), and all images in another (resource). It was then a simple task to write a Lotusscript agent that processed each file in that folder and read the content, parsed out the title, date originally posted and HTML for the blog post itself. I put that data into separate Notes documents, after performing some cleanup and string replacement.

I had already moved all images to a filer on my primary web server, so I performed a replace of the image URLs in the HTML, to have any images pointing to their new location. I also had to fix some special characters and replace them with the corresponding HTML entities.

Now when I had all the data, I just wrote another agent to export the data out again, to create a CSV file. I then installed a CSV importer in my WordPress blog and used to to import the file I just created.

After a few tweaks I performed a successful import. Later I realized I had missed a few special characters, so I had to fix those entries, but we are talking about 4 or 5, out of 268 entries.

If there is an interest, I might clean up the code a little and create a nicer UI (right now many of the values like path and URL are hard-coded) and then release the code if anyone else is planning to go through the same exercise. Below is the existing code to read the blog entries into a simple Notes database.

Option Public
Option Declare

Dim entrydir As String
Dim resourcedir As String

Sub Initialize
	Dim filename As String
	Dim cnt List As Integer
	Dim blogentry List As String
	Dim tst As Variant 

	entrydir = "D:\BleedYellowBlog\www.bleedyellow.com\blogs\texasswede\entry\"
	resourcedir = "D:\BleedYellowBlog\www.bleedyellow.com\blogs\texasswede\resource\"

	cnt("Total") = 0
	filename = Dir$(entrydir + "*.*")
	Do While fileName <> ""
		blogentry(filename) = entrydir + filename
		cnt("Total") = cnt("Total") + 1
		fileName = Dir$()
	Loop

	cnt("Processed") = 0 
	ForAll be In blogentry 
		cnt("Processed") = cnt("Processed") + 1
		Print "Processing " & cnt("Processed") & " of " & cnt("Total")  
		Call ProcessBlogEntry(ListTag(be),be)	
	End ForAll
End Sub

Function FixHTML(html As String) As String
	Dim tmp As String

	tmp = Replace(html,_
"https://www.bleedyellow.com/blogs/texasswede/resource/",_
"http://www.texasswede.com/blogfiles/resource/")
	tmp = Replace(tmp,_
"http://www.bleedyellow.com/blogs/texasswede/resource/",_
"http://www.texasswede.com/blogfiles/resource/")
	tmp = Replace(tmp,"/BLOGS_UPLOADED_IMAGES/","/uploaded_images/")
	tmp = Replace(tmp,"´",|"&acute;"|)
	tmp = Replace(tmp,"’","&acute;")
	tmp = Replace(tmp,"“",|&quot;|)
	tmp = Replace(tmp,"”",|&quot;|)
	tmp = Replace(tmp,"…",|"..."|)
	tmp = Replace(tmp,"<wbr>",||)
	tmp = Replace(tmp,"> < ",|>&anp;nbsp;< |) 	
        FixHTML = tmp 
End Function 

Function ProcessBlogEntry(filename As String, localpath As String) As Boolean 	
        Dim session As New NotesSession 
	Dim db As NotesDatabase
        Dim blogentry As NotesDocument 	
        Dim rtitem As NotesRichTextItem
        Dim siteurl As String  	
        Dim html List As String
        Dim tmp As String
        Dim import As Boolean
        Dim titlesection As Boolean
        Dim row As Integer
        Dim currow As Integer  	
        Dim titletext As string
        Dim htmltext As String
        Dim title As String
        Dim posteddate As String
        import = False 	
        titlesection = False
        row = 0 	
        Open localpath For Input As #1 charset="UTF-8"
        Do Until EOF(1)
            Line Input #1, tmp
            If InStr(tmp,|class="entryContentContainer"|) > 0 Then
	 	import = True		
	    End If
	    If import = True Then
		If InStr(LCase(tmp),|<!-- rating -->|) > 0 Then
			import = False		
		End If
 	    End If
	    If InStr(LCase(tmp),|<!-- entry title and info -->|) > 0 Then
		titlesection = True		
	    End If
	    If titlesection = True Then
		If InStr(LCase(tmp),|<!-- user name, date, meta info -->|) > 0 Then
			titlesection = False
		End If
	    End If
	    If titlesection = True Then
		titletext = titletext + tmp
	    End If
	    If InStr(LCase(tmp),|blogsdate.date.localize|) > 0 Then
		posteddate = StrLeft(StrRight(tmp,"localize ("),"));")
	    End If
	    If import = True Then
		row = row + 1
	 	html(CStr(row)) = tmp
	    End If
	Loop
	Close #1

	Set db = session.CurrentDatabase 
	Set blogentry = New NotesDocument(db)
	blogentry.Form = "Blog Entry"
	title = Replace(FullTrim(StrLeft(StrRight(titletext,"<h4>"),"</h4>")),"@amp;quot;",|"|)
	Set rtitem = New NotesRichTextItem(blogentry,"Content") 
	posteddate = Format$(JSMillisecondsToLSDate(CDbl(posteddate)),"mm/dd/yyyy hh:nn") + " GMT"
	siteurl = "http://www.bleedyellow.com/blogs/texasswede/"

	Call blogentry.ReplaceItemValue("Title", title)
	Call blogentry.ReplaceItemvalue("PostedDate", posteddate)
	Call blogentry.ReplaceItemValue("OriginalURL", siteurl + filename)
	currow = 0
	ForAll t In html
		currow = currow + 1
		If InStr(t,	|class="entryContentContainer"|)>0 Then
			' Do nothing				
		Else
			If currow < row-2 Then
				Call rtitem.AppendText(fixhtml(t))
				Call rtitem.AddNewLine(1,true)
			End If
		End If
	End ForAll
	Call blogentry.ComputeWithForm(True,False)
	Call blogentry.Save(True,True)

End Function

Function JSMillisecondsToLSDate(millis As Double) As Variant
	Dim ndt As NotesDateTime
	Dim zoneOffset As Integer
	Dim jsEpochDouble As Double, adjustedEpochDouble As Double, millisDateDouble As Double

	%REM
	JavaScript millisecond values are based on GMT
	but writable LotusScript date/time values are local.
	We need to know the local timezone offset from GMT,
	and for that we need a NotesDateTime object
	with both date and time components
	%END REM

	Set ndt = New NotesDateTime(Now)
	zoneOffset = ndt.TimeZone

	'The JavaScript epoch is midnight (day start) January 1, 1970 GMT
	jsEpochDouble = CDbl(DateNumber(1970,1,1))

	'Adjust epoch to local time
	adjustedEpochDouble = jsEpochDouble - (zoneOffset/24)

	'There are 86400000 milliseconds in a day
	millisDateDouble = adjustedEpochDouble + (millis / 86400000)
	JSMillisecondsToLSDate = CDat(millisDateDouble)
End Function

 

And here is the  agent to export the documents to a CSV file that can be imported into a WordPress blog using the CSV import plugin.

Option Public
Option Declare

Sub Initialize
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim doc As NotesDocument
	Dim filename As String

	filename = "d:\bleedyellow.csv"
	Open filename For Output As #1
	Print #1, |"csv_post_title","csv_post_post",| + _ 
                  |"csv_post_type","csv_post_excerpt",| + _ 
                  |"csv_post_categories","csv_post_tags",| + _ 
                  |"csv_post_date","custom_field_1","custom_field_2"|
	Set db = session.Currentdatabase
	Set view = db.GetView("By Title")
	Set doc = view.GetFirstDocument
	Do Until doc Is Nothing
		Print #1, GetCSV(doc)
		Set doc = view.GetNextDocument(doc)	
	Loop
	Close #1
End Sub

Function GetCSV(doc As NotesDocument) As String
	Dim rtitem As NotesRichTextItem 
	Dim tmp As String
	Dim content As String

	Set rtitem = doc.Getfirstitem("Content")
	content = Replace(FullTrim(rtitem.GetUnformattedText()),|"|,|""|)
	tmp = |"| + Replace(doc.GetItemValue("Title")(0),|"|,|""|) + |",|
	tmp = tmp + |"| + content + |",|
	tmp = tmp + ",,"
	tmp = tmp +|"| + "Old Blog Post" + |",|
	tmp = tmp +|"| + doc.GetItemValue("Tags")(0) + |",|
	tmp = tmp +|"| + doc.GetItemValue("PostedDate")(0) + |",,,|

	GetCSV = tmp
End Function
1 Comment

Welcome to my new blog

After having my blog hosted by Lotus911 (later GBS) at bleedyellow.com for almost five years, I have decided to switch blog platform. The main reason is due to limitations in IBM Connections as a blog platform (no anonymous comments and issues for example when trying to embed videos). I decided to go with WordPress as my blog platform, as it is common and widely supported.

Another advantage with a WordPress hosted blog that is that I now can have the blog hosted under my personal domain, as blog.texasswede.com.

Earlier today I imported the existing content to the new blog. I will write about that process in another blog entry shortly. Basically I wrote a couple of Lotusscript agents in Notes and retrieved the existing blog content and then reformatted it for WordPress. As I did not have very many comments, I did not import them, as I decided the amount of work was not worth it. They can be found on my old blog, as I will keep it alive. That way all the links to it from different placs will also continue to work.
I have not verified all old entries, so if you notice anything that need to be fixed, please let me know. One known issue is when I reference another blog entry, the link will currently take you to bleedyellow.com.

Again, a big thanks to GBS who hosted my blog for the last five  years, and who got me into blogging. I had made some attempt prior to 2008, but never got motivated enough. Hopefully the switch to WordPress and the greater possibilities will lead to me blogging more frequently than lately.

5 Comments

Nostalgia

I am sure most of you who started programming around the same time that I did (in the first few years of the 1980's) at one point carried something like this in your wallets:

ASCII Table

 

1 Comment

Things to think about when programming in Notes

Inspired by some of the posts in the DeveloperWorks forums and on StackOverflow, I thought I would post some more basic concepts and how I handle them. I am not saying my way is the best way, this is just what works for me. I am sure there will be more posts in the future”…”

I will also mention a few other things I noticed while reading the code posted in the forums.

 

Retrieve something that doesn´t exist

The question is how to identify what dates there are no documents created for. This is where lists are very useful. Richard Schwartz answered this question and posted some good code.
Rich suggests to create a list of dates, with each list item having an initial values of false, and then loop through the documents. As each document is processed, the value of the corresponding list item is changed from false to true. You can then go through the list and see which dates still have a value of false, those dates are missing documents.

My version of the same code is to actually delete the list item you have a match for, instead if setting it to true. In the end you have a list of just the items of dates without a corresponding document.

 

Write readable code

This could be a blog entry all by itself. But I notice that much of the code in the DeveloperWorkds forums is hard to read”´”. Partially because any tabs or multiple spaces used for indenting the code is stripped out, but also because the posters don´t write easy-to-read code.

Variable names are often not descriptive:

Dim db1 As NotesDatabase
Dim db2 As NotesDatabase

vs

Dim thisdb As NotesDatabase
Dim nabdb As NotesDatabase

Which one is easier to understand? In my opinion (and I am sure you agree) the second variant. Also function names and other variables should be named so you understand what they do and what kind of data they contain.

Comments are mostly non-existing. It is not that hard to add some comments to the code that explain what the code is doing. But don´t explain every line of actual code (it should be self-explanatory, if variables are named correctly), explain what a particular section of code is intended to do.

Here is a section of code from an agent I wrote earlier this week:

'*** Read PhotoUNID field in LossControl document'*** and build a list of the UNID values in the fieldphotoUNID = lcdoc.GetItemValue("PhotoUNID")(0)If photoUNID<>"" Then '*** Create array of values and put into photolist tmparray = FullTrim(Split(photoUNID,";")) ForAll t in tmparray If t <> "" Then photolist(t) = t End If End ForAll End If

The comments above will help the next person to look at the code to quickly understand what it is intended to do.

 

More on variables

Use Option Declare/Option Explicit. This will find many errors, especially for more inexperienced programmers, where variables are misspelled or missing, something that is a very common reason for posts in the forums.

Another thing that a surprisingly large number of posters seem to struggle with is how to correctly declare variables. I see many cases where several variables are declared on one row, but only the last one has the data type. The author of the code was thinking it would apply to all the variables:

Dim FirstName, LastName, Street, City, PostalCode, State as String

This will declare State as String, but all other variables as Variant. This is not unique for Lotusscript, Visual Basic (on which Lotusscript is based) works the same way.

I always declare each variable on a separate line. This makes it easier to find a particular variable if I am looking for it. I also declare all variables in the beginning of the code/function, again to make it easier to find it in the future. Finally I order the declarations in the same order:

1. Notes UI classes (so they are easy to locate, in case I need to rewrite the code to be used in a server-based agent.

2. Notes backend classes. I always declare them in the order they are being used, as this also is how the classes are structured.

3. Variables and custom classes, in the order they are used.

Here is an example, from the same agent as above:

 Dim session As New NotesSession Dim photodb As NotesDatabase Dim lcdb As NotesDatabase ' LossControl DB Dim lcview As NotesView Dim lccol As NotesViewEntryCollection Dim lcentry As NotesViewEntry Dim lcdoc As NotesDocument Dim photodoc As NotesDocument Dim rtitem As Variant Dim rtnav As NotesRichTextNavigator Dim rtlink As NotesRichTextDocLink  Dim cnt List As Long Dim photoUNID As String Dim unid As String Dim photolist List As String Dim verifiedlist List As String Dim tmparray As Variant Dim photos As String

As you can see, I also put a comment there, to explain what lc stands for.
I also try to use a list for counters, instead of having a number of separate variables. Doing that makes the code easier to read and understand, despite it actually being longer:

 cnt("Total") = lccol.Count cnt("Processed") = 0 cnt("Updated") = 0 cnt("UpdatedPhoto") = 0
 cnt("Processed") = cnt("Processed") + 1 If cnt("Processed") Mod 10 = 0 Then Print cnt("Processed") & " of " & cnt("Total") End If

See how easy that code is to read?

 

Use the Debugger

I see many messages where the poster is getting an error message, or an unexpected result (or no result at all). Sometimes a large chunk of code is posted, but no indicator where the error happens.

It seems like very few (at least of the obviously less experienced programmers) use the debugger at all. In most cases they would quickly find the problem that way, instead of asking why they get “object variable not set” or “type mismatch” errors somewhere in 100 lines of code”…”

Yes, the debugger has limitations, and it could use some new features (like breaking when a particular variable has a specified value or match an expression), but it is a huge help even in the current form.

 

Understand Data Types

Many problems are because the programmer did not understand what data type different functions returns, or even (in some cases) what the different data types means. One poster (I can´t find the post right now) had code like this:

 Dim x As Integer x = 0 x = x + 3.5 MsgBox x

He was the surprised that the message box displayed the value 4… I think understanding data types is a requirement of being a programmer, even if the language you work with is forgiving or don´t require variables to be declared.

 

Analyze the problem

Another common issue I see is that it seems like the programmer just got an assignment and started to write code, without thinking through what the actual process is going to be. He/she often write him/herself into a corner, or is so focused on solving it with existing knowledge (e.g. “has to be @Formula language”), that the difficulty level of the task approaches impossible. Or the code will be extremely convoluted.

Think through the problem, break it down into small problems/steps. Break each of those down into even smaller steps, etc. Finally you have a good specification, and often even pseudo code. It m
ay be that the user requesting the program/functionality (a.k.a. stakeholder) is saying how he want it to be done, but that is really not the stakeholders responsibility. He/she should just explain what the end result should be, and the developer will design the best solution.

I have examples where a manager comes to me and asks for a report “in Excel” of data in a Notes database. That is because the manager in this case was used to working in Excel, and thought of how Excel displays data as the way he wanted it.
I could very easily create a report directly in Notes, displaying exactly the same information. Since I asked what the end result was supposed to be, and how the data was supposed to be used (and by whom), I could avoid Excel altogether and built a pure Notes solution.

This is where experience comes in, things like that is not something you can just pick up at college/university. If you don´t have the analytical/problem solving skills, you will struggle as a programmer. You might be able to write code under strict guidance, or you might even be able to eventually complete the assignment, but it will most probably not be the best/fastest solution, even if the code will work.

Two good blog entries are Separating Programming Sheep from No-Programming Goats (CodingHorror, July 2006) and Why Can´t Programmers.. Program? (CodingHorror, February 2007). Programming consists of problem solving and analytical skills, fundamental skills (like data types, how functions works, recursion different kind of branching/looping), as well as understanding the language and platform you use. If you are missing any of those things, you will probably not be a very good programmer.

 

0 Comments

Movie Review: Looper

Last night I went to see Looper. I had actually not heard much about it, but I looked it up online real quick and at least it sounded like a good premise for a movie. I have always enjoyed sci-fi, and especially time-travel.

The premise is that Joe is a "looper", a contract killer in a near future (2044). About 30 years after that, time-travel has been invented, but declared illegal. So only the biggest crime syndicates have access to time-travel, and they use it to get rid of people. The send the victim back 30 years in time, bound and gagged with a hood over their heads. The looper promptly kills them and disposes of the body. The looper is paid with silver attached to the victim. Occasionally the future version of the looper is sent back, who kills his older himself. The is called "closing the loop".

Joe (played by an excellent Joseph Gordon-Levitt) is a looper. One day his future self (Bruce Willis) shows up, but promptly escapes. In the future, a new gangster boss, "The Rainmaker" has taken over, and he is closing the loop on all loopers. In doing so, the future Joe lost his wife, and he is now looking to prevent this by finding the young Rainmaker in the past and kill him.

I truly enjoyed this movie, it was absolutely much better than I had expected, and it makes you think more than the average movie. The story is clever and it works. You see influences of both Back to The Future and The Terminator in the story, as well as to Carrie and X-Men (with the concept of telekinesis), but it all fits well into the story.

I would highly recommend this movie. However, it´s not a movie for kids, due to violence (and for sensitive Americans, some nudity).

 

0 Comments

Are inexperienced developers the death of Notes?

Lately I have been more active in the IBM DeveloperWorks forums, as well as on StackOverflow, trying to help people with development problems. As I am just myself starting with Xpages, I been staying in the forums for "classic" Notes development.
I have noticed a trend, based on the postings. It seems like there is a substantial number of new developers who are not very familiar with Notes/Domino development. They sometimes think Domino works like a relational database.
There are then several who are posting about very simple things, that can easily be found in the online help, or by looking at the properties for an element. Like how to extend the last column in a view to use all available space.
There was even one user asking about how to duplicate a specific @Formula in Lotusscript, when the help file got a cross reference to the class and method to use…

There are others who does not seem to even understand the basics, either when it comes to programming in general or specifically of Notes/Domino.
Some of them don't understand data types. They declare a variable as integer, then make a calculation that results in a value of say 3.5, and is then wondering why the result is 4.
Others don't understand the difference between strings and variables, they are surprised when @SetField("myField"; "myField + 1") does not give them the expected result (the value in the field ‘myField’ increased by one).

On StackOverflow it is possible to see what other areas the user posted in. Some of the users seems to have a background in Java, SQL, .NET or other platforms. My guess is that they been thrown into a Notes projekt after their company took on a new development project, with the hope that they could learn it quickly. I think this could be dangerous, from some of the code I have seen, the lack of experience and understanding of the Notes/Domino platform will cause sub-standard or slow code, which of course will make executives think that Notes is a bad development platform. After all, if the expensive consulting company (or the off-shore based development house with all developers being at least Ph.D.) can't write fast and good code, the platform must be at fault, right?

Another thing I noticed over the last year or so is that in the Notes-related groups on LinkedIn, there has been a number of requests for the answers to the IBM certification tests. They have originated from both some big consulting companies and from within IBM. None of them were from the US (or Europe, if I remember correctly), but from countries more traditionally associated with outsourced or "off-shore" development. My guess is that the companies want their developers to be certified on paper, as they can either charge higher rates, or pass themselves off as being “experts” on the platform.
A number of the questions in the DeveloperWorks forums were posted under names that often are associated with the same countries/regions.

What I think we are seeing is the result of American and (in some part) European companies using cheaper off-shore development companies in order to save money. What they don't think of is that, unless the developers has a good knowledge of the product, that a local developer with many years of experience will create the same or better result in a much shorter time. So even at a higher hourly rate, the end result will be less expensive as well as better.

I want to make it clear that I don't think all developers in the countries typically associated with off-shoring (India, China, Russia, the Baltic states, Brazil, etc) are bad programmers. I know very competent developers from several of those countries, and I know some not-so-good developers in Europe and North America.

What I am afraid of is that off-shore development companies takes on Notes-projects, expecting (or hoping) their staff will quickly learn the product/platform and quickly develop the requested solution. In the process they are making Notes look bad as they don't understand the platform.
At the same time, the companies that is purchasing the solution are just looking at the hourly rate, and perhaps an initial estimate of how quick and inexpensive (due to low hourly rates) the project is promised to be completed. In the long run, I fear that Notes/Domino as a platform will suffer because of this.

The project management triangle  is still true:

You are given the options of Fast, Good and Cheap, and told to pick any two. Here Fast refers to the time required to deliver the product, Good is the quality of the final product, and Cheap refers to the total cost of designing and building the product. This triangle reflects the fact that the three properties of a project are interrelated, and it is not possible to optimize all three – one will always suffer. In other words you have three options:

Design something quickly and to a high standard, but then it will not be cheap.
Design something quickly and cheaply, but it will not be of high quality.
Design something with high quality and cheaply, but it will take a long time.

ProjectTriangle

Of course, an experienced Notes/Domino developer can make the rule somewhat invalid, but it requires extensive experience. 🙂

I don’t have a good solution. Perhaps companies thinking about outsourcing development need to be more diligent at selecting developers, requesting details about their previous experience, etc. Perhaps they need to ask more questions, including how many years of Notes/Domino experience the developers have. Personally, I would not suggest hiring a consulting company who haven’t had a presence at Lotusphere or at least had some of their developers speak there or at any of the LUG-conferences around the world. Many of the best Notes developers also got blogs where they post code and/or information, I would require a link to some blogs as well, so I could judge the quality of their code.

 

0 Comments

Neil Armstrong dies at age 82

NeilArmstrong_Lotusphere2007

Neil Armstrong. The first man on the moon. Speaker at Lotusphere 2007 (where I took the picture above). Self-proclaimed geek.

I always loved reading about space growing up, and I read everything from sci-fi to real stories. One of my favorites was Carrying the Fire: An Astronauts Journey by Michael Collins (the third Apollo 11 astronaut), which I read in Swedish translation (as I was just 7 or 8 years old at the time).

So when Neil Armstrong stepped up on stage at the 2007 Lotusphere Opening General Session, that was the coolest speaker ever. And he was not just another celebrity, he was interesting and funny. My favorite quote was this (as far as I rememeber):

The scientists came up with an experiment to measure the distance from Earth to the moon, using a laser. But in order to do that, they needed a mirror placed on the lunar surface. I was the service technician tasked to put the mirror there.

 

Best speaker ever, and with Lotusphere being renamed to Connect, he will keep that title forever.

 

0 Comments

Healthy (and tasty) bread rolls from my youth

When I went to school in Sweden in the early 1980´s, it was (I believe it still is) mandatory to attend “hemkunskap” (translates into “home knowledge”, probably somewhat close to home economics). These classes were taken during 7th to 9th grade, and included cooking/baking, how to do dishes, washing clothes by hand, creating a budget and furnishing an apartment with a set amount of money.

A couple of years ago, my sister found a recipe I had written down on a piece of paper from when we baked bread rolls at school. I favored graph paper, not just for math but for all kinds of notes, as you can see in the scan below.

One interesting item is the note in the upper right section, next to the amount of yeast to use. Translated it says “Note: put it [the yeast] in first, otherwise mom will be angry.” Not long before I was supposed to bake bread using our break maker at home, and I forgot the yeast in the beginning, so I added it at the end of the baking process, with above mentioned result”…”

Recept

 

After I got the recipe, I tried to make the same rolls, and they actually turned out very tasty. As they are healthy, I wanted to share how to make them. I have made one change to the recipe above, I added a small amount of sugar for the yeast to consume, but I am sure it would also be very good using a little bit of honey.

1 cake of yeast (or 3 packets dry yeast, do not use RapidRise!)
8 dl (27 fl oz/3.4 cups) warm water (32?/90? for yeast cake, 37?/100? for dry yeast)
8 table spoons of oil
16 ml (just over 3 teaspoons) of salt
(optional) barely 1 tablespoon of sugar or honey
12 dl (5 cups) graham flour
4 dl (1.6 cups) wheat flour

Put the yeast in a big bowl. Add sugar and salt to the warm water, stir to dissolve. Add a little of the water to the years and stir to dissolve yeast in water. Add the rest of the water and the oil, stir well.
Add the wheat flour and the graham flour. Add half of it, stir well, add half of the rest, stir more. Add the rest little by little. When the dough is getting fairly solid, dump on a baking table and start kneading, adding more flour as needed.

When the dough is sticky but not wet, and well kneaded, shape it into a big ball, put it back in the bowl, sprinkle over some wheat flour and cover with a baking towel. Let it rise for 20-30 minutes. Don´t allow it to stand in a cool area or in draft/near an air conditioning vent. I prefer to put it outside, the Texas summer temperature of 95-100 degrees is perfect. Don´t let it get over 100 degrees, or the yeast will die.

After the dough have been rising (should about double in size) put it back on the table. Cut it in four sections, shape each part as a small loaf and cut in 6 pieces. Shape each of the 24 resulting pieces into a ball (don´t press too hard, you just want to shape them, not compact them) and put them on cookie sheets. Leave plenty of space between each, I usually put no more than 12 on one cookie sheet. Again cover with baking towels and rise additionally 30-40 minutes.

Bake the rolls about 7-9 minutes in 225°C (435°F). After you take them out, quickly brush each roll with cold water. Let cool on a rack. Smaklig måltid!

 

0 Comments

Review: Samsung Galaxy S3

Last Thursday I got the Samsung Galaxy S3 I pre-ordered back in the beginning of June, and I have now been playing with it for a few days. There are of course other reviews (mainly of the international version) and overviews of the phone, so I will not list all the features and functions here.
As I am in the US, I received the North American version. It differs from the international version in that it has a dual-core Snapdragon S4 processor and 2GB system memory, instead of the Samsung’s own processor Exynos 4 Quad and 1 GB memory. This is due to the latter processor not supporting the North American LTE networks.

Samsung Galaxy S3 vs. Blackberry Bold 9700With this phone I am also moving from the Blackberry platform to Android. I have been looking forward to getting a nice big screen and a more powerful phone, but at the same time my biggest fear was the on-screen keyboard. The times when I have been using an iPhone or played with older Android phones in the store, I did not feel like I would be able to type as fast as with the Blackberry’s excellent physical keyboard.
Samsung Galaxy S3 LockScreen

I am coming from the Blackberry Bold 9700, with OS 5. The phone is about 2 years old, and originally came with OS 4. After I upgraded, the phone became more and more sluggish, and I constantly ran out of memory, in certain applications as well as when browsing the web. The GPS started taking longer and longer to get a fix, it could take me 2-3 minutes (if it even got the position) if I was indoors. The screen on the blackberry is also tiny compared with today’s phones, even if it was a very good screen when it came out.
So it was about time for me to get something more modern.

I was very pleasantly surprised with the keyboard on the Samsung Galaxy S3. As soon as I started typing, the correct text came out. The predictive text works very well, as long as I use English. I know there are other keyboards (like Swiftkey 3 that Mitch Cohen blogged about last week) where I can set different languages, so that is not a big deal right now.
The 4.8 inch Super AMOLED screen is just gorgeous, and features a resolution of 720×1280 pixels. The internal memory in my phone is 16GB (32GB and 64GB models are also available or coming soon). The memory can be expanded using microSD cards up to 64GB, and in some markets customers get a free 50GB DropBox account. My carrier, AT&T, opted out of this promotion. I already use DropBox, SugarSync, SkyDrive and Google Drive, so after downloading clients for those services, I can now easily transfer my pictures to my cloud storage of choice.

S3_FoldersJust like on the Blackberry, and most other smart phones, the Galaxy S3 has several screens where I can place widgets, icons for applications, and folders containing additional icons. This way it is easy to organize all my apps. On the Blackberry I also used folders, but the lack of available memory caused me to eventually remove most apps.

The default setup came with a number of widgets, but I removed most of them from the screens and opted to just use icons. The lock screen shows the date and time, the current weather, and four icons for applications you want instant access too. To unlock, you swipe your finger over the screen, or swipe any of the four icons to launch that particular application.

I have already modified my phone by adding a custom wall paper, and as I mentioned above, I have organized the icons and widgets the way I want them. To the left you can see a folder open, showing the four applications located in it, in this case IBM Lotus Traveler.

S3_P1

I currently have four screens of icons, of the seven I can have. The first one, the "home screen, is where you end up after unlocking the phone on the lock screen. At the bottom you have five icons of the most frequently used functions, they stay on ever page. The the top of the screen is a notification area, with small icons indication new mail, text messages, twitter messages, etc. It also shows the status for network/wireless connection, battery status, as well as time.

S3_Keyboard

As I mentioned, the keyboard is very impressive, and it exceeded my expectations. I had assumed that I would make a lot of typos, but the predictive text works very well. Or perhaps it is me being too predictable… But the result is that I have very few errors when I type. There are a few small issues, mainly how question marks and similar characters works and that there is no support for Swedish. But as I plan to evaluate a couple of other keyboards, that is not anything that bothers me.

As you can see to the left, when I start typing, suggestions show up above the keyboard. In most cases the suggestion is correct, but in case you want exactly what you typed, the option furthest to the left is what you entered.

You can also see the speech recognition icon to the left of the space bar. I have not used it very much. Speech recognition is of course available everywhere you would use a keyboard, but also on other places, like the S Note application. I have not had time to test the S-Voice yet, nor the face recognition unlocking of the phone or a few of the other advanced functions that is available in this phone.

But I did use the phone to call with. The sound quality is excellent, much better than on my Blackberry. From what I read online, it has active noise cancelling.

I also tested the web browser. As opposed to the Blackberry, it actually load every page I tested.

S3_WebBrowser

The browser is fast (especially on wifi or 4G LTE) and seem to render all pages I tested perfectly. However, I created some bookmarks, and a few hours later they were gone. I am not sure what I did, but now the bookmarks seem to stay. The browser support Flash, of course.

2012-06-24 09.36.53

Talking about speed, I live and work in the Dallas-Ft Worth area, where AT&T have their 4G LTE network available. And it is fast, as you can see to the left.

The one issue I see with the phone is the battery. Despite having a 2100 mAh capacity, it usually lasts only to about 3pm. However, I been using the phon
e extensively, and I may need to tweak some setting. I have no power saving settings turned on, and usually run either wifi or bluetooth. Since I have 4G coverage, that also uses more battery. So one of my first purchases was a portable charger…

So the summary is that this is an amazing phone, and that my worry that the keyboard would annoy me was not an issue. I am very happy with the phone, just wishing the battery lasted a little bit longer.

 

0 Comments

Irony: FunnyJunk lawyer criticizing the same actions as his client engage in

 In a blog entry from 06/23/2010, Charles Carreon (the lawyer who is suing The Oatmeal), posts about the outcome of the case Viacom vs. Google. Youtube, owned by Google, allowed their users to upload copyrighted material, and they then benefited financially from this through the sale of ads on the site. Exactly the same activity that his client FunnyJunk engages in.

As that blog entry in retrospect is somewhat embarrassing for Mr Carreon, he took that down. But since the internet never forgets, Google still got the page cached. Some interesting quotes:

If Google can generate ad revenue by taking in every kind of content without distinction, and make money on the infringing attractions, then Google can “work the float,” and always have enough infringing content to keep its blood pressure up at the expense of copyright holders. The only way that content owners can act proactively is by implementing digital “fingerinting technology” through the “Claim Your Content” system that Google uses as its only screening mechanism. Fingerprinting your content is not, however, cheap.

Please don’t take me for a copyright hawk, but this seems like a ruling that benefits a company that has made a habit of turning other people’s work into their payday, and is being encouraged to keep on doing it.

Here is an image of the page as well, as retrieved from Google this morning:

Blog entry by Charles Carreon - click for higher resolution

Click image for larger/high resolution version. Source: Google cache

Disclaimer: The blog entry is reproduced under “fair use”.

 

 

 

0 Comments

How to make enemies (and a fool of yourself) on the internet

This last week we have seen two high profile examples of how you can screw up and make a total idiot of yourself on the internet. With social networks like twitter and Facebook, news spread quickly, and if it is perceived that there is something unfair going on, expect furious people to share it. When you or I, with perhaps a couple of hundred Facebook friends and twitter followers, post about it, it will still spread, but slowly. But when people like Jamie Oliver (2.5 million followers) or Neil Gaiman (1.7 million followers) tweet about it, things start spreading like wild fire.

 

The first example is The Case of The Thief Suing His Victim. Most of you are probably familiar with the online cartoon The Oatmeal. Matthew Inman, the guy behind all the funny cartoons, complained a year ago that a website called FunnyJunk was full of his drawings. FunnyJunk allow their users to post material (from a quick glance it looks like a large part of the contents is copyrighted material), and then when complaints are sent to them just blame the users, while cashing the checks for all the advertising on the site. Matthew blogged about FunnyJunk doing this about a year ago, and described their business model:

Here’s how FunnyJunk.com’s business operates:
1.Gather funny pictures from around the internet
2.Host them on FunnyJunk.com
3.Slather them in advertising
4.If someone claims copyright infringement, throw your hands up in the air and exclaim "It was our users who uploaded your photos! We had nothing to do with it! We’re innocent!"
5.Cash six figure advertising checks from other artist’s stolen material

 

Last week, Matthew was served with papers, demanding him to pay FunnyJunk $20,000 or be sued. FunnyJunk had hired Charles Carreon as their lawyer, who wrote that letter.
Matthew responded publicly here: http://theoatmeal.com/blog/funnyjunk_letter
I highly suggest reading the whole thing. It is extremely amusing.

BearLove So Matthew sets up a fundraiser. Not to raise money to pay off FunnyJunk, but to split even between the National Wildlife Federation and the American Cancer Society. He raised the $20,000. In 64 minutes! The amount collected by "Operation BearLove Good. Cancer Bad." is currently at $169,000. However, the lawyer, Charles Carreon, is trying to shut down the fund raiser, according to MSNBC. He is also complaining that he was not expecting an outpour of hate and people being upset at him, or having his mom accused trying to seduce a Kodiak bear (the drawing is supposed to be of the mom of the FunnyJunk admin/owner, not the lawyer, by the way). Very strange that someone who market himself as a cyber attorney is so clueless to how the internet works. He should lookup the Streisand effect, as well.

Even other lawyers chime in. The law-blog PopeHat.com uses some strong words:

So, The Oatmeal tried to turn this into something good ?something that would benefit wildlife protection and cancer research ?and Charles Carreon had a snit and tried to shut it down because it was embarrassing to him and his client?

Fuck him. He’s vermin. He’s not forgivable. Let any good he has ever done be wiped out. Let the name "Charles Carreon" be synonymous with petulant, amoral censorious douchebaggery.

 

Another lawyer, who supposedly knows Charles Carreon, is also quoted on the same page:

Despite my earlier charitable comments, I can not find any words to defend trying to shut the fundraiser down. I can’t even gin up a minor benefit of the doubt on that one. I can see an ill-considered demand as a mistake in judgment while hoping to gain an advantage for your client. But taking a shot at the fundraiser would not do that ?it would just be lashing out to hurt bears and cancer patients? Holy fucking shitballs inside a burning biplane careening toward the Statue of Liberty, Captain! I hope that the reporter merely got the story wrong, because if not, that’s more fucked up than a rhino raping a chinchilla while dressed up in unicorns’ undergarments.

 

It will be interesting to see the outcome of this. The twitterverse seems to have the consensus that Charles Carreon just committed career suicide.

 

 

The second example is The Case of NeverSeconds. A nine year old girl, Martha Payne (who blog under the name VEG), started a blog called NeverSeconds, where she posted pictures of her school lunches, as well as described them (contents, taste, etc). This is a great blog!

SchoolLunchPicture by Martha Payne, from this blog entry. 

The blog went viral recently, and children in other countries are sending her pictures of their lunches. Martha is also raising money for Mary´s Meals, a charity trying to feed poor children. UK newspapers started writing stories about the blog and how the schools should serve healthier (and bigger) meals for the kids.

However, on Thursday Martha posted a message titled "Goodbye.":

This morning in maths I got taken out of class by my head teacher and taken to her office. I was told that I could not take any more photos of my school dinners because of a headline in a newspaper today.

I only write my blog not newspapers and I am sad I am no longer allowed to take photos. I will miss sharing and rating my school dinners and I´ll miss seeing the dinners you send me too. I don´t think I will be able to finish raising enough money for a kitchen for Mary´s Meals either.

Goodbye,
VEG

 

The school board decided to stop Martha from taking pictures. Supposedly one of the newspapers who picked up the story about her blog had called for the lunch ladies to be fired. So it was not even something Martha did.

This story was picked up by UK and international news outlets, and celebrities like Jamie Oliver and Neil Gaiman posted on twitter in support of Martha. Her charity went from ,000 to (currently) 7,000strike> 8.000 (and it keeps going up) in a few days! Donate you too.

MarysMeals 

After a media- and twitter frenzy, and after the members of the
school board of Argyll and Bute were contacted by the education secretary of Scotland, the ban was lifted today. The school board first posted this statement, still trying to shift blame to Martha. They then retracted that and posted another statement. I suspect that the first statement is how the council really felt, that government officials should not be allowed to be criticized. They were probably forced by higher-ups and more outrage to withdraw the first statement and replace it with another one.

This is a great example on how NOT to act when criticized. Basically a hug PR fiasco.

 

So there you have it, two great examples of a website/lawyer and a group of politicians who dug themselves a hole, and then kept digging. I have a feeling that that school board will be gone at the next election. And that the FunnyJunk lawsuit will be thrown out of court quickly, if it even get there. By the way, Matthew Inman have retained Venkat Balasubramani to handle the case:

I have discovered that The Oatmeal is represented by none other than Venkat Balasubramani, who will lay a motherfucking smackdown if you make him. While The Oatmeal´s response is funnier, Venkat brings his A-Game here.

 

Let´s bring out the popcorn! But first, go and send some money to the bears/to stop cancer and to feed the children.

Update: Martha is back! Monday she will take a new picture and post. Also, her fund raiser is now up to 2,300″…”

 

0 Comments

Regular Expressions in Notes (Lotusscript)

Today I needed to use regular expressions (a.k.a. regexp) in a Lotus Notes application. I just wanted to check if the user entered a claim number (in the format “nnXXXXXnnnnn”, e.g. 12RICTX12345) in a field. A quick online search found a blog entry with some code using the VBScript object available in Windows, and I adapted it for my application.
Just in case someone need this, I am posting the code below. I am not taking credit for the code, I found it on Giles Hinton´s blog and just adapted it a little bit.

I also found information about using LS2J and Java to handle regular expression in Notes, which should be platform independent, not restricted to just Windows. Since all our users are on Windows (either directly or through Citrix), I could use the quick method below. But I would probably use the script library posted on OpenNTF for more serious code.

 

Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim regex As Variant
Dim pattern As String
Dim result As String
Dim match As Boolean

'*** Define pattern and get text value to check for match
pattern = |b([0-9]{2}[a-zA-Z]{5}[0-9]{5})b|
Set uidoc = ws.CurrentDocument
subject = uidoc.FieldGetText("ShortDescription")
'*** Create RegExp object
Set regex = CreateObject("VBScript.Regexp")
regex.Global = True
regex.IgnoreCase = True
regex.Pattern = pattern
'*** Test for match of pattern in text
match = regex.Test(subject)
If match = True Then
    Msgbox "Claim number was found in the field."
End If
0 Comments

Review: LEGO Lord of The Rings

This weekend I spent with my son building some of the new LEGO kits from the new Lord of The Rings series. Here is a quick review of the kits we have built this far. You can click on the images for high-res versions of them.

 

9469 Gandalf Arrives – 83 pieces

GandalgArrives

A small but nice set. Contains Gandalf in his cart loaded with fireworks, as well as Frodo welcoming him.
Plenty of nice details, like the fireworks, a carrot for the pony and an envelope for Frodo to put the ring in.

 

9472 Attack on Weathertop – 430 pieces

Weathertop_Closed

This is a very nice set. It contains five minifigs: Aragorn, Frodo (with the ring), Merry and two Nazgûl (ringwraiths), as well as two horses. The three first minifigs have a feature I have not seen before, they have two sets of faces. By turning the head and exposing the part hidden by the hair, you get two different facial expression, like stern and aggressive or scared. The Frodo minifig in 9460 got the same feature, but not Gandalf as the back of his head is visible. All the minifigs are extremely detailed, it is obvious that the designers of the kits realized that collectors and adults will buy these kits.

Weathertop1_Details

 

The kit itself is of the ruins on top of Weathertop (Amon Sûl), and it features a trap door and a cooking fire. The ruins can be opened and in the inside you find weapons, toches and much more. Even a rat! There is also a stand-alone pieved of ruin with a bush and some plants.

WeatherTop_Open

The plants are the only thing I did not like with the kit. For some reason, perhaps the kind of softer plastic used, they don’t stick well to the bricks they are placed on. But that is a minor detail, otherwise this is a great kit.

 

9473 The Mines of Moria – 776 pieces

Moria2_Finished

This is a big set, the second largest in the series, and it depicts the events in the Chamber of Mazarbul. It contains six minifigs (Gimli, Legolas, Boromir, Pippin and two Moria orcs), as well as the cave troll. There are four separate sections, a large wall section, the doors to the chamber, the well with the skeleton and the chain and bucket, as well as Balins tomb, containing the skeleton of Balin. By pulling a lever, the skeleton, bucket and chain will fall down in the well, just like in the book and movie.

There are plenty of details, from old weapons to gems and even the Book of Mazarbul.

BalinsTomb_Details

 

9476 The Orc Forge – 363 pieces

OrcForge

This is currently my son’s favorite kit. It features a light brick, so when a rod is pushed, it looks like fire under the melting pot. In addition, there are four minifigs: Lurtz, two Mordor orcs and one Uruk-hai. To be really picky, Lurtz was created by Sauron, just like the Uruk-hai, so there should not have been any Morder orcs, but Isengard orcs. There is two sets of Uruk-hai armor (complete with the white hand of Sauroman), a crane to lift material to melt for the forge, etc.

OrcForge_Details1

OrcForge_Details2

 

 

So what is the verdict? As a Lord of the Rings fan (both the books and the movies by Peter Jackson), I am very happy with the LEGO kits this far. The quality is good, the instructions are very clear (recently I have seen some instructions where it was easy to miss a piece of pick the wrong shade of gray) and the detailing is amazing.
I still have two more kits to build that I already purchased, and I have to get the last kit (Battle of Helms Deep). I will report on them later.

 

0 Comments

35 years ago in a galaxy far, far away…

May 25, 1977. Imagine it has been 35 years”…”

When the first movie (then called just "Star Wars", later renamed "Episode IV ?A New Hope") was released in Sweden, the age restriction was set to 11 years. With a parent you were allowed to see it even if you were younger. I was 8 years old, but my parents did not want to go see it.
It was not until "Episode VI ?The Return of The Jedi" was released in 1983 that I actually got to see the two first movies. They were shown back-to-back with a short break in-between, and a few days later the last movie premiered.

I had of course read the book that was released around the time the original Star Wars came out, so I was familiar with the story even before watching the movie. As a young boy, I really enjoyed the movies, and I still do. I recently watched "Episode I ?The Phantom Menace" in 3D.
I am however slightly irritated at George Lucas and how he keep changing the movies”…”

StarWarsMoviePoster1977

 

From Wikipedia:

Star Wars debuted on Wednesday, May 25, 1977, in 32 theaters, and eight more on Thursday and Friday. It immediately broke box-office records, effectively becoming one of the first blockbuster films, and Fox accelerated plans to broaden its release.
 
Star Wars remains one of the most financially successful films of all time. The film earned $1,554,475 through its opening weekend, eventually earning over $220 million during its initial theatrical run. Star Wars entered international release towards the end of the year, earning $410 million in total. Reissues in 1978, 1979, 1981 and 1982 brought its cumulative gross in Canada and the U.S. to $323 million, and extended its global earnings to $530 million.
 
Following the release of the Special Edition in 1997, Star Wars briefly reclaimed the North American record before losing it again the following year to Titanic. In total, the film has earned $775,398,007 worldwide (including $460,998,007 in North America alone). Adjusted for inflation, it has earned $2.5 billion worldwide at 2011 prices, making it the most successful franchise film of all-time; at the North American box-office it ranks second behind Gone with the Wind on the inflation-adjusted list.

 

0 Comments

Lotusscript Code – HTML retrieval class

I saw a question in the DeveloperWorks forum about retrieving a web page (in this particular case in order to get some data out of it), and realized that I never posted my HTML retrieval class…

So without further ado, here it is. It should be fairly self-documenting… Create a new object, then call the GetHTTP method with a URL to get a string representing the HTML code of that URL.  This is Windows only, by the way.

Class RemoteHTML
  Private httpObject As Variant
  Public httpStatus As Integer
 
  Public Sub New()
    Set httpObject = CreateObject("MSXML2.ServerXMLHTTP")
  End Sub

  Public Function GetHTTP(httpURL As String) As String
    Dim retries As Integer
    retries = 0 
    Do
      If retries>1 Then
        Sleep 1   ' After the two first calls, introduce a 1 second delay betwen each call
      End If
      retries = retries + 1
      Call httpObject.open("GET", httpURL, False)
      Call httpObject.send()
      httpStatus = httpObject.Status
      If retries >= 10 Then
        httpStatus = 0     ' Timeout
      End If
    Loop Until httpStatus = 200 Or httpStatus > 500 Or httpStatus = 404 Or httpStatus = 0
    If httpStatus = 200 Then
      GetHTTP = Left$(httpObject.responseText,16000)
    Else
      GetHTTP = ""
    End If
  End Function

End Class
0 Comments

End of content

No more pages to load