Skip to content

Instantly share code, notes, and snippets.

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.Web.UI.DataVisualization.Charting.Chart>" %>
<%
Model.Page = this.Page;
var writer = new HtmlTextWriter(Page.Response.Output);
Model.RenderControl(writer);
%>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" /> <!-- Require SSL must be OFF in the site settings -->
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}{REQUEST_URI}" />
@carlhoerberg
carlhoerberg / MigrateAndGenerateContext.cmd
Created May 26, 2010 09:47
Work with Linq to Sql and Migrator
@echo off
setlocal
set path="%CommonProgramFiles(x86)%\microsoft shared\TextTemplating\10.0";"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools";%path%
set connStr="Data Source=.\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=true"
REM Download MigratorDotNet from http://code.google.com/p/migratordotnet/
echo Applying migrations
..\Libs\Migrator\Migrator.Console SqlServer %connStr% "..\MyProject.Migrations\Bin\Debug\MyProject.Migrations.dll" -trace
@carlhoerberg
carlhoerberg / SyncDB.cmd
Created May 27, 2010 11:38
Sync two MsSql databases
@echo off
setlocal
set path="%programfiles%\IIS\Microsoft Web Deploy";%PATH%
msdeploy -verb:sync -source:dbFullSql="Data Source=.\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=true",computerName=yourcomputer.com ^
-dest:dbFullSql="Data Source=.\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=true",dropDestinationDatabase=true
endlocal
@carlhoerberg
carlhoerberg / QuerableExtensions.cs
Created August 25, 2010 15:17
Dynamic LINQ OrderBy extension method
public static class QuerableExtensions
{
public static IOrderedQueryable<T> OrderBy<T>(this IQueryable<T> source, string property, bool asc)
{
return ApplyOrder<T>(source, property, asc ? "OrderBy" : "OrderByDescending");
}
public static IOrderedQueryable<T> OrderBy<T>(this IQueryable<T> source, string property)
{
return ApplyOrder<T>(source, property, "OrderBy");
}
public class VarCharLengthValidatorProvider : AssociatedValidatorProvider
{
protected override IEnumerable<ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context, IEnumerable<Attribute> attributes)
{
var columnAttribute = attributes.OfType<System.Data.Linq.Mapping.ColumnAttribute>().FirstOrDefault();
if (columnAttribute == null || !columnAttribute.DbType.ToLower().Contains("varchar"))
yield break;
var match = Regex.Match(columnAttribute.DbType, @"(\d+)", RegexOptions.IgnoreCase);
if (match.Success)
module ActiveSupport
module Inflector
alias :old_foreign_key :foreign_key
def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
old_foreign_key(class_name, false)
end
def tableize(class_name)
class_name
end
end
@carlhoerberg
carlhoerberg / gist:640479
Created October 22, 2010 12:41
Web.config lines to enable dynamic in NHaml views
<configSections>
<section name="nhaml" type="NHaml.Configuration.NHamlConfigurationSection, NHaml"/>
</configSections>
<nhaml templateCompiler="CSharp4" useTabs="true">
<assemblies>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add assembly="Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
</nhaml>
require 'rubygems'
require 'sinatra/base'
require 'haml'
require 'models'
require 'rack-flash'
require 'pony'
require 'mime/types'
class App < Sinatra::Base
enable :sessions
recipe Running jQuery recipe...
/usr/lib/ruby/1.8/open-uri.rb:174:in `open_loop': redirection forbidden: http://github.com/rails/jquery-ujs/raw/master/src/rails.js -> https://github.com/rails/jquery-ujs/raw/master/src/rails.js (RuntimeError)
from /usr/lib/ruby/1.8/open-uri.rb:132:in `open_uri'
from /usr/lib/ruby/1.8/open-uri.rb:518:in `open'
from /usr/lib/ruby/1.8/open-uri.rb:30:in `open'
from /usr/lib/ruby/gems/1.8/gems/thor-0.14.3/lib/thor/actions/file_manipulation.rb:55:in `get'
from http://railswizard.org/f866948c3a033b907ff4.rb:79:in `apply'
from /usr/lib/ruby/gems/1.8/gems/thor-0.14.3/lib/thor/actions.rb:167:in
`inside'
from /usr/lib/ruby/1.8/fileutils.rb:121:in `chdir'