Code Optimization

Interesting things in software development and code optimization

Visual Studio 2017 and Razor problem

Hello,


If you have the same problem as me then you see just black text when you open any cshtml file, something like that:

so, nothing highlighted, even css and pure html.


Also, in my case there were no "Add View..." on solution context menu and on controller cation context menu.


Unfortunately what did help me is complete uninstall of the VS 2017 and installing again.


hope it will help you as well.


Thank you



1vqHSTrq1GEoEF7QsL8dhmJfRMDVxhv2y



Drive C, Free space and Intel Driver Update Utility

Hello there,


Have not posted new articles for a long time and this is the next useful post about Drive C:, Free Space and Intel Driver Update Utility.


I was trying to free a little bit more space on my 128GB drive C: because of almost all space had been etan and 5GB left.

As always I started from the Windows folder and my impression was that it occupied 25GB from 128GB only!

Huh! Interesting. I had started digging dipper and found that ProgramData->Intel folder occupied 35GB!!! 

35GB!!! for what?


Actually I figured out that Intel Driver Update Utility stored some data files there with no really useful reason.


So the solution is to Uninstall this Intel Driver Update Utility and it automatically frees the space.

(or you can just delete the .etl files)


Here you are - free 35GB of space on drive C: :)


Not only Windows likes eating  ;)


Have a good day!


1vqHSTrq1GEoEF7QsL8dhmJfRMDVxhv2y



Mouse pointer, audio and video lagging on ASUS R515M (X553MA)

Hello friends,


If you have the ASUS R515M (X553MA) notebook as me and you have mouse, audio and video lagging all the time, then you got to the right place and it is absolutely possible that it will help you.

What I have come up is the following - under the Device Manager you will find small thing named "HID-compliant wireless radio controls" device:




I don't know what is it for and have just DISABLED it. 

Reboot your notebook and after that everything should work well. In my case it has fixed mouse pointer lagging, audio lagging and video lagging.


Thank you :)




1vqHSTrq1GEoEF7QsL8dhmJfRMDVxhv2y



the debugger's worker process (msvsmon.exe) unexpectedly exited

Hello friends,


seems that you just have faced the same problem as me - "the debugger's worker process (msvsmon.exe) unexpectedly exited"


Quick and easy solution for that is just to DELETE all breakpoints:

- DEBUG -> Delete All Breakpoints


Thank you,

and see you son ;)


1vqHSTrq1GEoEF7QsL8dhmJfRMDVxhv2y



Lark Ultimate 8i WIN tablet and Windows 10 touchpad problem

Hello,


You have updated your Lark Ultimate 8i WIN tablet to Windows 10 and now the touchpad went crazy?

You touch it on right side but it makes clicks on left side? You even can not log into windows because there is no way to press any button on the virtual keyboard?

I know it and I did have the same problem and did try to solve it for a few months without any success. I did email to the Lark support and Microsoft support but no one did answer.


Fortunately I have solved this problem, I did find a proper SileadTouch touch pad driver.

Please, download the zip file and unzip files and copy them to the C:\Windows\System32\Drivers 

(and overwrite existing files)


Let me know, please, if anything



sileadtouch_win10.zip (64.2KB)


Thank you

1vqHSTrq1GEoEF7QsL8dhmJfRMDVxhv2y



Moving mouse makes video lagging - Windows 10

Hi friends,


have you noticed that, if you have windows 10 and Intel graphics chip, moving mouse over video or just moving mouse makes video lagging in a web video player?

I have Intel processor with built-in video card and I have noticed this problem. To solve it you need to do two simple steps under the Intel HD Graphics control panel:

- maximize performance on the plugged in mode

- maximize performance and disable power setting for the on-battery mode


more over, after I disabled it all I have noticed that YouTube video player started to work great in the full-screen (before this it didn't show video in full-screen mode) mode and whole laptop performance has been increased.


Enjoy it :)



1vqHSTrq1GEoEF7QsL8dhmJfRMDVxhv2y



Play audio with javascript under mobile browsers

Hello friends,


as some of you may know - there is a problem to start playing audio using javascript under mobile browsers.

This is a security feature and to be able to start playing audio you have to provide user with a button that user has to click to start playing audio.

In my case I was trying to play short audio file after some period of time but with no luck :(

After some research I found information that it was a security issue (not issue but security reason), and what I had come to is the following:

var audio = new Audio();

document.body.appendChild(audio);

audio.src='/Content/Audio/timer_001.mp3';

audio.loop = true;

var initSound = function () {

audio.play();

setTimeout(function () {

audio.pause();

}, 0);

document.removeEventListener('touchstart', initSound, false);

audio.pause();

}

document.addEventListener('touchstart', initSound, false);


So the main idea is to call audio.play and pause methods on first touch event.

After that each time your javascript code calls play or pause methods - browser plays audio.


Thank you,

see you :)




1vqHSTrq1GEoEF7QsL8dhmJfRMDVxhv2y



There was an error running the selected code generator

Hi friends,


there is good article about OAuth/OWIN and MVC 5 that I did read to get an idea what this all is and how to work with that. But after I created a project and went through all steps in the article I had decided to add my own tables and controllers and I did face with the following problem:

so right after I did click the add button to add my controller and to extend the ApplicationDbContext with my models I did get this error again and again.

I did try all steps that I found through the internet but non of them did help me to solve this problem. After a few hours I spent on it I had come to the following solution:

- Open your working project folder.
- Delete the BIN folder
- Delete OBJ folder
- Clean Solution, Rebuild Solution and try to Add Controller


But if you will get another error, like I got, about something like " the AppData\Temp\xxxxx.dll can not be accessed because of it is used by another process" - you will have to stop your antivirus and in my case it was free Panda Antivirus.


Now everything should work and you don't need to change from System.Data.Entity.DbSet<> to System.Data.Entity.IDbSet<>

or whatever in your code.


Thank you :)


1vqHSTrq1GEoEF7QsL8dhmJfRMDVxhv2y



Print on Wood - Image overlay


Hello my dear friends,


in this post I will show you how to overlay one image over another image like if you would print an image over wood.

In this example we need two images, one is a wood image and another one is just a photo or whatever image do you like.

To make such effect we will do a few simple steps, here you are:

- create an empty image that will be a result image;

- draw your wood texture over that empty image;

- combine colors of the wood image and a photo, using the following formula c1 * c2 / 255.0;


The main thing here is to multiply each component of colors and divide it by 255.0. You do not need to do anything with alpha,

here is the short code:

for (int y = 0; y < surfWood.Bounds.Height; y++)

{

for (int x = 0; x < surfWood.Bounds.Width; x++)

{

color = surfWood.GetPixel(x, y);

color2 = surfSrc.GetPixel(x, y);

surfWood.SetPixelAsIs((byte)((double)color.R*(double)color2.R/255.0)

,(byte)((double)color.G*(double)color2.G/255.0)

,(byte)((double)color.B*(double)color2.B/255.0)

,color.A

, x, y);

}

}


 the result you will get is like the following:



so looks like you have printed out on a wood plate.


Thank you



1vqHSTrq1GEoEF7QsL8dhmJfRMDVxhv2y