Sep
26
2014

IsPrime Function in JavaScript

The following code sample illustrates how to use JavaScript to determine if a number provided is a prime number or not. In this example, the number is hardcoded in the JavaScript. You can edit this and experiment with other values at the isPrime at CodePen

var theNumber = 22;
var primeResult = isPrime(theNumber);
document.write("<hr />" + primeResult);

function isPrime(n) {

  var s = [2,3,5,7];
  var ld = [1,3,7,9]; 
  var divs = [];

  if (n==1) {return false;}
  if (s.indexOf(n) > -1) {return true;}
  
  if (ld.indexOf(n%10) > -1) {
     divs = getDivisibles(n);
     document.writeln(divs);
  } else {
    return false;
  }
  
  return (divs.length == 0);
  
}// isPrime

function getDivisibles(n) {
  var i = 2;
  var divs = [];
  while (i*i<=n) {
      if (n%i==0) {
        var upper = n/i;
        divs.push(i);
        if (upper>i) {divs.push(upper);}
      }
      i++;
  }// while
  divs.sort(function(x,y){return x-y;});
  return divs;
}// getDivisibles

See the Pen isPrime by J Michael Palermo IV (@palermo4) on CodePen.

    Copyright © Microsoft Corporation. All rights reserved.
    The code provided in this post is licensed under the Microsoft Public License (Ms-PL).
Sep
26
2014

Demo jQuery Selectors

The demo below shows how to find a count of elements using different jQuery selectors. To modify the expressions yourself, feel free to make edits at the jQuery selectors demo at CodePen


$(document).ready(function () {
  // start the results of methods below with this:
  writeLine("Selectors<hr />");

  // count of all elements
  writeSelectorLength("*");

  // count of elements in body
  writeSelectorLength("body *");

  // count of all divs and p tags
  writeSelectorLength("div,p");

  // count of all p tags direct children of divs
  writeSelectorLength("div > p"); 

  // count of all li tags
  writeSelectorLength("li"); 
});

// helper method to write content at specific location in page
function writeLine(anyHtml) {    
    var output = $("#output");
    var currentOutputContent = output.html();
    output.html(currentOutputContent += anyHtml + "<br />");
}
// helper method to write results of getSelectorLength
function writeSelectorLength(anySelector) {
    writeLine(getSelectorLength(anySelector));
}
// helper methos wrapping results of query in a span
function getSelectorLength(anySelector) {
    return anySelector + 
        "<span class='smaller'> has </span>" + 
        $(anySelector).length + 
        " <span class='smaller'>matches</span>";
}

See the Pen MVA140826-jQuery by J Michael Palermo IV (@palermo4) on CodePen.

    Copyright © Microsoft Corporation. All rights reserved.
    The code provided in this post is licensed under the Microsoft Public License (Ms-PL).
    Copyright © Microsoft Corporation. All rights reserved.
    The code provided in this post is licensed under the Microsoft Public License (Ms-PL).
    Copyright © Microsoft Corporation. All rights reserved.
    The code provided in this post is licensed under the Microsoft Public License (Ms-PL).
Jul
28
2014

GameMaker Tips: Resources

A significant aspect to making games with GameMaker is the management of graphics, sounds, and other game related resources.  Inside GameMaker, resources are managed in the Resource Tree, which provides a file-explorer type view to all the gaming assets.

gamemaker resource tree  

The Resources menu option also provides a quick way to add resources to a game project.  Each respective resource menu-item has a corresponding keyboard shortcut.

gamemaker resources and keyboard shortcuts

    Copyright © Microsoft Corporation. All rights reserved.
    The code provided in this post is licensed under the Microsoft Public License (Ms-PL).
Apr
15
2014

Reno Hackathon 2014

Congratulations to the winners announced at the Reno Hackathon!

Many of the participants used GameMaker by YoYo Games to create an app.  A testimony to GameMaker Studio is that most who were using it were doing so for the first time – and of that group, some had no development background whatsoever! This was highlighted in the news coverage by KRNV Channel 4 as seen here:

