All Things Techie With Huge, Unstructured, Intuitive Leaps

Download jfaces jar


So, I write some code in Java SWT and I need a dialog.  The quickest one is a jfaces implementation.  I pop the code in, and Eclipse can't find the import.  It doesn't have the class, and it can't auto import.  What to do? Obviously I am missing a jar.  I google "download jfaces jar".  Nada.  No separate download.

I find it in the plugins directory of my Eclipse plug-ins folder in my Programs folder.  Quel surprise!  There is no independent download of the jfaces jar.  It is bundled with the latest Eclipse download.  My version of the "found" jfaces jar was org.eclipse.jface_3.8.101-v20120817-083647.jar.

Hope this helps someone.

Exception in thread "Thread-0" org.eclipse.swt.SWTException: Invalid thread access



So you are getting your feet wet with Java SWT and you are having trouble updating your UI while you are doing some heavy processing.  Perhaps you have an intensive task like monitoring a stock quote and then updating the UI.  Either it plain doesn't work, or you keep getting the error:  Exception in thread "Thread-0" org.eclipse.swt.SWTException: Invalid thread access

Googling sometimes is not very helpful with this.

Obviously the way to work it, is to not put the intensive task in the main thread of the program.  That way you will never get an interrupt vector to update the UI.  So how do you do it?  I put the heavy duty processing task in a button, and kick a separate, non-UI thread to do the work.  Then at the point that you need to update the UI, kick a UI thread to do the update.  Here is a code snippet:

Button button1 = new Button(shell, SWT.PUSH);
button1.setBounds(220, third, 200, 50);
button1.setText("Do Work");
button1.addSelectionListener(new SelectionAdapter() {
 @Override
public void widgetSelected(SelectionEvent e) {
// Kick a thread that has nothing to do with the display
     Runnable runnable = new Runnable() {
         public void run() {
           for (int i = 0; i < 10; i++) {
             try {
               Thread.sleep(500);
             } catch (InterruptedException e) {
              
               e.printStackTrace();
             }

                      // this will print to the console, because the UI display thread is not involved
             System.out.println(i);

                      //Now get the UI thread to update the label 
                      display.asyncExec (new Runnable () {
                    public void run () {
                lblResultslabel.setText(i.toString());
               }
            });
           }
         }
       };
       new Thread(runnable).start();
  
 
}
});

Hope this helps someone.

Apple Developer Site Down

I got this from Apple this morning.

Scheduled Downtime on August 17



Dear Developer,

We want to let you know that the site will be undergoing a brief scheduled maintenance on Saturday, August 17th at 6pm PDT. During this time the developer website and developer program services will be offline.

Best regards,

Apple Developer Program Support

Old Technology


I am the CTO of a technology company.  Recently we got a piece of 90 year old technology that now sits at the entrance of our offices.  (Our offices are located in an old Victorian Post Office with neo-classical pillars and a stone facade).

This is a punch clock made by the IBM Corporation in the 1920'  There are 150 holes in the circle.  Each hole is an employee number.  As an employee, you come in, spin the bar to your employee number and press the lever.  A bell dings.  Inside, a drum wheel with a 4 day capacity piece of paper on it, gets punched with your in and out time.

It is an amazing complex piece of machinery with castings, an oak cabinet, and quite a complex series of gears and such inside.  I googled antique forums, and the thing goes for about $2,000 on the open market.

We actually use an online timesheet to record employee hours.  This is just a conversation piece in our office.

Invoke or BeginInvoke cannot be called on a control until the window handle has been created





I had a C# program where I kicked a new thread to check for messages in the database.  I used a delegate in the new thread to call a method in the class that went to the database message table and checked for new messages higher than the message primary key id that it knew about.

It kept throwing this error:

Invoke or BeginInvoke cannot be called on a control until the window handle has been created


As it turns out, I had a couple of variables that were declared but not initialized or set and instead of throwing a null exception, because they were called using a delegate by a different thread, it threw the above error instead.

The fix was to initialize and set the variables.

Hope this helps someone.

Google's Soft Censorship of Images

(click on picture for larger image)

This morning, I saw something completely new from Google -- soft censorship on their image search.  I read on CNN, the story of Derek Medina, or how he killed his wife, and posted the picture of her body on Facebook, before turning himself in to police.  The article said that the picture went viral.

To see how viral, I did an image search.  I was amazed that Google initiated soft censorship on the images.  The censored images just had a gray icon.  When you clicked on them, you could see the preview of the image, but I was amazed that they would do this.

In retrospect, it makes a lot of sense for the sake of propriety, because you still can see the image if you take the trouble to click on it and open a preview layer, but it was still surprising.  It reminded me of the magazine racks in the convenience stores that have cardboard over the covers of the girlie magazines.

The jury is out as to whether I like this or not.

The Best Anagram Solver on the Web


I wanted to find the anagrams of a friend's name.  (Just in case you didn't know, an anagram is re-arranging a name or a phrase to form another one, using all of the letters without repeats or deletions.)

So I googled "Anagram Solver" and up came the top four results:


  • www.ssynth.co.uk/~gay/anagram.html‎
  • www.solverscrabble.com/‎
  • www.wordsmith.org/anagram/‎
  • anagram-solver.net/‎
So I tried all of them.  The first one gave me a whole bunch words that nobody recognizes or uses on a daily basis.

