Joseph Michael Pesch
VP Programming

SQL Backup All User Databases via Windows Task Scheduler

by 22. March 2016 18:14

1) Create the SQL procedure below
2) Add this sqlcmd to a CMD file:
    sqlcmd -S localhost -E -Q "exec master.dbo.prc_BackupUserDatabases"
3) Add this command to the CMD file (to delete files older that X days), sample deletes *.bak files older than 5 days:
    forfiles -p "C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup" -s -m *.bak -d -5 -c "cmd /c del @path"
4) Add to windows task scheduler with Action = Start a Program (pointed to the CMD file)

SQL Procedure

USE [master]
GO
create procedure [dbo].[prc_BackupUserDatabases] as
begin
  declare @DatabaseName varchar(50)
        , @BackupFolder sysname = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\';
  declare cur cursor for select name from sys.databases where len(owner_sid) > 1
  open cur
  while 1=1 begin
    fetch next from cur into @DatabaseName
    if @@FETCH_STATUS <> 0 break
    declare @BackupFilePath sysname = @BackupFolder + @DatabaseName + N'_' + CONVERT(char(8), GETDATE(), 112) + '.bak';
    backup database @DatabaseName to disk = @BackupFilePath with init, STATS=10;
  end
  close cur
  deallocate cur
end

Tags:

SQL Server

Enable Remote IIS Web Administration with IIS Management Console or Power Shell

by 24. February 2016 05:00

https://technet.microsoft.com/en-us/magazine/dn198619.aspx

Tags:

MP4 File Format Specification Details

by 14. February 2016 14:59

 

 

Tags:

Tools for Apache Cordova for Visual Studio 2013 - Blocking Update and Cannot Uninstall

by 24. January 2016 07:07

I was trying to update Visual Studio 2013 and could not as it was complaining that I needed to remove an older version of "Tools for Apache Cordova for Visual Studio 2013".  I went into my Control Panel and found "Tools for Apache Cordova for Visual Studio 2013 - CTP3.1" as an installed program and tried to uninstall; however, that would immediately say it completed and would not actually remove it.  To force the removal I had to search in my "%ProgramData%\Package Cache" folder for the "MultiDeviceHybridApps_VS.msi" file.  Then run the following command from an administration command prompt using the full path to the MSI.

misexec /x FULL_PATH_TO_MSI_HERE

Tags:

Visual Studio

C# Generic Class Wrapper

by 23. January 2016 07:57

 

public class Wrapper<T>
{
    public Wrapper(T wrapped)
    {
        Wrapped = wrapped;
    }

    public T Wrapped { get; set; }
}

public class WrapperFactory
{
    public static Wrapper<T> Create<T>(T wrapped)
    {
        return new Wrapper<T>(wrapped);
    }
}

var wrappedInt = WrapperFactory.Create(42);

Tags:

C#

Morris.js Charting Issue with Unresponsive JavaScript in Firefox Browser

by 9. January 2016 11:09

After implementing Morris.js for charting I would periodically receive this error message in Firefox:

Warning: Unresponsive script

A script on this page may be busy, 
or it may have stopped responding.  
You can stop the script now, 
open the script in the debugger, 
or let the script continue.

Script: http://.../plugins/morris/raphael.min.js


To resolve this I added the parseTime: false setting to the chart object. It seems that Mozilla tries to parse the "xLabels" attribute as a datetime and goes into a loop.

 

Tags:

JavaScript

SQL Function to Convert Delimited String to Table

by 24. December 2015 07:58

This is a SQL function to convert a delimited string into a table.

create function [dbo].[DelimToTable] 
(@StringInput varchar(max), @Delimiter nvarchar(1))
returns @OutputTable table([String] varchar(255)) as begin
declare @String varchar(255)
while len(@StringInput) > 0 begin
set @String = left(@StringInput
, isnull(nullif(charindex(@Delimiter, @StringInput) - 1, -1)
, len(@StringInput)))
set @StringInput = substring(@StringInput
, isnull(nullif(charindex(@Delimiter, @StringInput), 0)
, len(@StringInput)) + 1, len(@StringInput))
insert into @OutputTable ([String]) values(@String)
end
return
end

