All Things Techie With Huge, Unstructured, Intuitive Leaps

Killing Application With Escape Key in .NET C#


So, you are a C# weenie and you want to kill your Forms Application by hitting the escape key.  It's as easy as pie.

In the forms load method, put in the following two lines:

this.KeyPreview = true;
this.KeyDown += new KeyEventHandler(Form1_KeyDown);

Then create the KeyDown method:

private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
             if (e.KeyCode == Keys.Escape)
             {
                 Application.Exit();
             }
        } 

Hope this helps.

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.

    epodcastnetwork.com SPAM !!!


    Legal Definition of Spam

    As a public service announcement and for the edification of dumbass spammers, I provide the following definition of Spam.  Public Law No. 108-187, 15 U.S.C. 7701, et seq., defines spam as a "commercial electronic mail message" as "any electronic mail message the primary purpose of which is the commercial advertisement or promotion of a commercial product or service (including content on an Internet website operated for a commercial purpose)."  The primary characteristics of Spam are:

    1) Lack of visible and operable unsubscribe mechanism in all emails.
    2) Lack of a legitimate physical address of the publisher and/or advertiser.
    3) Message sent to a harvested email address.

    I have zero tolerance for spammers who fit the above-mentioned legal criteria.  

    Here is the latest spam fitting the above criteria in my mailbox by dumbass spammers:

    (start clip)

    I have been physically threatened by a spammer because of  my posting of his illegal spam.  My attorney suggests that I save the screen shots, and remove the content as it will be evidence.  A criminal felony complaint is being filed with the appropriate police departments against the perpetrators of the illegal spam for the resultant felonious threats to me for exposing their spamming business practices. 
    (end clip)

    Now the ironic thing is that they have a fancy domain account and yet they want me to send money to a gmail account.  Yeah, right!

    Google is killing off Adsense?

    Holy Cow!  Google is killing Adsense.

    I just got this email today:


    Hello,

    We’re writing to let you know about some important changes that will be happening to AdSense on Google Sites. Starting on August 30th, it will no longer be possible to make updates to AdSense on your Google Site.

    Any ads that you currently have running will not be altered or removed. However, it will no longer be possible to edit or add new ads to your existing site or new pages.

    This change does not require any action on your part and will not affect the current implementation of ads on your site.

    To read more details about this change, please visit the help page.

    Yours sincerely,

    The Google Sites Team

    © 2013 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
    You have received this mandatory email service announcement to update you about important changes to AdSense on your Google Sites account.

    So I went to the Adsense website and I got this terse notice:

    Sunsetting AdSense

    Some important changes are coming to AdSense on Google Sites. By August 30, 2013, it will no longer be possible to make updates to AdSense on any of your Google Sites.

    No change is required on the part of AdSense users. Any ads that you currently have running will not be altered or removed, though you’ll be free to delete ads yourself. However, it will no longer be possible to edit or add new AdSense ads to your existing site or to new pages.

    There is no other explanation.  There is no indication of what if anything will replace it.  Inquiring minds want to know!


    Traffic Faking Update


    This is an update on traffic faking.  If you have a blog or a website, you will see an inordinate amount of hits from weird and not-so-weird domains.  They are faking traffic to your website.  When you click out of curiosity, you are bombarded by spam, or even worse, malware.

    I created a La Brea Tarpit blog -- a blog with lots of keywords.  It has had no hits at all from legitimate users, but in four days, it had the following hits from the traffic faking domains:

    http://www.vampirestat.com 30 hits
    http://www.vampirestat.com/ 22 hits
    http://thetaoofbadass.pw 18 hits
    http://blogsrating.pw/ 11 hits
    http://awsurveys.com 10 hits
    http://www.adsensewatchdog.com 4 hits
    http://google.adsensewatchdog.com 2 hits
    http://blogger-custom-domain.blogspot.com/ 1 hit
    http://kmzackblogger.blogspot.com 1 hit

    I contacted that .pw registrar and they weren't interested in stopping their traffic faking domains, so my guess is that they are scumbag traffic faker enablers as well.

    The internet is very Darwinian.  Traffic faking must work to generate hits, otherwise they wouldn't do it.  If you are a webmaster or blog owner and you see one of these domains, don't click on it.  Let's starve them out of web traffic.

    Apple Was Hacked -- This is what they sent me.

    Apple Developer

    Apple Developer Website Update
    headershadow

    Last Thursday, an intruder attempted to secure personal information of our registered developers from our developer website. Sensitive personal information was encrypted and cannot be accessed, however, we have not been able to rule out the possibility that some developers’ names, mailing addresses, and/or email addresses may have been accessed. In the spirit of transparency, we want to inform you of the issue. We took the site down immediately  and have been working around the clock since then.

    In order to prevent a security threat like this from happening again, we’re completely overhauling our developer systems, updating our server software, and rebuilding our entire database. We apologize for the significant inconvenience that our downtime has caused you and we expect to have the developer website up again soon.