Handy Hints
Enable CORS on windows
Often i recognize that the PUT and DELETE http methods are not allowed and in these days of REST Apis this can be a problem. Often is enough to enable the support for CORS (Cross-origin resource sharing).
To do this you could add to the Global.asax the following Application_BeginRequest implementation.
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_BeginRequest(object sender, EventArgs e)
{
var context = HttpContext.Current;
var response = context.Response;
// enable CORS
response.AddHeader(
"Access-Control-Allow-Origin",
"*");
response.AddHeader(
"X-Frame-Options",
"ALLOW-FROM *");
if (context.Request.HttpMethod == "OPTIONS")
{
response.AddHeader(
"Access-Control-Allow-Methods",
"GET, POST, PUT, DELETE");
response.AddHeader(
"Access-Control-Allow-Headers",
"Content-Type, Accept");
response.AddHeader(
"Access-Control-Max-Age",
"1728000");
response.End();
return;
}
//Here goes the other initializations
}
}
Disable Java Update
- You need to have administrative rights
- Change (or add) the following registry key
[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Update\Policy] "EnableAutoUpdateCheck"=dword:00000000
Another approach would be to delete the following key blocking the scheduler for Java updates
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\ CurrentVersion\Run\SunJavaUpdateSched
Reset File Associations Windows 7/8
- Go to "Control Panel"->"Default Programs"->"Set your default programs"
- Select the program that you want to open files with
- Check and uncheck happily!
Restart Ms Download Manager
Simply run...
%windir%\Downloaded Program Files\TransferMgr.exe
Show hide tabs and spaces VS2010-VS2012
The shortcut to toggle them is
CTR+R, CTRL+W
Castle Windsor-Component is not a typed factory
Facing an exception like...
System.ArgumentException: Component MyPackaged.IMyTypedFactory is not a typed factory. TypedFactoryInterceptor only works with typed factories.
Probably you have to force the order of registrations. You should register the Castle TypedFactoryFacility BEFORE registering the IMyTypedFactory.
Suppose your bootstrap works like the following
var container = new WindsorContainer(); container.Install(FromAssembly.This());
With two installers like the following
public class MyServicesInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(
Component.For<IMyTypedFactory>()
.ImplementedBy<MyTypedFactory>()
.LifeStyle.Singleton);
}
}
public class MyWindsorInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.AddFacility<TypedFactoryFacility>();
}
}
To ensure the correct order of initialization you should create a new Castle InstallerFactory. This will take all the types founded and will reorder them. In our specific situation the first to install will be the MyWindsorInstaller!
public class MyCustomInstallerFactory : InstallerFactory
{
public override IEnumerable<Type> Select(IEnumerable<Type> installerTypes)
{
var firstInstaller = installerTypes.FirstOrDefault(it => it == typeof(MyWindsorInstaller));
var retVal = new List<Type>();
retVal.Add(firstInstaller);
retVal.AddRange(installerTypes
.Where(it =>
typeof(IWindsorInstaller).IsAssignableFrom(it) &&
!retVal.Contains(it)
));
return retVal;
}
}
The bootstrapper would be then changed to:
var myInstallerFactory = new MyCustomInstallerFactory(); var container = new WindsorContainer(); container.Install(FromAssembly.This(myInstallerFactory));
SQLServer Take Db Offline
This means force disconnection and take offline
ALTER DATABASE MyDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE ALTER DATABASE MyDB SET OFFLINE WITH ROLLBACK IMMEDIATE
Download Metro Apps
New Way To Download Metro App In Win 8 And Install For Each computer
Prerequisites
- Fiddler2 for Windows 8 (Fiddler for .net Framework 4)
- Fiddler2 Windows 8 AppContainer Loopback Utility
- Install Download manager program like IDM Or any other download manager
Installation
- Download and install Fiddler2 And utility
- Open Fiddler2 and click on the button 'Win 8 config'
- Then click on the yes > Exempt All > and Save Changes > Just close your utility
Download
-
Open win store and select one of the program and press the install
-
Switch to your desktop and look Fiddler2
-
Right-click on the address in the address list, finding the links with appx inside
-
Download every appx with ContextMenu > Copy > JustUrl
-
Past address in the address bar Firefox and download
-
Save them in order renaming them as 001, 002 etc.
-
Look at the size and going from the latest remove all duplicates -keeping the order- e.g.
- If before were present
- 001.appx 100k
- 002.appx 1Mb
- 003.appx 2Mb
- 004.appx 200k
- 005.appx 1Mb
- 006.appx 2Mb
- The result will be
- 001.appx 100k
- 004.appx 200k
- 005.appx 1Mb
- 006.appx 2Mb
- If before were present
-
Install them in the numbered order exactly!
Sideload Apps in windows 8
Procedure
Windows 8 needs to be prepared before you can sideload apps. The first thing you need to
do is enable "Allow all trusted applications to install" in the Group Policy. Keep in mind
that the Group Policy is only available in Windows 8 Pro and Enterprise, and not Windows 8
or Windows 8 RT. Users on those systems can change a Registry setting instead.
-
Windows 8 Pro/Enterprise
- Tap on the Windows key, enter group policy, switch to Settings on the filter on the right, and load the Group Policy on the system
- Navigate to 'Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > App Package Deployment'
- Double click Allow all trusted apps to install.
- Switch the setting to enabled and click ok.
-
Windows 8 or If you do not have access to the Group Policy, change the value in the Registry directly for the same effect. May be it is not needed
- Sets the value to 1 for the registry key ''HKLM\Software\Policies\Microsoft\Windows\Appx\AllowAllTrustedApps''
-
The two other requirements are that the app needs to be cryptographically signed, and that the computer the app needs to be installed on trusts the signing certificate. If that is the case, apps can be installed with the following Windows PowerShell command
add-appxpackage C:\app1.appx -DependencyPath C:\winjs.appx
-
The file app1.appx is in this case the app that you want to install, and winjs.appx the dependency. Additional information about the process are available on Technet.
In case of errors
After entering Windows Store Just click on the Repair button
Then close the Windows Store
Try running the game or program
Installing Sqitch on windows
- Install Strawberry Perl
- Open the Perl.exe command prompt
- Install Sqitch: cpanm --quiet --notest App::Sqitch
- Install the db modules always with cpanm
- PostgreSQL: cpanm --quiet --notest DBD::Pg
- SQLite: cpanm --quiet --notest DBD::SQLite
- Oracle: cpanm --quiet --notest DBD::Oracle
- MySQL: cpanm --quiet --notest DBD::mysql
- Firebird: cpanm --quiet --notest DBD::Firebird
- Odbc: cpanm --quiet --notest DBD::ODBC
If there are unknown errors, like "Verify script 'my script.sql' failed" probably you would need to add the
binaries directory for your database to the machine path.
Installing WPS Office on Ubuntu 64 bit
Find the latest deb package (can check the last version on http://wps-community.org/downloads )
wget -O wps.office.deb http://kdl1.cache.wps.com/ksodl/download/linux/a21//wps-office_10.1.0.5707~a21_amd64.deb
Find the libpng12-0 deb package (can check the last version on https://packages.debian.org/jessie/amd64/libpng12-0/download )
wget wps.libpng12.deb http://ftp.us.debian.org/debian/pool/main/libp/libpng/libpng12-0_1.2.50-2+deb8u3_amd64.deb
Install the libpng and mesa, then wps office
sudo dpkg -i wps.libpng12.deb
sudo apt install libglu1-mesa
sudo dpkg -i wps.office.deb
Get and Install the fonts
wget -O wps.fonts.deb http://kdl.cc.ksosoft.com/wps-community/download/fonts/wps-office-fonts_1.0_all.deb
sudo dpkg -i wps.fonts.deb
Get and Install the equation fonts (the last command will take a while)
wget -O wps.equation.zip https://github.com/udoyen/wps-fonts/archive/master.zip
unzip wps.equation.zip
sudo mkdir /usr/share/fonts/kingsoft
sudo cp -r wps-fonts-master/* /usr/share/fonts/kingsoft/
sudo chown -R $USER:$USER /usr/share/fonts/kingsoft
sudo chmod -R o+rw,g+rw /usr/share/fonts/kingsoft
sudo fc-cache -vfs
Remove temporary files
rm wps.*