Tags:

SQL Server

Visual Studio 2013 Setup/Installer Add In

by 21. October 2015 05:03

https://visualstudiogallery.msdn.microsoft.com/9abe329c-9bba-44a1-be59-0fbf6151054d

NOTE: To create a windows service setup make sure to open the service.cs file and right-click on the screen to "Add Installer" (as shown in screen shot below).

 

Tags:

Migrate Azure Virtual Machine (VM) Between Storage Accounts

by 20. October 2015 04:39

https://azure.microsoft.com/en-us/blog/migrate-azure-virtual-machines-between-storage-accounts/

Tags:

Azure

Sending Email Through SMTP Using TELNET

by 16. September 2015 05:17

1) Open a cmd prompt.

2) Enter telnet <the FQDN of your SMTP server> <the port number>

image

3) Enter EHLO <the DNS domain name where the SMTP server is at>

image

If you get a successful connection you will see this:

image

4) Enter MAIL FROM: <the email address of the Workflow Run As Account>

image

5) Enter RCPT TO: <some email address you want to send to>

image

6) Enter DATA

image

7) Enter SUBJECT: <some subject you want to have> and hit Enter TWO times:

image

8) Enter a message body followed by Enter, then a period, then Enter again.

image

9: Enter QUIT

Tags:

Windows

SQL Server Drop Extended Properties (e.g. MS_Description)

by 8. September 2015 04:38

This script will generate a set of drop statements:

--tables
 select 'EXEC sp_dropextendedproperty
 @name = '''+name+'''
 ,@level0type = ''schema''
 ,@level0name = ' + object_schema_name(extended_properties.major_id) + '
 ,@level1type = ''table''
 ,@level1name = ' + object_name(extended_properties.major_id)
 from sys.extended_properties
 where extended_properties.class_desc = 'OBJECT_OR_COLUMN'
 and extended_properties.minor_id = 0
 union
 --columns
 select 'EXEC sp_dropextendedproperty
 @name = '''+sys.extended_properties.name+'''
 ,@level0type = ''schema''
 ,@level0name = ' + object_schema_name(extended_properties.major_id) + '
 ,@level1type = ''table''
 ,@level1name = ' + object_name(extended_properties.major_id) + '
 ,@level2type = ''column''
 ,@level2name = ' + columns.name
 from sys.extended_properties
 join sys.columns
 on columns.object_id = extended_properties.major_id
 and columns.column_id = extended_properties.minor_id
 where extended_properties.class_desc = 'OBJECT_OR_COLUMN'
 and extended_properties.minor_id > 0

Tags:

SQL Server

BundleConfig EnableOptimizations Breaks Font Awesome

by 30. August 2015 15:13

When using Font Awesome with bundling and optimization you need to add the CssRewriteUrlTransform() to the font awesome bundle (as shown below).

BundleTable.EnableOptimizations = true;

bundles.Add(new StyleBundle("~/bundles/css/font-awesome").Include(
  "~/css/font-awesome.min.css", new CssRewriteUrlTransform()
));

Tags:

CSS

Bootstrap Image Slider Center Image

by 30. August 2015 12:03

div.carousel-wrapper{
    width: 80%; /* for example */
    margin: auto;
}

.carousel-inner > .item > img,
.carousel-inner > .item > a > img{
width: 100%; /* use this, or not */
margin: auto;
}

Tags:

CSS | Bootstrap

Bootstrap Image Slider Center Image

by 30. August 2015 12:03

div.carousel-wrapper{
    width: 80%; /* for example */
    margin: auto;
}

.carousel-inner > .item > img,
.carousel-inner > .item > a > img{
width: 100%; /* use this, or not */
margin: auto;
}

Tags:

CSS

SQL Server TSQL DateDiff Between Weekdays Only

by 20. August 2015 07:04

declare @d1 datetime, @d2 datetime
select @d1 = '8/1/2015',  @d2 = '8/20/2015'

