Ruby on Rails: Running specific tests aka “I just want to test my current module”

There comes a time when your project has a reasonable amount of tests, be it unit tests, integration tests and what not. When working on a specific component, let’s say a payment module for an online shop you could probably do without running the whole test suite every single time you’re creating, changing or deleting a test for the payment module.

Now, if you just want to run a single test you can do so easily from the command-line using:

You could probably extend that one liner to include a list of files and create a shell script that does it for you, but why do that when we can create a rake test task that does it for us? If we open up our Rakefile and add a new TestTask under the test namespace like this:

This will allow us to run

from the command-line and it will run through the tests we’ve defined in the file list. You could probably be smart about the list using wildcards (or expressions?), but for now we only have the two files. This requires that the tasks be maintained, but in return you don’t have to run all the other tests each time you want to see if something failed or passed in the payment module.

I realize there might be other ways and perhaps some cool gems that can help us out even further so if you have tips, suggestions or the absolute truth then please feel free to comment and I’ll do my best to update the post!

 

 

 

 

Microsoft Student Hackathon 2015 in Oslo

On the 18th to the 19th of September, Microsoft Norway and myself are inviting students to attend a hackathon event at Microsoft’s headquarters at Lysaker Torg 45. It’s a tradition and I’ve participated a couple of times during my period at The Norwegian School of Information Technology now knows as Westerdals Oslo School of Arts, Communication and Technology (Westerdals ACT). It is quite the honor to be on the other side of the table this time and my good friend Anders Gill (Technical Evangelist) and I will kick things off with a thirty minute presentation each where we’ll be talking about Windows 10, Universal Windows Platform, Azure and the new Windows Bridge for Android and iOS.

For those into gaming there will be competitions in FIFA and Halo as well, so come on down on the 18th of September and join us in creating awesome new ideas, apps and websites!

Make sure to visit the post over at Channel9 where we have made a little promotional video or just watch it here and remember to sign up at this page.

 

Hope to see you there!

 

 

Video: Remove noise using Adobe Audition

When I’ve recorded using my Blue Yeti microphone connected through USB to my desktop computer I notice that my recordings pick up a lot of static noise as well as the fan noise from my computer. Using Adobe Audition I’ve had great success at removing most of those noises from my clips using the Noise Reduction effect. This quick tutorials will show you the basics on how you can utilize the effect to remove unwanted noise. It is a powerful tool so there’s a lot of things to cover, so be sure to come back for more in-depth tutorials on this subject.

 

Video: Just another Friday night

Lately I’ve been gearing up and bought myself some equipment to help me do podcasts, videos and streams, and I recently purchased a Canon Powershot G7 X camera for that purpose. So far it seems to perform really well and is exactly what I was looking for: a small camera that can I bring with me everywhere that produces great video and image quality. I also bought a lighting studio set consisting of two daylight lamps on a rack. I might have to do an equipment video later on.

In addition to the camera and the lighting; a small clip-on mic, popfilter and a boom arm plus shockmount for my Blue Yeti was also purchased for audio sessions.

To test out some of this equipment I created this short video: “Just another Friday night”: While others go out partying (hard) on a friday night, others, well.. see for yourselves.

Try Android apps on your Windows Phone today

At Microsofts yearly developer conference, Build this April; they announced two interesting projects or bridges as they call them: Project Astoria and Project Islandwood. These bridges are intended for getting apps created for other platforms, namely Android and iOS to run on Windows 10.

Project Astoria contains a whole Android sub-system and will in its first rendition only be available on Windows 10 Mobile; which means phones and phablets only. Sorry desktop users.

In the latest builds of Windows 10 Mobile released through the Insider Preview Program the Android sub-system has been reportedly been a part of that package. Many pictures of developers and enthusiasts analyzing files and namespace have circulated on Twitter, and earlier today tools and documentation leaked for Project Astoria; making it so that some of us with supported phones can sideload Android apps onto our device.

