How to Open the iPhone Simulator Without Opening Xcode

iPhone SimulatorThis is a useful tip if you have to do any type of mobile web testing for iOS Safari and you either don’t have an iPhone/iPod Touch or you don’t feel like plugging it in and setting things up.  As long as you have Xcode installed, you can simply open a terminal and run the following command:

MACBOOK:~ user$ open -a iPhone\ Simulator

This should launch the last simulator you had running.  If you need to run a different version of iOS or switch to a different device profile, you can do that once the simulator has started.  Hopefully this works for you – you can even create a shortcut and put it on your desktop or in the dock if you find yourself running this command often.

How to Calculate the Angle Between Two Points in Javascript

JavascriptSo it’s been a while since I’ve posted, so I thought I would post something that was both useful and nostalgic.  I haven’t had a need to do any form of trig since college, maybe even high school.  But for the hackathon last week, I was building an in-browser version of Missile Command that let you blow up the contents of the page.  To do this, I needed to animate missiles being fired and I need to know what the angle between the base and the target to rotate the missile sprite to look correctly.  So my first search yielded the following code snippet:

var angle = Math.atan2(y2 - y1, x2 - x1);

This seemed pretty simple and straightforward and to get the x2 and y2 values, I used the clientX and clientY values from the mouse click event and I used getBoundingClientRect() to get the top and left properties of the base which was a div element positioned at the bottom of the page.  So the final code to calculate the angle looked like this:

// e - mouse event
// base - div element
var baseRect = base.getBoundingCLientRect(),
    y2 = e.clientY,
    x2 = e.clientX,
    y1 = baseRect.top,
    x1 = baseRect.left + (baseRect.width/2),
    angle = Math.atan2(y2 - y1, x2 - x1);

So this made perfect sense and I was feeling pretty good (except for the flashbacks to high school and sitting in those uncomfortable chairs hoping the teacher wouldn’t notice I didn’t do my homework).  I then use the CSS Transform property to rotate my missile sprite like this:

transform:rotate(angle);
-ms-transform:rotate(angle); /* IE 9 */
-webkit-transform:rotate(angle); /* Opera, Chrome, and Safari */

And of course this is going to work on my first try, right? If you’ve read any of my other blog posts, you should know by now that nothing I do ever works on the first try.  So I click in the upper-right quadrant of the page and the missile rotates to point straight up.  At first, I think it’s because my sprite is actually pointing up and I need to offset the rotation.  Then I think there’s something wrong with how I was calculating the x and y coordinates.  So I debug all the values and they look okay.  Then I look at the calculated angle value and notice that it’s not even close to what it should be.  What could I have done wrong… that’s when I went back to the original equation and realized that angle was returned in radian and not degrees.  Well, first I had to remember what radians were and then I had to figure out how to convert it into degrees which turned out to be pretty simple:

var angleDegrees = angleRads * (180/Math.PI);

And then we go, now we have an angle in degrees that works.  Like I said at the beginning, this was a useful exercise in using something I learned in school and something that felt somewhat nostalgic.  Since I want to do more game development, I have a feeling this is only the beginning of my adventures of trying to remember trig basics.  Wish me luck…

Google’s 2GB RAM upgrade for new Glass explorers angers early adopters

Google GlassGoogle will soon ship an upgraded version of Google Glass with 2GB of RAM, angering early members of its Glass Explorer Program stuck with the older model.Google Glass currently comes with 1GB of RAM, but to improve performance Google will begin shipping a new version with 2GB of RAM, it said in a post to Google Plus.

The announcement angered some existing Glass owners. Some demanded a free upgrade to the 2GB version in comments on the posting. Others said they would be willing to pay a small fee for an upgrade, while one acknowledged that if further hardware updates were planned, it wouldn’t make sense for Google to upgrade all users each time. “Getting a final consumer version would be swell though,” he added.

Google does not plan to upgrade existing users’ devices, it said.

“Throughout our open beta program, you can expect to see us make changes here and there. We won’t be swapping devices, but you’ll continue to see improvements with our software updates,” a Google representative said in a comment on the posting.

The company does replace broken or defective Google Glass devices, however, prompting Google Plus user Jake Weisz to identify a loophole in the no-upgrades policy. “If defective Glass units get free upgrades to 2GB, you will see a lot of ‘defective’ models this month,” he wrote.

In May, Google broadened its Explorer Program, making Glass available in the U.S. to anyone over 18 years old for US$1,500. Before that, users who wanted to buy Glass required an invitation from Google. On Monday it extended the offer to U.K. residents over 18, who can purchase Glass for £1,000 (roughly US$1,700).

Google is upgrading the Glass software as well as the hardware. It is adding an easier way to frame shots for photos, with the addition of L-shaped corners bracketing the image in the viewfinder screen, and adding two new Google Now cards, one to remind users where they parked their car and another to let them know when packages are arriving.

