Store historical records in a history table in SQL Server

Author: | Categories: Database No Comments
You can maintain historical changes made in a table by creating another table with the same schema which holds historical data. SomeTable is the base table containing current data rows SomeTable-History has exact same schema with 2 additional columns trans_type varchar(10) date_time datetime and this table will hold historical data Below triggers created on SomeTable […]

Add a PHP page to WordPress

Author: | Categories: Wordpress No Comments
First, duplicate post.php or page.php in your theme folder (under /wp-content/themes/themename/). Rename the new file as templatename.php (where templatename is what you want to call your new template!). Enter the following at the top of the new file: <?php /* Template Name: templatename */ ?> You can modify this file (using php) to include other […]

Increase the Maximum File Upload Size in WordPress

Author: | Categories: Wordpress No Comments
In most situations there is a need to upload bigger file to WordPress site, and by default there is a limit of file size for uploading. Below are few options to increase file size which can be uploaded to WordPress. Theme Functions File There are cases where we have seen that just by adding the […]

Detect a mobile device in jQuery

Author: | Categories: Programming 4 Comments
Below are few options to detect whether web request is from a Mobile device using Javascript. Option 1 if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { // some code.. } Option 2 var isMobile = { Android: function() { return navigator.userAgent.match(/Android/i); }, BlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i); }, iOS: function() { return navigator.userAgent.match(/iPhone|iPad|iPod/i); }, Opera: function() { return […]

Detecting Mouse Movement with jQuery

Author: | Categories: Programming No Comments
Javascript / jQuery can help in capturing Mouse move, Scroll and Click events Option 1 – Capturing Mouse move along with Click and Scroll var timeout = null; $(document).on('mousemove click scroll', function() { clearTimeout(timeout); timeout = setTimeout(function() { console.log('Mouse idle for 3 sec'); }, 3000); }); Option 2 – Capturing Mouse with Javascript (function() { […]

Write text file without Read lock in C#

Author: | Categories: Programming No Comments
Suppose there is a situation in which a service is writing a log file and there is another application which needs to open this file for reading. By default a file which is written is exclusively open by writer. To overcome this and make Write and Read non-exclusive use the following code. Writer var writer […]

Ubuntu update via command line

Author: | Categories: Linux No Comments
Update Fetches the list of available updates. It downloads package lists from the repositories and “updates” them to get information on the newest versions of packages and their dependencies. It will do this for all repositories and Personal Package Archives sudo apt-get update Upgrade Upgrade is used to install the newest versions of all packages […]

Log4net logging in asp.net MVC

Author: | Categories: Programming No Comments
Make changes in web.config file as follows <configuration> <configSections> ... <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> </configSections> <appSettings> ... <add key="log4net.Config" value="log4net.config"/> <add key="log4net.Config.Watch" value="True"/> </appSettings> <log4net> <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> <file type="log4net.Util.PatternString" value="D:/Logs/TTG SmartANPR REST Service/smartanprrest_%date{ddMMyyyy}.log" /> <appendToFile value="true" /> <rollingStyle value="Date" /> <datePattern value="yyyyMMdd" /> <staticLogFileName value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date %level - %message%newline" […]

WebClient with Timeout Support

Author: | Categories: Programming No Comments
By default the C# WebClient class does not let you modify the default timeout value of 1 minute. This subclass exposes the Timeout property so you can change the default without having to use a HttpWebRequest. using System; using System.Net; namespace MyNamespace { public class WebClientEx : WebClient { public int Timeout { get; set; […]

Run Hyper-V and VirtualBox on the same machine

Author: | Categories: Windows 13 Comments
On 64 bit Windows, if Hyper-V is enabled, VirtualBox cannot create virtual machines of 64 bit architecture. So in order to install 64 bit OS on VirtualBox, Hyper-V has to be disabled. Below are ways to enable/disable Hyper-V in Windows to install and run 64 bit virtual machines. Method 1 1. Open Windows Features. 2. […]