adobe and other apps with scaling on high dpi displays fix

Fixing Photoshop Scaling Issues on HighDPI systemI found a great blog that talked about manifest files.. but this one is WAY easier.

Right click the exe file you are trying to run that is giving you weird scaling issues.

Select “Compatibility”
Look for a setting “Override high DPI scaling behavior. Scaling Performed by.. And if the box is checked. uncheck it or if it is unchecked, check it. In photoshop where menus etc were tiny, I needed to check it. WIth another app where the fonts where HUGE I had to uncheck it.

 

Finding the directory that python is installed in.. (CENTOS) and using it for virutalenv’s path

assuming the following command returns a version of Python 3 you can find where it is installed using the sys object..

(see if python3 has been installed.)
python3 –version

In my case it returns

Python 3.5.0
If python 3.x has not been installed.. http://ask.xmodulo.com/install-python3-centos.html

to find the location of the install for use with Virtualenv..

at the $ type python3 (this should launch python3)

import sys
sys.executable

The import line gives you sys lib functionality and sys.executable will tell you where it is.. now you can create a virtual environment that uses python3

e.g. $ virtualenv -p /usr/local/bin/python3 py3envtest

will generate a virutal env for python3 in the directory of py3envtest.
to activate the virutalenv you will need to change into the directory of py3envtest and execute the following command

. bin/activate

Done! not typing python should automatically run the version that virtualenv had specified.

 

How to loop and increment a value in a dos batch file

the code below is basically a for loop that continues until a counter reaches a value..

@echo off
:: turn off echo
set /a var=1
:: initialize a numeric variable and set it to 1
:LOOP
:: a label to define the start of the loop
if %var% gtr 254 goto :END
:: the if test the variable and if it is > 254 (gtr) it sends the code to the label END
echo %var%
::return current value to screen
set /a var+=1
::increment counter
goto LOOP
::go back to the top of the loop and increment the number again.
:END

How to fix IE11 not playing videos on Windows 2008 server R2

I recently decided to finally upgrade my tried and true copy of IE10.. knowing full well i was about to lose some of my favorite Developer Tools – not an easy decision.. but i got sick of videos not playing due to compatibility issues.

Result.. I lost my dev tools and still couldn’t play videos.. I did find a few online solutions that suggested adding the following to the end of the youtube url to make it work..
&nohtml5=1
The problem was that you had to append that to EVERY video in Youtube and *#& help you if you want to watch an embedded video.

Today i found the real solution. To view video in the first place you needed to add the “Desktop Experience” to server 2008. The problem is that that version of “Desktop Experience” didn’t support the latest video formats or codecs.. So you need to upgrade/update the Desktop experience..

Full MS KB article = 2483177
or click this link…
https://support.microsoft.com/en-us/kb/2483177

Hopefully this solves any issues you are having.. it fixed mine.!

Jquery Plugin to only allow numeric input..

Ok.. so this is my first Jquery Plugin – VERY SIMPLE…

All it does is attach to the keydown of any element it is attached to and look to see if the key being pressed is numeric via a regular expression. Nothing fancy. no periods, no commas, no currency formatting.

Useful for making sure credit card numbers or bank account numbers are being entered correctly in a web page.

(function($) {
    $.fn.PreventNonNumeric = function() {
        $(this).keypress(
            function(x) {
                if (x.key.replace(/\D/, "") == ""|| x.key === "Spacebar")
                { x.preventDefault(); }
            }
        );

        return this;
    };
})(jQuery, event);

Attach to an element as

$("#Text1").PreventNonNumeric();

 

 

How to make a Webapi based project return gzipped json.

If you do have access to change applicationHost.config, you can enable GZip compression for JSON responses by adding the appropriate mime type to httpCompression -> dynamicTypes

The ApplicationHost.config file exists in the following directory  C:\Windows\System32\inetsrv\config

 

<httpCompression directory="%TEMP%\iisexpress\IIS Temporary Compressed Files">

<scheme name="gzip" dll="%IIS_BIN%\gzip.dll" />

<dynamicTypes> ...

<!-- compress JSON responses from Web API -->

<add mimeType="application/json" enabled="true" /> ...