The company also announced 12 new Glassware apps from partners, including Shazam, a music recognition app that can be triggered with the words “OK Glass, recognize this song,” and 94Fifty Basketball, a training aid that works with a sensor-equipped basketball to offer feedback after each shot.

Google’s announcements arrived just before the start of its annual I/O developers conference in San Francisco, which kicks off Wednesday. The company will lead sessions on how to build new types of software for Glass during the conference.

Google is also expected to unveil a small TV set-top box resembling the Apple TV and Amazon’s Fire TV at the event, the Wall Street Journal reported on Wednesday. Citing two people who have seen the device, the newspaper said the device will not be sold under the Google brand but will be powered by the Android TV software that Google developed to play games, movies and other content on TVs. Users will be able to control the box with their Android phones and tablets and maybe with other devices, the report said.

PCWorld

 

Nest opens its developer program to let apps and services tap into its smart home appliances

Google NestI like to see more household devices have APIs exposed that allow developers to build on top of existing functionality.  Of course, this could also be potentially dangerous if you’re able to change the thermostat and bad code sets your thermostat to 110 degrees.  Probably unlikely, but a possibility – or maybe hackers will be able to access your thermostat one day.  I would also be curious if you have access to the Nest’s motion detector and it basically becomes a secondary security system that can detect when someone is in your house when they’re not supposed to be.  We’re seeing more and more connected devices in homes that will eventually create a pretty powerful and detailed network/sensor array.  In any case, I think I’ll take a look at the Nest API and see what you can do with it.

-=-=-=-=-=-

Nest, the company bought by Google for $3.2 billion, has opened its developer program to allow other apps and services to tap into its smart smoke alarms, thermostats and other home tech products it launches in the future.

“What we’re doing is making it possible for your Nest devices to securely interact with the things you already use every day. Things like lights, appliances, fitness bands and even cars. Because when we make connections between these different parts of your life, we can create personalized experiences that do even more to keep you comfortable and safe,” the company writes on its blog.

Initial ‘Works with Nest’ integration partners include Mercedes-Benz, whose cars tell Nest products to activate when they are near home; LIFX bulbs, which sync with Nest products to flash during an emergency; and Jawbone, which links its UP24 band to Nest appliances.

The Wall Street Journal reports that “some” Google apps will connect with Nest, but users will maintain full control over what information, if any, is shared.

TNW

Google Glass now available in UK

Google Glass

Google announced that the controversial, pricey and still rather infant technology Glass is now available to the brits for £1,000 and if you’re over 18 (but seriously, if minors can get alcohol and drugs, I can’t imagine a kid with £1,000 sitting in their pocket not able to convince an adult to buy this for them).  This is interesting news mainly because while there is a consistent flow of articles and editorials on how Glass invades your privacy, restaurants/bars/movie theaters are banning it, it’s become a badge of the tech elite, blah blah blah – there’s still a lot of people who want to get their hands on it.  There’s the early adopters who love trying something new, there’s people who want to stand-out (good or bad) and then there’s people who see actual use of Glass in everyday life and possibly in their professional life like cops and surgeons are already doing.  I don’t think Google would be doing this if no one wanted Glass (which is what all the articles suggest) but I also don’t think Glass is going to become as mainstream as the iPhone either.  But just like segways, mini disc players, the nintendo power glove and other technologies that were ahead of their time, Glass may just be a chapter in the history of tech… or maybe not… who knows…

How to roll back/undo a GIT commit

GITSo I have done this more times than I care to admit… immediately after doing a commit (but before pushing) I’m like “shoot, I didn’t meant to do that” or “crap, I was supposed to commit that file” or something similar.  And then I find myself searching Google for how to undo a commit because while I do it often, it’s just infrequent enough that I usually forget how I did it last time.  So while I’m hoping this helps someone, I’m actually hoping that by writing a blog post I’ll commit (haha, get it) this to memory.  So first I’ll give credit to Stack Overflow where I found the command I typically use which is:

git reset --soft HEAD~1

This will undo the last commit you made.  And the nice thing is you can also change the “~1″ to undo multiple commits if you made multiple mistakes.  And if the above is too hard to remember, I did hear about a simple script you can install called gitjk that is pretty useful and easy to remember.  I haven’t used gitjk myself, but looking through the readme, it looks straightforward.  So hopefully this has helped if you stumbled on this page after doing an accidental commit and you’re trying to figure out what to do.

Can’t Login to Synology DSM – “System is getting ready. Please log in later.”

Synology DS212So I’m hoping this will help someone who encounters the same problem I did when I tried to login to my Synology DS212 tonight.  At first, I thought it was simply waking up from being asleep,but I kept checking every couple minutes and after like 15 minutes, when I kept getting:

