Monday, December 28, 2015

Testing on BrowserStack locally



If you login with a BrowserStack account, you can test your local work on emulators. Note for Safari on a Mac, you have to use specific ports.

"For now, Safari 8 on Yosemite allows Local testing via a limited number of ports. The ports that are most easy to remember are 80,3000, 4000, 5000, 8000 and 8080." - StackOverFlow post

So this for example works:
https://localhost:8080

Wednesday, December 2, 2015

Clear Location Settings Cross-Browser


Let's say you are either developing or testing a website you are building that saves your location, and you already told it to save some day in the past. Interestingly every browser has its own way to clear location settings. Here's a quick reference of the big 4 Windows browsers (Chrome, IE, Edge, and Firefox).

On Chrome: Go to the settings from the hamburger menu. Click Content Settings.


On Microsoft Edge: Open the menu labeled with the 3 dots (...), hit Show More, and you will see the dropdown has the Location permissions.


On Internet Explorer: Click the gear and go to Internet Options, then Privacy tab.


On Firefox: First right click anywhere inside of the page, then select View Page Info. Then select the tab for Permissions.

Thursday, November 12, 2015

SQL Server: Save Database Locally

If you have a database up in the cloud or elsewhere and want to make a local copy, you start by opening up SQL Server Management Studio (this is 2014 but should be the same/similar for other versions).

Login to your local server. I used SQL Express, so my login is Windows Authentication and the server name is localhost/SQLEXPRESS. Also make sure this is running if you check in your Services on your machine.

Login to your online server. You need those credentials from your company or whatnot.

Now, start by right clicking on Datbases on your online server and hitting Export Data-tier application.

Hit Next.
Save locally somewhere. I just made a Db folder under my C drive to make it easy to find. It will save a BACPAC file.

Now, right click on Databases on your local server and hit Import Data-tier application. Find your BACPAC file you just made.

Find the BACPAC file you saved.

Hit Next and finish up with this dialog and you should have a local copy imported into your local server.

Add your local DB to your connection string config file.

Installing SQL Server && .NET 3.5 on Windows 10

Recently at work, I upgraded to Windows 10. Obviously, I needed SQL Server. Interestingly all versions I tried (2012, 2014, and 2016) are dependent on .NET 3.5. Even more interestingly, Windows 8 and Windows 10 do not come stock with .NET 3.5.

Anytime I tried to install SQL server, I would get a missing .NET 3.5 error.

When I try to install .NET 3.5 I had the following error: 0x800f081f missing source files.

I tried this and it failed, many times:
  1. Open a command prompt with administrator user rights (Run as Administrator) in DOS BOX type gpedit.msc
  2. Local Computer Policy -> Admin Templates -> System -> Specify settings for Optional Component install and component repair (way near the bottom of the right frame)
  3. Check the “Contact Windows Update Directly” box and set policy to Enabled.
  4. Close gpedit
  5. *Try this: Type in the dos box: DISM /Online /Enable-Feature /FeatureName:NetFx3 /All
  6. Or check in Control Panel and you can now check the .net 3.5 box and it should download
(I also tried using a USB drive with the source files and that failed.)

What did work for me:
  1. On this page (note screenshot above with photo): https://www.microsoft.com/en-us/software-download/windows10, hit Download Media Creation Tool.
  2. On my Windows 10 laptop, I opened this file, made a .ISO of my windows 10.
  3. I mounted said .ISO onto the E: drive (right click .ISO and click Mount).
  4. I ran command prompt as an admin.
  5. Then I ran this in command prompt (Replace E with whatever your mounted drive for Windows ends up being).
DISM /Online /Enable-Feature /FeatureName:NetFx3 /Source:E:\sources\sxs /All /LimitAccess

.. and it made me restart. And then it appeared to work. For some reason having it mounted locally worked.

On top of this, I was installing SQL Server 2014 and ran into another snag. I got stuck on Install watsonx86_cpu32_action, for a long long time.. suspected somethng was wrong and read a website here. Based on the suggestions, I went into Task Manager and had to End Task on some Windows Installer processed under the Background Processes.. and then it caused it to get past the watson freeze.