I then went to the second one.  It only takes a limited amount of letters.

I then skipped one and tried the last one, anagram-solver.net.  The name looked promising. It wasn't.

The clear winner was:

  • www.wordsmith.org/anagram/‎
I hope that this helps someone.  I realize that creating and solving anagrams is about as useful as having your high school class Greek textbook handy on the coffee table for those everyday emergency translations, but what the hey.

Copying Forms Error in Visual Studio .Net and C#


A colleague phones me up and asks me about a Visual Studio C# project that I had written a couple of years ago.

He tried simply copying a form and he kept getting the error:

The item "obj\Release\<filename>.resources" was specified more
than once in the "Resources" parameter.  
Duplicate items are not supported by the "Resources" parameter.

Hmm.  I went to stacktrace (the website) and they said that the easiest way was to go into Explorer, duplicate the files and add them to the project.  It didn't work because the .resx file was not under the .cs file structure.

It turns out that the re-factoring isn't complete.  If you just plain old copy the form in the Solutions Explorer, rename it, and then immediately go and fix all of the references to the old name in the .cs file (rename the class, the constructor and all references to the old name) and then do the same thing in the .resx file, everything eventually works.

It eliminates the above problem.

Hope this helps someone.

Amazon Monetizing Mobile Apps with API

The folks at Amazon sent me this:




Amazon

Amazon Mobile Ads

Dear Mobile App Developer,

Today we announced the general availability of the Amazon Mobile Ads API which gives you the ability to earn great eCPM by monetizing your app with mobile ads from the Amazon Mobile Ad Network.

Our eCPM has increased 30% since the beta launch in March, and early adopters such as Games2Win are discovering that the Amazon Mobile Ads API is a great monetization solution. "The $2.00 eCPM we saw from Amazon far exceeded our expectation. We tested Amazon in our Kindle app first. Now we're racing to get the Amazon ads integrated in all of our apps across all Android stores," said Mahesh Khambadkone from Games2Win.

Starting today, the Amazon Mobile Ads API will be included as part of our Amazon Mobile App SDK. Apps that use the Amazon Mobile Ads API may be distributed on any Android platform as long as they are available for download through the Amazon App Distribution Program.

Earn a Kindle Fire HD by integrating the Amazon Mobile API in your app in the next few weeks. Here's how:

1. Integrate the Amazon Mobile Ads API into your app. Get started here.
2. Submit your app to the Amazon Mobile App Distribution Portal between July 25th and September 1st. Get started here.
3. Send at least 500 ad requests to the Amazon Mobile Ad Network every week between September 15th and October 19th (see terms and conditions below).


Best regards,
Amazon Mobile App Distribution Team


Terms and Conditions of Kindle Fire HD Offer:

  • To qualify for a free Kindle Fire HD, 7" display, 16 GB, with special offers, app developers must meet all of the terms and conditions of this offer.
  • This offer begins at 12:01 a.m. (PT) September 15th, 2013 and ends at 11:59 p.m. (PT) October 19th, 2013 (the "Offer Period").
  • A "Qualifying App" is any mobile app that is submitted to the Amazon Mobile App Distribution Portal between and including July 25th and September 1st, 2013. Apps that have sent ad requests to Amazon using the Amazon Mobile Ads API prior to July 25, 2013 are not Qualifying Apps.
  • A developer's Qualifying Apps must send at least 500 ad requests every week during the Offer Period. (Each week begins at 12:01 a.m. Sunday and ends at 11:59 p.m. Saturday.) This offer is only open to developers who send the required number of ad requests for the entire Offer Period.
  • A developer may use a single Qualifying App or multiple Qualifying Apps to generate the 500 weekly ad requests as long as the Qualifying Apps are registered to a single developer account.
  • Limit one free Kindle Fire HD device per developer.
  • Offer good while supplies last.
  • Qualifying Apps must meet the Mobile Ad Network Program Participation Requirements.
  • Developers must agree and adhere to the Program Materials License Agreementand the Mobile Ad Network Publisher Agreement to qualify for this offer.
  • Qualifying developers must be reachable through the email addresses registered on the Distribution Portal.
  • Amazon will attempt to ship the Kindle Fire HD device to qualifying developers in the U.S. and other countries. However, Amazon is not responsible for customs or taxes required for international deliveries.
  • A "Qualifying App" is any mobile app that has integrated the Amazon Mobile Ads API and is submitted to the Amazon Mobile App Distribution Portal between and including July 25th and September 1st, 2013. Apps that have sent ad requests to Amazon using the Amazon Mobile Ads API prior to July 25, 2013 are not Qualifying Apps.
  • Amazon reserves the right to modify or cancel this offer at any time in its discretion.
  • This offer is void where prohibited.
  • Excel Spreadsheet ~ SUM formula doesn't work


    OK so I had an Excel Spreadsheet.  I had a column that needed to be added up and the total displayed with the Formula SUM function.  I created the formula, and although I had a number there, when I changed the numbers that the sum was composed of, the result never changed.

    I tried a whole pile of things.  I tried deleting the formula and recreating it.  I tried copying the column.  I tried copying the sum formula from other cells.  It was a real head-scratcher and hail-puller-outer.

    So how did I solve it?  I selected the column, and then the cell properties and I assigned a Number Format to the cells.  Worked like a charm. The SUM formula now worked. It only took me a few weeks to figure this one out.  Damn Microsoft.