System is getting ready. Please log in later.

I knew something was wrong.  So I did some searching on Google and of course, I wasn’t the only one having problems.  On Synology’s forum, I found a bunch of people having the same problem going back to March.  Skimming through the reports, it seems due to upgrading the version of DSM.  However, there were “official” reports from Synology saying it was due to the Synology box being compromised (aka hacked).  I don’t know if I completely believe this.  But rather than point fingers and play the blame game, let’s get to the solution (or solutions).  If you look at this post, you’ll see Synology suggests 3 possible solutions:

  1. Remove disks and use a spare disk to re-install DSM
  2. Manually install DSM
  3. Remove disks and boot (then contact Synology)

So I will jump to the answer and recommend going with Option 1.  That worked for me.  It was fairly pain-less to remove the hard-drives, insert a spare drive, turn it on, and use the Synology Assistant to find the box on my network and upgrade to the latest version of DSM.  Then I took out the spare hard-drive and put back my original hard-drives.  I then had to wait for it boot up again and use the Synology Assistant to install the latest version of DSM to be able to login to DSM via my web browser again (yes, I spent probably a hour or so to get back to the same functionality I had months ago – this is called technology).  Anyways, the other options didn’t seem so great and no one else seemed to have any success, so I would recommend going with Option 1 like I did.  And then hopefully you’ll have a working NAS again and you can continue backing up your cat videos.

Google’s browsers take top spot in U.S.

Google ChromeWhen I saw the title of this article, I was really skeptical at first and wondered how it could be true.  But after reading the article and seeing how it factors in mobile browsers and also goes as far as to combine the stock Android browser and Chrome for Android, it makes more sense (not sure if I agree with their manipulation of the numbers though).  As someone who has to write code for websites and has to deal with all the issues and differences on multiple browsers, I’m happy to see the growth of Chrome – in a lot of ways, it feels very Apple-like (yeah, weird to say there are similarities between Google and Apple, but hear me out).  Apple wasn’t the first company to release a smartphone, but they are arguably the most successful.  The same can be said about Google and the Chrome browser, it definitely wasn’t the first browser, but it has proven to be extremely successful and as far as developers goes, it’s definitely a favorite.  In both cases of Apple and Google, they saw the market need for a better product and provided a superior product to what was out there.  In the case of Apple they created a mobile OS better than Windows Mobile and Blackberry (not that hard to do) – and in the case of Google, they built a faster/better browser than IE and FireFox that made it easier for developers to build against.  In both cases, they built superior products and also focused on providing not just a product, but a platform – that catered to developers to easily build apps and extensions.  Anyways, Chrome is a great product… if you’re reading this on anything but Chrome, go get Chrome.

-=-=-=-=-

When it comes to browser market share, Google is now king of all it surveys.

According to a new report, the combined usage of the company’s mobile and desktop browsers has finally overtaken that of Microsoft’s Internet Explorer in the United States. Google’s browsers, which include Chrome and the default browser in Android, held nearly 32 percent share of the U.S. market in April, compared with about 31 percent for Internet Explorer, according to Adobe, whose Digital Index service tracks browser usage.

Usage of Google’s browsers topped Internet Explorer in other markets last year, according to Adobe Digital Index.

The report underscores the large and growing importance of mobile devices. Internet Explorer remains the most used browser on PCs, with 43 percent share in April, compared with 31 percent for Google’s Chrome. But Google was able to overtake Microsoft in the browser wars because of the disparity in their mobile strengths.

On mobile devices, Chrome had 14 percent of the market in April and the Android browser has 20 percent. Internet Explorer, by contrast has less than 2 percent of the market.

Conversely, Apple’s Safari, with 25 percent share in April, has now become the third most-used browser in the U.S. because it is the most popular mobile browser. Safari had 59 percent share of the mobile browsing market, but just 10 percent of the PC browsing market. Safari is the default browser on the iPhone and iPad.

The report also highlights the decline of Mozilla’s Firefox. Once the second-most popular browser behind Internet Explorer, Firefox is now the fourth most popular browser, surpassed by not just Google’s browsers, but Safari also. Like Internet Explorer, Firefox has struggled to gain usage on mobile devices. Like Internet Explorer, it’s also seen a drop in usage on PC’s.

Firefox had less than 9 percent market share overall in April, down from nearly 20 percent two years ago. Its share of the desktop market is now 12.5 percent, while its mobile usage is less than 1.8 percent.

Adobe determines market share by looking at the browsers used to visit some 10,000 consumer Web sites in the United States. Market share corresponds with the portion of visits to the average Web site made with each browser.

The new report echoes that of other reports in recent months and years that have shown the rise of Chrome and mobile Safari and the decline of Internet Explorer and Firefox.