Wednesday, November 11, 2015

Angular JS: $.emit and $.on


In Angular, you sometimes need the scope/functions of another controller to be triggered by something in one controller.

For example, say you have a controller for a navigation page (Controller 1) and a Map page (controller 2) that contains changing maps. You want the navigation page to have a button that changes the map, but all of your stuff to control the Map page is in the Map controller. You can't hit those scope items or those methods.

So, you can have an onclick on the button on the Navigation page that hits the Controller 1 changeMap functions, which will $.emit 'changeMap' out.. where in Controller 2 there is an event listener $.on waiting for this to be triggered, and it will reroute you to the changeMap_Handler.

Controller 1: Navigation Page Controller
        $scope.changeMap = function () {
            $rootScope.$emit('changeMap', { fromState: $state.current.name });
            $state.go('locations');
        }   
Controller 2: Map Page Controller
    $rootScope.$on("changeMap", changeMap_Handler);  // passes it to the handler function

    // here is the handler function
    function changeMap_Handler(event, attrs) {
        $scope.changingMap = true;
        $rootScope.changingMap  = $scope.changingMap ;
        if (attrs.fromState === "someStateVariable") {
            $scope.variable = true;
        }
    }

Tuesday, November 3, 2015

Wednesday, September 2, 2015

Xamarin Test Cloud: How to deploy your tests

Step 1: Go to https://testcloud.xamarin.com/

Step 2: Login and see your dashboard.

Step 3: Click "New Test Run" on the top right. Click which type of app you want to run tests for first.

Step 4: Select devices you want to run the test on.

Step 5: Test series is how your tests will be organized on your dashboard. You can order them by the number of test runs you plan to execute. So if you are only doing 5 or so devices, it is nice to label it small. Then you can do medium and large depending on your audience.

Step 6: Take this code, fill in the details for your application (apk file, assembly directory..).. the part I blue marked out is my API key and my email address (which you will have filled in for your test run). Then go into the Apple terminal and put it in.. submit it, and your tests will be added to Test Cloud! You can login and see your runs on their website.

You can put "--category "smoke"", or whatever attribute is above your tests to only run certain ones. If you look at my previous Xamarin post, I mentioned you can have
[Test]
[Category("smoke")]  // attribute for sending only certain tests
[Category("whatever2")]
public void TestNameHere()
{

}
And you add it to the Terminal code at the end like this..!
mono packages/Xamarin.UITest.1.0.0/tools/test-cloud.exe submit ../something.ipa APIKEYHERE --devices f37a5aa9 --series "small" --locale "en_US" --user hello@world.com --assembly-dir StuffHere/bin/Debug --category "smoke"
Or for Windows command prompt, something like this and change api key to the one given to you:
Users\ctenn\Desktop\testcloud\testcloud\AAA\packages\Xamarin.UITest.1.0.0\tools\test-cloud.exe submit CCApp\testcloud\com.AAA_TESTCLOUD_14_2.apk APIKEYHERE --devices d3939da0 --series "weekend" --locale "en_US" --app-name "AAA" --user email@email.com --assembly-dir CCApp\testcloud\AAA\AAA\bin\Debug
NOTE 1: You can also use Xamarin studio, go into your Test explorer, right click (or double tap whichever it is) the test you want.. and then click to submit it to Test Cloud. (I am just a stubborn web developer who lives off of Windows and Visual Studio).

NOTE 2: General expectations for how well applications will work on devices depends heavily on the device. Goal is to find out your audience and what types of phones they use to cover the vast majority of them. It is best to get the top say 10-20 devices working as close to 100% as you can. Then work to try and support bigger audience. When you get to the 40 newest devices point, you will start seeing massive fails in performance based on their capacity to deal with new applications and you can't really expect them to work perfectly. Chances are you will have difficulty supporting more than the top 80 realistically based on those phone's ability to perform and their memory.