Project Astoria currently works on a small set of phones, but it has been theorized that the next build of W10M will open up for a lot more devices. The current list of supported phones:

  • Nokia Lumia 920
  • Nokia Lumia 925
  • Nokia Lumia 929 / Verizon Icon
  • Nokia Lumia 830
  • Nokia Lumia 930
  • Nokia Lumia 1520
  • Nokia Lumia 635 (1GB RAM variant)
  • Nokia Lumia 730
  • Nokia Lumia 820
  • Nokia Lumia 435
  • Nokia Lumia 928

Unfortunately the new Lumia 640 and 640 XL aren’t supported which happens to be phones I have access to here while travelling so I have no way of testing, verifiyng or uploading a video to show of the features. I will make a video in a few days when I’m back home so be sure to check back for more detailed information.

In case you have a supported phone and want to test it out, you can head on to Neowin and check out their installation process, but beware, it can end up badly (well, hard reset badly) for the phone.

Tool: Switch between Dark or Light theme on Windows 10

If you’ve been following news regarding Windows 10 lately there’s a good chance you have probably picked up that it’s possible to switch Windows 10 over to a Dark theme. It requires fiddling with the registry and there are some guides out there on how to do it, but why go through any trouble? I discovered today that my good friend and brother had released a simple tool that you can use to switch between Dark and Light themes.

Windows-10-dark-theme-tool

Interested? Then head over to “Windows 10 Dark Theme Enable / Disable Tool” on Tommynation.com for the download.

Running Windows 10 Mobile Insider Preview build 10080 on Lumia 930

With the latest insider preview build of Windows 10 for Phones — now named Windows 10 Mobile — released you can now install it on your flagship phones like the Lumia 930 that I’m using. So that’s what I did. I hopped on the fast-ring and let the update process do its job.

When I returned to the phone (downloading and installing can take some time) — I was greeted with a loading screen. Turned out to be an eternal loading screen. It kept on loading and my phone started to heat up. I plugged it out of the charger and turned it off. I turned it back on again after a while and the loading screen still greeted me and it kept on loading. I found out I could however access the notification center, Cortana and even use the task switcher. The loading screen was in fact the start screen not being able to load. I thought I would have to use the recovery tool.

Then I tried resetting my phone from Settings > System > About > reset phone. After a reset the start screen appeared. With huge tiles. I then read some tips on tweeterspacespherenet about this particular issue and resolved it by going into Settings > Personalization > Start and enable “Show more tiles”. The tiles would be smaller, but there’s still some issues with the icon size to tile size ratio, but I can live with that for now.

Another issue you might run into is that backspace does not do anything. By adding another keyboard from Settings > Time & language > Keyboard this started to work as well. I might also add that I like the way you switch between languages now. Swiping on the space key? Nice gesture.

To sum it up or TL;DR:

Start screen not showing? Getting an infinite loading screen?

Reset your phone from Settings > System > About > reset phone

Huge tiles on your start screen?

Go to Settings > Personalization > Start and turn on “Show more tiles

Backspace not working?

Go to Settings > Time & language > Keyboard and add another keyboard language

One more thing; have you noticed a mouse cursor in the top-left corner when you tap on the back, home or search button on your phone? Try pairing a bluetooth mouse. You can now use your mouse to click on stuff on your phone. The scrolling does not work though:

 

SharpKeys: Reviving the missing < and > key using Norwegian layout on a US keyboard

At Microsoft Build this year we were so lucky to receive a HP Spectre x360, and it has proven to be quite a decent 2-in-1 (check out reviews etc). The only problem: it has a US keyboard. Being Norwegian I’m used to a different keyboard layout, so keys are a bit misplaced (yes, I said it). So far it has been fine. As long as I don’t look at the keys the muscle memory takes care of hitting the right ones according to the norwegian keyboard layout.