select datediff(dd, @d1, @d2) - (datediff(wk, @d1, @d2) * 2) -
       case when datepart(dw, @d1) = 1 then 1 else 0 end +
      case when datepart(dw, @d2) = 1 then 1 else 0 end

Tags:

SQL Server

Remove hiberfile.sys from Windows C: Drive

by 2. August 2015 09:46

Run CMD as administrator and run the following commands:

POWERCFG -X -hibernate-timeout-dc 0
POWERCFG -X -hibernate-timeout-ac 0
POWERCFG -H OFF

Tags:

iPhone Backup File Locations

by 26. July 2015 14:58

When iTunes backs up your iPhone, iPad or iPod Touch, it saves all your important data into various files within the backup folder.

The filenames are encoded so they appear as strings of letters and numbers. It turns out, however, that for each version of the iPhone operating system (iOS), they're encoded in similar ways.

Here are some of the main files.

iOS 6 iPhone Backup File Locations

ContentsReal FilenameFilename in Backup
SMS sms.db 3d0d7e5fb2ce288813306e4d4636395e047a3d28
Contacts AddressBook.sqlitedb 31bb7ba8914766d4ba40d6dfb6113c8b614be442
Calendar Calendar.sqlitedb 2041457d5fe04d39d0ab481178355df6781e6858
Reminders Calendar.sqlitedb 2041457d5fe04d39d0ab481178355df6781e6858
Notes notes.sqlite ca3bc056d4da0bbf88b5fb3be254f3b7147e639c
Call hist. call_history.db 2b2b0084a1bc3a5ac8c27afdf14afb42c61a19ca
Locations consolidated.db Removed from iTunes backup, not iDevice

iOS 5 iPhone Backup File Locations

ContentsReal FilenameFilename in Backup
SMS sms.db 3d0d7e5fb2ce288813306e4d4636395e047a3d28
Contacts AddressBook.sqlitedb 31bb7ba8914766d4ba40d6dfb6113c8b614be442
Calendar Calendar.sqlitedb 2041457d5fe04d39d0ab481178355df6781e6858
Reminders Calendar.sqlitedb 2041457d5fe04d39d0ab481178355df6781e6858
Notes notes.sqlite ca3bc056d4da0bbf88b5fb3be254f3b7147e639c
Call hist. call_history.db 2b2b0084a1bc3a5ac8c27afdf14afb42c61a19ca
Locations consolidated.db Removed from iTunes backup, not iDevice

iOS 4 iPhone Backups

ContentsReal FilenameFilename in Backup
SMS sms.db 3d0d7e5fb2ce288813306e4d4636395e047a3d28
Contacts AddressBook.sqlitedb 31bb7ba8914766d4ba40d6dfb6113c8b614be442
Calendar Calendar.sqlitedb 2041457d5fe04d39d0ab481178355df6781e6858
Notes notes.sqlite ca3bc056d4da0bbf88b5fb3be254f3b7147e639c
Call hist. call_history.db 2b2b0084a1bc3a5ac8c27afdf14afb42c61a19ca
Locations consolidated.db 4096c9ec676f2847dc283405900e284a7c815836

iOS 3 iPhone Backups

ContentsReal FilenameFilename in Backup
SMS sms.db 3d0d7e5fb2ce288813306e4d4636395e047a3d28
Contacts AddressBook.sqlitedb 31bb7ba8914766d4ba40d6dfb6113c8b614be442
Calendar Calendar.sqlitedb 2041457d5fe04d39d0ab481178355df6781e6858
Notes notes.db 740b7eaf93d6ea5d305e88bb349c8e9643f48c3b
Call hist. call_history.db ff1324e6b949111b2fb449ecddb50c89c3699a78

iOS 2 iPhone Backups

ContentsReal FilenameFilename in Backup
SMS sms.db 3d0d7e5fb2ce288813306e4d4636395e047a3d28
Contacts AddressBook.sqlitedb 31bb7ba8914766d4ba40d6dfb6113c8b614be442
Calendar Calendar.sqlitedb 2041457d5fe04d39d0ab481178355df6781e6858
Notes notes.db 740b7eaf93d6ea5d305e88bb349c8e9643f48c3b
Call hist. call_history.db ff1324e6b949111b2fb449ecddb50c89c3699a78

