Skip to content

Instantly share code, notes, and snippets.

View johnathan-sewell's full-sized avatar

Johnathan Sewell johnathan-sewell

  • BLAST
  • Copenhagen
View GitHub Profile
@johnathan-sewell
johnathan-sewell / word.hbm.xml
Created July 28, 2011 21:39
Bare bones NHibernate mapping for Lexikon word
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="lexikon.console"
namespace="lexikon.console.domain">
<class name="Word">
<id name="Id">
<generator class="native"></generator>
</id>
<property name="Text"></property>
@johnathan-sewell
johnathan-sewell / hibernate.cfg.xml
Created July 28, 2011 21:30
Bare bones NHibernate configuration for Lexikon app
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<!-- properties -->
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string_name">db</property>
<property name="show_sql">false</property>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
@johnathan-sewell
johnathan-sewell / wordpress tag lists.php
Created July 25, 2011 21:38
Wordpress tag cloud as multiple HTML lists
<?php
$mytags = get_tags() ;
if ($mytags) {
echo '<ul>';
for ($x = 0; $x <= count($mytags); $x++) {
if (($x > 0) && ($x % 3 == 0)) echo '</ul><ul>';
echo '<li>';
echo '<a href="' . get_tag_link($mytags[$x]->term_id) . '">' . $mytags[$x]->name . '</a>';
echo '</li>';
}
@johnathan-sewell
johnathan-sewell / ClearPersistentCookies.cs
Created June 2, 2011 09:33
Clear persistent login tickets in ASP.NET
private void ClearAnyPersistentCookies() {
var cookie = Request.Cookies.Get(FormsAuthentication.FormsCookieName);
if (cookie == null) return;
var ticket = FormsAuthentication.Decrypt(cookie.Value);
if (ticket == null) return;
if (ticket.IsPersistent)
FormsAuthentication.SignOut();
}
@johnathan-sewell
johnathan-sewell / index.html
Created May 25, 2011 21:37
Replace an html select element with a more easily styled JavaScript version
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<style>
.styled-dropdown {
border: 1px solid #333333;
color: #000000;
cursor: pointer;
@johnathan-sewell
johnathan-sewell / html5Placeholder.js
Created May 24, 2011 14:30
A quick and simple solution for browsers that don't support the text input placeholder attribute.
(function ($) {
$.fn.html5Placeholder = function () {
this.each(function(index) {
var placeHolderText = $(this).attr("placeholder");
if (placeHolderText) {
$(this).val(placeHolderText); //set the placeholder text as a text in the input box
$(this).focusin(function() { //remove the placeholder text on focusin
if ($(this).val() === placeHolderText)
$(this).val("");
@johnathan-sewell
johnathan-sewell / table-space.sql
Created March 28, 2011 11:22
Find out how much space each table in a SQL Server database is using
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
@johnathan-sewell
johnathan-sewell / form-required-fields.css
Created January 19, 2011 15:02
CSS to add an asterisk to required field
form label:after{
content: ':';
}
.form-template label:after{
content: ': *';
}
@johnathan-sewell
johnathan-sewell / VirtualPathProviderExtensions.cs
Created January 13, 2011 22:03
Enables you to use relative paths with EPiServer VirtualPathVersioningProvider
using System;
using System.Collections.Specialized;
using System.IO;
using System.Web.Hosting;
namespace EPiServer.Extensions
{
internal static class VirtualPathProviderExtensions
{
public static NameValueCollection FixPhysicalPath(this NameValueCollection configParameters)
@johnathan-sewell
johnathan-sewell / web.config
Created January 13, 2011 21:30
Web.config file for EPiServer 6.0.530.0 for IIS6 and Visual Studio development server
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<section name="workflowRuntime" type="System.Workflow.Runtime.Configuration.WorkflowRuntimeSection, System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<section name="wftools.services.common.ado" type="WFTools.Services.Common.Ado.Configuration.CommonAdoProviderSettings,EPiServer.WFTools.Services" />
<section name="wftools.services.persistence.ado" type="WFTools.Services.Persistence.Ado.Configuration.PersistenceAdoProviderSettings,EPiServer.WFTools.Services" />
<section name="wftools.services.tracking.ado" type="WFTools.Services.Tracking.Ado.Configuration.TrackingAdoProviderSettings,EPiServer.WFTools.Services" />
<section name="episerver" type="EPiServer.Configuration.EP