SiliconBeat

Apple WWDC Announcements Fail to Impress

Apple WWDC 2014After a busy day, I finally got a chance to catch up on the latest from WWDC and I can easily say that I’m not impressed by the new features/functionality.  This was obviously focused on the software updates coming to iOS and OS X in the fall of this year, so we still haven’t seen what hardware updates Apple will make (but I have a feeling a bigger screen is going to be the “big” surprise feature announcement).  But just looking at the software features that were announced, most were less than innovative or original, for example:

Customizable keyboard – um, yeah, this is a pretty basic customization that lets people find a keyboard that gives them maximum productivity.  And companies have been releasing customized keyboards for a long time, so not to impressed with this.

Widgets – and we’re only talking about widgets in the notification area, so you still can’t have a widget on your home screen showing you pertinent information (basically anything you want) so this isn’t even feature parity, it’s simply an improvement.

Lockscreen actions – again, something fairly trivial when you look at all the customization options you can do with your lock screen on an Android phone.  It does give third-party app developers to implement/add additional functionality, but definitely nothing new.

iCloud – um, yeah, so iCloud has been out for a while, but now they’re finally implementing what every other cloud storage provider has offered… wait for it… cloud storage… super innovative, right?

But don’t get me wrong, I think everything listed above improves the iOS experience.  I just don’t think it’s innovative to bake in features that other systems/apps have had and say that you’re changing the mobile landscape.  At best, you are simply keeping up with the cool kids (yes, I’m calling Android users the cool kids and Apple users the nerds).  So with all that being said, all the features included in iOS 8 look great and will definitely make iOS a feature-rich OS.  But there’s nothing super impressive that makes me want a iPhone yet.  I’m hoping the hardware announcement of the iPhone 6 is more impressive (and not just a bigger screen).

Okay, before I wrap up, I will point out some of the cooler features I saw… Continuity (useful features, but stupid name) features like Handoff, SMS and incoming/outgoing calls from your desktop are all pretty cool features (and things that I already do thanks to Android and Motorola).  So again, nothing making me jump at a new iPhone.  Guess we’ll have to wait and see the iPhone 6.

Motorola will close the Texas factory where it assembles Moto X smartphones in 2014

Moto XAnd while this news isn’t surprising, it’s pretty disappointing that Motorola is closing their factory in Texas.  I was actually pretty optimistic when I saw the Moto E and thought that Lenovo’s purchase of Motorola was going in the right direction.  Unfortunately, this is a sign that Lenovo is looking at their bottom line and trying to maximize their profits.  This could mean that the Moto E is simply a hold-over from the previous regime and that things will slowly go down hill.  I’m glad that I have my Moto X, but I’m not sure what my next phone will be… maybe a Samsung… a Motorola… a HTC… a LG… or even a iPhone 6… I’m pretty open at this point (well, maybe not a Windows Phone or Blackberry).  Any suggestions?

-=-=-=-=-

Motorola is closing a factory in Texas that employs 700 people to assemble its Moto X smartphones, the Wall Street Journal (WSJ) reports.

The plant will be shuttered before the end of the year, throwing the future of the customizable handset – and the direction of Motorola’s future flagship smartphones – into doubt. The decision was confirmed to TNW and comes four months after its $2.9 billion acquisition by Chinese manufacturer Lenovo.

According to the WSJ, Motorola will continue to produce the Moto X in China and Brazil, among other locations, but didn’t disclose whether this would include the Moto Maker devices currently handled in Texas.

When Motorola first hinted at the Moto X last summer, it said the Android smartphone would the first “designed, engineered and assembled in the USA.” It was a key part of the company’s marketing push and created a welcome narrative about bringing jobs and manufacturing back to the US.

While the device received high praise from the press, market research has suggested it wasn’t a massive success with the public. The smartphone touted unexceptional mid-to high-end components, but differentiated through Moto Maker – a website where customers could personalize the handset with different colours, materials, engravings and cases.

It was certainly novel, although the location of the Texas factory meant Moto Maker was confined to the US. Although the Moto X has subsequently been launched in other markets, Motorola has so far been unable to offer customers the same level of hardware customization.

Since Google sold Motorola, the company has launched the low-cost Moto E and a 4G-enabled version of its mid-range Moto G smartphone. It’s too early to judge how they’ve performed for Motorola, but the build quality, components and software experience represent excellent value for money.

Neither are supported by Moto Maker though, which would make it simpler for Motorola to abandon the service completely once it launches a successor to the Moto X later this year. If so, it will be an unfortunate end to an experiment that many hoped would prove the financial viability of US-based assembly.

For now though, it seems the Moto Maker service will continue as usual. Motorola didn’t disclose exactly when the factory will be shuttered – we’ll be sure to let you know when its doors finally close.

TNW