iOS 1 iPhone Backups

ContentsReal FilenameFilename in Backup
SMS sms.db 3d0d7e5fb2ce288813306e4d4636395e047a3d28
Contacts AddressBook.sqlitedb adb8c77534444e97c31ff15924d50f3ed1fbd3b1
Calendar Calendar.sqlitedb 14ee8cdc3e6e0220399ff210246e1c92b7df89a0
Notes notes.db 740b7eaf93d6ea5d305e88bb349c8e9643f48c3b
Call hist. call_history.db a49bfab36504be1bf563c1d1813b05efd6076717

From: http://www.iphonebackupextractor.com/blog/2012/apr/23/what-are-all-files-iphone-backup/

 

Tags:

Bitnami Wordpress How To Remove the Manage Banner

by 7. June 2015 20:58


How to remove the banner

In case you wan't to remove the banner, you will just need to SSH into your machine and then execute the following command:

sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1
Please note the actual path will depend on the installed application so it may be different in your case (/opt/bitnami/apps/drupal/bnconfig for Drupal, /opt/bitnami/apps/joomla/bnconfig for Joomla...).

And then restart Apache:

sudo  /opt/bitnami/ctlscript.sh restart apache

Please note the above steps will only remove the corner banner, the Bitnami info page will still be availble by visiting  http://example.com/bitnami/index.html

Original source: https://wiki.bitnami.com/Components/Bitnami_info_page

Tags:

Piranha CMS Uses TinyMCE and Removes Certain Tags Like FontAwesome <i> Tags

by 9. May 2015 10:27

I was using Piranha CMS with the out-of-the-box implementation in conjunction with an MVC Bootstrap HTML/CSS template.  This was working great with the exception of certain tags (specifically in my case the <i> tag used in conjunction with FontAwesome) would get removed.  This is because by default the TinyMCE html editor that Piranha CMS uses will only retain the configured allowable tags.  I fixed this issue by adding my <i> tag to the configuration of allowable tags using the "extended_valid_elements" configuration setting of TinyMCE.  This setting adds additional allowed tags/attributes in the TinyMCE editor in addition to the default allowed tags/attributes. 

In my case the specific setting looked like this: extended_valid_elements : 'i[*]'

In order to implement this with Piranha CMS I needed to add a new file "TinyMCE.cshtml" to the folder "Areas\Manager\Views\Shared\Partial" in my MVC project (side note, that full folder path did not already exist so I added the necessary sub-folders).  Here is the full content of the TinyMCE.cshtml file:

<script type="text/javascript" src="~/res.ashx/areas/manager/content/js/ext/tiny_mce/tinymce.min.js"></script>
<script type="text/javascript">
  tinymce.init({
    extended_valid_elements : 'i[*]',
    mode: 'specific_textareas',
    editor_selector: "editor",
    convert_urls: false,
    plugins: [
        "autoresize autolink code hr paste piranhaimage link"
    ],
    width: "100%",
    height: "340",
    autoresize_min_height: 340,
    @if (File.Exists(Server.MapPath("~/areas/manager/content/css/editor.css"))) {
        <text>content_css: "@Url.Content("~/areas/manager/content/css/editor.css")",</text>
        }
    toolbar: "bold italic underline | bullist numlist hr | formatselect removeformat | cut copy paste | link piranhaimage | code",
  });
</script>

Tags:

ASP.Net | MVC

TSQL Function to Return Number of Weekdays Between Two Dates (Excludes Weekend Days)

by 4. May 2015 10:41

TSQL function to return a number of weekdays between two dates (i.e. excludes weekend days):

create function WeekdayDateDiff
(
 @BegDt as DATETIME,
 @EndDt as DATETIME
) returns int as begin
  return (datediff(dd, @BegDt, @EndDt) + 1)
  -(datediff(wk, @BegDt, @EndDt) * 2)
  -(case when datepart(dw, @BegDt) = 1 then 1 else 0 end)
  -(case when datepart(dw, @EndDt) = 7 then 1 else 0 end)
end

Tags:

SQL Server