For most people this will be fine for most usecases, but in case you’re a developer then you might want to use the lesser and greater than keys (< and >). Using a Norwegian layout on a US keyboard these keys do not exist as far as I can tell. On a Norwegian keyboard we have an extra key next to the Z key that houses both < and >:

Huh, where's that key?
Huh, where’s that key?

There’s an easy fix if you’re willing to let another key be replaced. Caps lock is a key that I don’t use at all, so for me it was easy to remap caps lock. Surprisingly there weren’t many guides online that adressed this specific issue that I could find.

To help us with this issue download the SharpKeys tool from their codeplex site. Install it on your system.

To add a key mapping simply click Add, and you’re presented with a simple dialog where you can choose which key to map from and which key to map to.

The SharpKeys interface
The SharpKeys interface

At first I felt a bit disheartened because the list was made for US keyboards so the specific key that I was looking was not present. Not at first. After a bit of thinking I found a USB keyboard that I had, hooked it up and clicked the Type key button. I hit the <> key and it got detected as key: Unknown: 0x0056 (00_56). Very intuitive I know!

Add/Edit key mapping. Use the Unknown: 0x0056 (00_56) for <> keys
Add/Edit key mapping. Use the Unknown: 0x0056 (00_56) for <> keys

When you’re all set, hit ok, then the “Write to registry” button. Sign in and out and you should be set!

I hope this can help others with this issue who are feeling a little lost like I felt when I started my Google with Bing search.

Azure WebJobs: You need Connection Strings

If you run into any trouble after adding a fresh Azure Webjob to your project and try to run it, my guess will be it has to do with connection strings and a missing storage account. If you don’t have an Azure Storage Account then creating one will be the first step. You then need to define these two connections strings in your web app: Portal (Web App -> Configure):

  • AzureWebJobsDashboard
  • AzureWebJobsStorage

connection-strings

And the format for those connection strings:

Replace STORAGE_ACCOUNT_NAME with the name you give the storage account and get the PRIMARY_ACCESS_KEY from the Portal.

If you’re going to connect to a database, also make sure that the name of the connection string you’re using is present in the Portal as well. Otherwise, if you use something like ‘DefaultConnection’ (in your DB context) which is the default one, the Azure Web App will make sure to make that work, but WebJobs will not. When you look at the connection strings in the portal you will probably not find DefaultConnection, but something along the lines of “prod_db” etc. Either rename the connection string on both ends or make sure that ‘DefaultConnection’ is present so that WebJobs can access it.

Hopefully this little post can be of some help if you run into the same problems as I did.

Running Docker on Hyper-V

It has been clear that the obvious choice when running Linux on Windows has been using VirtualBox or VMWare. It’s easier. VirtualBox and VMWare allows you to configure host-to-guest folder sharing without having to configure something called Samba/CIFS and you could get decent video performance.

Then again, many of us running Windows do however use Hyper-V on a regular basis. At least for me the Windows Phone emulators runs on Hyper-V. You could dual-boot your Windows (If this is something you’d like then check out Scott HanselmansSwitch easily between VirtualBox and Hyper-V”), and I did for while. It got tedious. Why can’t we have it all?

Then this product called Docker came along:

Using Docker on Linux we could package up our apps and distribute them. The apps would run inside containers which is sandbox for running a complete virtualized system inside another system. Basically we’re talking about virtualization. The thing that should strike you is the notion of replacing your README.md file with a Dockerfile that describes how to create a ready-to-use image for running your app.

You can then distribute this Dockerfile and let other people build images off of it, or even better, create images and upload them to Dockerhub for everybody (or privately) to pull and use.

I have begun using it, and even though I’ve hit some problems (mostly due to the fact that I run Windows and Hyper-V) I’m excited to use it and start using it to package our web-apps in particular at work.

This post will be a quick guide on how to get Docker up and running using Boot2Docker or from a plain Ubuntu Server installation.