</dynamicTypes>

<staticTypes> ... </staticTypes>

</httpCompression>

How to get the value from a WinForms.Listbox not databound.

I was faced with a bit of a challenge this morning. In WebForms getting the value of the selected item in a ListBox is pretty straight forward. However what i found in WebForms as a different story.

To complicate the process I was adding items to the listbox using the items collections add method.

If you look at the Intellisence for LIstBox.Items.Add expects a single argument of Object. Typically this is just the Text that is going to be displayed. However adding an item where the Text shows one thing, but the value is a different thing requires a slightly different approach

Step1. Add a new Class to your project that has a Text and Value property.
e.g.
private class ListItem
{
public string Text { get; set; }
public string Value { get; set; }
}
Step 2. When initializing the form, set the ListBox’s DisplayMember and ValueMember properties to your classes properties
e.g.
listBox1.ValueMember = “Value”;
listBox1.DisplayMember = “Text”;
Step 3. Add your items e.g.
listBox1.Items.Add(new ListItem(){ Text = “some text”, Value = “some value”});
Step 4. Read the value on the item being selected.
in the Listbox’s SelectedIndexChanged event read the value by casting the Listbox’s selected item as your custom class and then reading the property you need.
e.g. ((ListItem)listBox1.Items[listBox1.SelectedIndex]).Value

 

Hopefully that helps..
 

Does IE Suck or is it every other browser..

Having been in IT for over 20 years I have definitely heard my fare share of Microsoft Bashing. Usually by people who have NO CLUE what they are talking about. Of course web designers – who know php and MySQL because it was free when they were in college – are probably the worst of the bunch.

What I have found is that no only do I see less issues with IE than other browsers, but it is actually faster. Every time apple updates their phones and browsers I cringe. This has caused hours of extra work due to their inability to follow standards. ON android browsers in tablets and phones, drop down menu’s don’t work (at the time of this writing) Even when the menu exposes a standard <a tag>

Anyway.. today I was looking at statistics gathered by google on our public website and was amazed at what the two fastest browsers were.

1. Edge (Microsoft 10) and
2. IE (stop the cheering or leering .. check out your site if you don’t believe a random test of 38,000 page views.)

What really blew me away was that Edge was nearly 50% faster than chrome (the next fastest non-Microsoft product) – I even prefer the debugging tools in IE10 (yeah 11 and edge suck – they are more like chrome – a giant step back)

 

“Fng Virus” removal tricks

So last night a buddy came over with a laptop that had developed a nasty cold that day (lunchtime)

The well designed little beast was quite liberal with his system – it had turned off emergency restore and would also grab hold of IE and cause it to do something that ate up CPU cycles and consumed HUGE amounts of RAM. This last bit of course was making it very difficult to do things like run anti virus software.

What I ended up dong was booting to safemode, and removing traces to the virus there.

I did find out that there is another cool options built into Windows today.
“System Configuration”

from the run command type “msConfig”
on the selective startup – deselect Load System Services and Load startup items, then in boot Choose Safeboot – with minimal selected.

Having the network adapter disabled would also be a good idea.

Go to the Services tab and check  “hide all Microsoft services” and press disable all (stopping services that should not be running from starting up) now reboot and remove the nasty bug – if you find a virus writer – tell some Muslim extremist group they insulted their prophet to ensure they have a slow and painful death!

 

As a note a friend I work with suggested the following utility

http://www.bleepingcomputer.com/download/combofix/

It is called combofix and is supposed to be good at fixing stuff that nothing else can get rid of, but it comes with a warning. It should be a last resort. It can render the OS useless and force you to do a reinstall of everything including the OS. However, it will also remove stuff that the others leave behind and give you back a system that would otherwise force you to reinstall anyway.

 

How to calculate religious holidays in SQL

I found this a few years ago, but like most things forgot where i found it. The whole thing is written to exist in a SQL database.

Holiday Calendar Calculator

It adds a table that references the holidays you want to generate and also a table valued function that takes a date range as it’s arguments. The output is all the holidays listed in the table by date and title.
For more usefull SQL (and other) scripts and help, visit http://tek-tips.com