image

Although the participants took the Hackathon seriously, the event was full of energy, prizes, and great networking.  There was a variety among the attendees – students, entrepreneurs, moonlighters, and newbies.  For a glimpse of what the journey was like, check out the news coverage by KTVN Channel 2:

image

The Reno Gazette-Journal also noted the activity corresponding with the Hackathon involving tech for NASA.

The Microsoft licensing team in Reno demonstrated their logistical prowess which resulted in everything running smoothly.  Special thanks to Bruno Terkaly and tech-celebrity Sarah Austin (with PlexiNLP) for contributing their technical mentorship to all!

image

    Copyright © Microsoft Corporation. All rights reserved.
    The code provided in this post is licensed under the Microsoft Public License (Ms-PL).
Oct
11
2013

Surface RT Review

Surface RT - Why Loved

    Copyright © Microsoft Corporation. All rights reserved.
    The code provided in this post is licensed under the Microsoft Public License (Ms-PL).
Sep
25
2013

Palermos on NBC Today Show

Please enjoy my 2 seconds of national fame as I stand in the background with my daughter asking Matt Lauer "What up?"

    Copyright © Microsoft Corporation. All rights reserved.
    The code provided in this post is licensed under the Microsoft Public License (Ms-PL).
Sep
23
2013

Power Window Repair

I recently rolled down the driver-side window of my truck… and it would not come back up.  After trying repeatedly to get it to work again (failing each time), I started thinking “What is the bill going to be for this nuisance?”

I asked some of my friends in the Phoenix area if they ever had this type of problem with the power window no longer working.  Those who replied also shared the sticker shock of the repair price – anywhere from $300 to $700.

Determined not to spend that much, I binged ‘power window repair’ and started researching.  I was intrigued by the following:

SNAGHTML14e550ae

Only $99 for the repair?  Seemed too good to be true.  I looked up the Power Window Repair on Yelp and read the reviews. Because the reviews were great and recent, I called the company.  I got a voicemail and left my contact information.  Within a couple hours I got a call back from a nice lady who asked me details about my situation.  She quoted me a price on the phone ($129 all taxes included) to repair my window.  We made an appointment for the next day.  The repair would be done at my location.

Paul arrived on time and had my window fixed in under 30 minutes!  With no surprises with the repair bill, I gladly paid the $129!

What is the point of this story?  It demonstrated a true “win-win” for all parties.  From an internet perspective, it reminded me of these things:

  • Research a repair on the internet, even if your friends have a connection for you.  Why not compare and validate?
  • When researching a company, strive to get a 3rd party opinion. When reading reviews, be cognizant of the dates.  Recent reviews weight higher than older reviews.
  • If you offer a service, how would you fare with the above?  Would potential customers find you?  What do your reviews look like?

In closing, I want to thank Power Window Repair for such great service!  If you live in the greater Phoenix area and ever have a problem with your power window, this is the company to contact!

    Copyright © Microsoft Corporation. All rights reserved.
    The code provided in this post is licensed under the Microsoft Public License (Ms-PL).
Sep
19
2013

Windows Store Apps with HTML5–Refresh

imageA full day of content has now extended the very popular “HTML5 for Windows 8 courses” available at the Microsoft Virtual Academy.  This new course builds on everything you’ve already learned about developing apps in these HTML5 courses: Developing Windows Store Apps with HTML5 Jump Start and Advanced Windows Store App Development Using HTML5 and JavaScript Jump Start. This fast-paced refresh course filled with real-world scenarios shows you how you can make your apps richer and more integrated, using the new features available in Windows 8.1. This course is targeted at anyone making apps or aspiring to make apps for the Windows 8 platform using HTML and JavaScript. It will help you prepare for Microsoft exams 70-481 and 70-482.

[View course at Microsoft Virtual Academy]

    Copyright © Microsoft Corporation. All rights reserved.
    The code provided in this post is licensed under the Microsoft Public License (Ms-PL).

Resources

Archives

Team Blogs

Download OPML file OPML