Sticky header menu with animation using Javascript

The problem I needed to create animated menu, which will stay always sticked to the top and will collapse or expand as user scroll How it should look Click the image for a live version – Wisephora.com What do you need to implement it? You will need a little bit Javascript and CSS. There are several ways how to implement it, at first I wanted to do it purely by using CSS transitions, but I got whole bunch of weird bugs, so finally I implemented it using mostly Javascript. The main idea is that menu switches between two states, “expanded” and “collapsed”. I …

Continue Reading

My Bower/Gulp settings

This is my Gulp.js workflow settings based on examples shown in this PluralSight course (I really recommend you to watch it). I am using these gulp plugins: main-bower-files for creating list of js files to be injected gulp-inject for injecting js/css files into index.html file When you install some library via bower you should do so with the –save option, so that it automatically updates the bower.json file. Like this bower install angular –save That will add following line to bower.json file: “dependencies”: { “angular”: “~1.4.8″ } Why do you need it? Because the main-bower-files plugin will then read this “dependencies” section and inject listed scripts …

Continue Reading

Difference between async loops in C#

What do you think will happen when you run these 2 snippets of code? They both looks quite similar at the first sight, don’t they. This one var results = new List<SomeClass>(); mylist.ForEach(async item => { var result = await SomeDbQueryAsync(item); results.Add(result); }); versus this one var results = new List<SomeClass>(); foreach(var item in mylist) { var result = await SomeDbQueryAsync(item); results.Add(result); }); The code looks remarkably similar, but the 1st sample will throw this exception “A second operation started on this context before a previous asynchronous operation completed. Use ‘await’ to ensure that any asynchronous operations have completed before …

Continue Reading

VisualStudio has problem when multiple versions of Typescript are installed

You can have several versions of Typescript installed on your machine and each project in Visual Studio can be configured to use different version by specifying that version in .csproj file. Like this But you might still have problems with IntelliSense for some native javascript objects. VisualStudio uses file lib.d.ts  to learn interfaces of window objects, events, etc. This lib.d.ts is updated with each version of typescript you install. When some interface become obsolete, it is removed from lib.d.ts, and VisualStudio then marks usage of such an interface as invalid and refuses to build. Now you have problem. You can either manually update …

Continue Reading

Selenium WebDriver can’t start

After a few days of writing tests using Selenium, the WebDriver suddenly stopped working. It did not even start. I tried to restart my machine, check versions of Firefox and Selenium (both were up to date), restart Visual Studio, clean solution. Nothing worked.  There was not even an exception description. All I got was a message “Exception does not have a stack trace”. Not very helpful. After some time I found the cause of this: When Selenium WebDriver starts it creates its own copy of  Firefox profile in Temp folder. If WebDriver is stopped in a standard way, then it …

Continue Reading

How to unit test Angular’s $resource and $http

Unit testing of Angular’s underlying $http can be very tricky. I’ve some spent considerable time to get the unit testing up and running. What was running OK in a live application, was not working at all in a unit test. I was getting error message “No pending request to flush !” all the time. My controller looked something like this //TypeScript Module.controller(“UsersCtrl”, [<any> “$scope”, “$location”, “User”, function ( $scope, $location : ng.ILocationService, User: ng.resource.IResourceClass) { $scope.findUsers = () => { User.query({ email: $scope.searchTerm, showAdHoc: $scope.showAdHoc }, function (data: any) { //data arrived. Do something with them }, function (errorData: any) …

Continue Reading

Fyzika dopravní zácpy

Překlad článku The Physics Behind Traffic Jams od Williama Beaty. Poznámka překladatele: Nechávám vše v ich-formě. Takže pedem upozorňuji, že nežiju v Seattlu, a netrávím každý den 2 hodiny v zácpě, jako původní autor. Nicméně mi článek přišel natolik zajímavý, že ho tu překládám. Myslím, že pražáci mají s dopravou podobné zkušenosti jako lidi v Seattlu. (Článek jsem lehce zkrátil.) Žiju v Seattlu a denně dojíždím do práce, což mi zabere tak 45 minut. To když mám štěstí. Když ho nemám, je to třeba i 2 hodiny jedním směrem. To mi dává dostatek času všímat si zajímavých vzorů chování aut. …

Continue Reading

How to set default browser in Visual Studio 2010

After every upgrade of Resharper I always encounter the same annoying error: Default browser in Visual Studio is reset to default browser in Windows. I use Chrome but when I need to debug JavaScript I always use Internet Explorer with VS. It’s by all means the best debugging tool for JavaScript I’ve encountered (I know that some people hate MS products, so lets the flame wars begin 🙂 ). One workaround is to right click on any .aspx page and choose “Browse with…” and then set IE as default. But this is not always available. But what if you are …

Continue Reading

Navigate to Remote Source Files with Resharper

My colleague showed me today how to set Resharper 6 to show source code of files not available locally. I did not know it is possible. You are then able to see how some objects or libraries are defined. Go to Menu / Resharper / Options / Tools / External Sources and check the Option “Navigation to Sources” Mark “Use debug information for navigation” And most importantly “Allow downloading from remote locations”. See the attached images

Continue Reading
FILED UNDER: TipsTAGGED WITH:

How to get text value from HtmlTextWriter in C#

HtmlTextWriter is very nice tool to generate HTML in C#, but it lack ability to get generated HTML as a string. Here is a simple solution: HTmlTextWriter uses internally StringWriter which uses StringBuilder. So you first create StringBuilder and StringWriter, pass them to HtmlTextWriter and when you are done you simply call ToString() on the instance of StringBuilder.  

Continue Reading