Skip to content

Instantly share code, notes, and snippets.

@underwhelmed
underwhelmed / HangfireJobStatusUpdateAttribute.cs
Last active August 29, 2015 14:19
Hangfire v1.4 Windows Server Configuration
public class HangfireJobStatusUpdateAttribute : JobFilterAttribute, IElectStateFilter
{
private IScheduledTasksRepository _repo;
private IScheduledTaskLogRepository _log;
private ITransactionFactory _tranFactory;
private ICronService _cronSvc;
/// <summary>
/// Initializes a new instance of the <see cref="HangfireJobStatusUpdateAttribute"/> class.
/// </summary>
@underwhelmed
underwhelmed / .htaccess
Created April 28, 2015 20:34
Redirect all http and https traffic from naked domain to www.
# Redirect HTTP without www to HTTP with www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Redirect HTTPS without www to HTTPS with www
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
public class TestController : Controller
{
public string ViewThis()
{
return "Test, Dennis";
}
}
//using default routes from Empty MVC2 Web Application, http://localhost:xxxxx/Test/ViewThis should return just that text
SELECT UserLogin, FirstName, LastName
FROM Users
LEFT OUTER JOIN
(
SELECT UserID
FROM UserPropertyValues
WHERE PropertyValueID IN (@PropertyIDs)
GROUP BY UserID
HAVING COUNT(UserID) =
(
SET NOCOUNT ON
IF OBJECT_ID('tempdb..##INDEXTEMP') IS NOT NULL begin exec sp_executesql N'DROP TABLE ##INDEXTEMP' end
EXEC sp_MSforeachtable
@command1 = N'INSERT INTO ##INDEXTEMP ([name], [rows], [reserved], [data], [index_size], [unused]) exec sp_spaceused ''?'', ''true'';'
, @precommand = N'CREATE TABLE ##INDEXTEMP ([id] int identity(1,1) not null,[name] sysname,[rows] int,[reserved] varchar(20),[data] varchar(20),[index_size] varchar(20),[unused] varchar(20))'
, @postcommand = N'
SELECT
[name], [rows], [reserved], [data], [index_size], [unused]
$server = "localhost"; # The SQL Server instance name
$database = "MyDB"; # The database name
# Load the SMO assembly
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null
# Create the SMO objects
$srv = New-Object "Microsoft.SqlServer.Management.SMO.Server" $server;
$db = New-Object ("Microsoft.SqlServer.Management.SMO.Database");
Uri uri = new Uri(url);
Console.WriteLine(uri.GetLeftPart(UriPartial.Path));
Public Class Bootstrapper
Public Shared Sub BootstrapStructureMap()
ObjectFactory.Initialize(AddressOf AutoRegisterStructureMap)
End Sub
Private Shared Sub AutoRegisterStructureMap(ByVal s As IInitializationExpression)
s.Scan(AddressOf ScanAssemblies)
End Sub
DECLARE @sql VARCHAR(255)
SET @sql = 'SELECT Testing FROM @tbl WHERE CONTAINS(*, ''"' + @p0 + '*"'')'
EXEC @sql
<script type="text/javascript">
function redirectToHttps()
{
var httpURL = window.location.hostname + window.location.pathname + window.location.search;
var httpsURL = "https://" + httpURL ;
window.location = httpsURL ;
}
redirectToHttps();