Wednesday, January 13, 2016

Shaky Fixed Backgrounds on IE 11

Sometimes on IE 11, there will be a shaky scroll on backgrounds / images that only appears in IE.

If a user were to go to Internet Options > Advanced > and UNCHECK Smooth Scrolling, this would fix the problem. However, assuming most users have it checked by default.. here is how to fix the issue using JavaScript. I am using Angular JS so I put it in the controller loaded on the page that needs the function and put it in the init function. If you are not using Angular, then just take the if statement part out, ignore the init() and place it as needed.

I also added a .1 * wd in there in case you need to adjust the speed the page gets scrolled when the user uses the mousewheel. Since ours was moving way, way too fast.. we had to multiply it by .1 to make it slower. Multiply by a whole number to make it faster.


Credit to here: http://stackoverflow.com/questions/21775234/ie-11-smooth-scrolling-not-firing-intermediate-scroll-events

Tuesday, January 5, 2016

Algorithms: Merge Sort


I have decided to take an online Algorithms course for fun / for my own good / for my curiosity in my spare time on Coursera. I am going to post some of my notes here based on what I can find on the internet with my own notes on it. I find a lot of times it is harder to come from a non-traditional background and learn very comp-sciey type of classes as I don't have a background in all the vocab / theories / concepts, so I will basically be breaking down tech sounding concepts into plain English I can understand and sharing my notes :). I don't honestly think this will help me in my day to day work but perhaps down in the future it will be a foundation for something or extremely helpful in some rare case.

Starting off.. the study of algorithms appears to me to be the study of how long things take, making more efficient code, estimating the worst case scenario for how long your code will run, and the actual set of functions / processes / calculations to be measured. Merge sort is one of many ways to take a bunch of scrambled numbers and get them sorted. Merge sort specifically takes say 8 blocks, divides it into two sets of 4, then each of those two sets into four sets of 2, and stops there.. then merges them back one at a time into a new set of numbers in order (by comparing each number to see if it is higher/lower than the numbers in the set). Watch THIS little animated snipped on Wiki and all will be clear.

Very, very specific estimated times for a calculation with constants in them aren't terribly useful.. except on a very small scale calculation.. but seem good for the sake of understanding how to calculate it at all. Below is a merge sort in C language I found on a website (referenced below image) with some annotations on it.

The number of operations it takes to run this algorithm is: 6n*log(base 2)n + 6n The easiest way to prove it is to understand that each level does the same amount of work. And to multiply the amount of work by the number of levels. And that is the total work done.

Here is how to prove each level does the same amount of work: Number sub-problems doubles with each level (larger quanity of arrays). But amount of work to do halves (arrays get smaller). Doubling # of arrays and halve the size of each array.. will have constant amount of work. See notes on code below:
Original image and C code from http://faculty.cse.tamu.edu/djimenez/ut/utsa/cs3343/lecture2.html.

The number of levels will be:
So.. if we know there are (log(base 2)*n + 1) levels and 6n work per level, if we multiple those two things we can say merge sort will take this amount of operations for a n input array of n numbers: 6n*log(base 2)n + 6n

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;
        }
    }