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 / Program.cs
Created February 15, 2012 13:26
Log4Net basic console example
using System;
using System.Reflection;
using log4net;
using log4net.Config;
//see http://logging.apache.org/log4net/release/manual/configuration.html#attributes
[assembly: XmlConfigurator(Watch = true)]
namespace Log4NetExamples.ConsoleApplication1
{
internal class Program
@johnathan-sewell
johnathan-sewell / App.config
Created February 15, 2012 13:21
Log4Net example configuration
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="RollingLog.log" />
<appendToFile value="true" />
@johnathan-sewell
johnathan-sewell / contact-page.php
Created September 19, 2011 08:55
Sample code for a Wordpress contact page which emails a form submission
<?php
/*
Template Name: Contact Page
*/
/**
* The template for displaying the Contact page.
*
*
* @package WordPress
@johnathan-sewell
johnathan-sewell / .gitignore
Created September 16, 2011 09:48
Template for git ignore file
_ReSharper.*/
package/
_ReSharper*
*.user
*.suo
*.cache
*.orig
*.pdb
*.ReSharper
[Cc]onnection[Ss]trings.config
@johnathan-sewell
johnathan-sewell / HomeController.cs
Created September 15, 2011 20:59
MVC controller accessing NHibernate SessionFactory from static variable
public class HomeController : Controller
{
public ActionResult Index()
{
//Get static SessionFactory defined in Global.asax
var session = MvcApplication.SessionFactory.GetCurrentSession();
using (ITransaction transaction = session.BeginTransaction())
{
var word = new Word
@johnathan-sewell
johnathan-sewell / session-per-web-global.cs
Created September 15, 2011 20:54
Setting up NHibernate session per web request - Global.asax
public static ISessionFactory SessionFactory { get; private set; }
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
//Configure NHibernate and create a session factory for the application
var nhibernateConiguration = new NHibernate.Cfg.Configuration();
ls *.sln | select -first 1 | %{ ii $_.FullName }
@johnathan-sewell
johnathan-sewell / mail.php
Created September 8, 2011 09:04
Send an email in PHP
<?php
$to ="[email protected]";
$subject = "PHP Mail Test";
$message = "This is a PHP mail test";
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$success = mail($to ,$subject ,$message, $headers);
print("mail sending result:" + $success);
@johnathan-sewell
johnathan-sewell / create-folder-structure.ps1
Created August 30, 2011 20:33
A Powershell script for creating a new solution structure, it mimics the structure of the SharpArchitecture example solution at https://github.com/sharparchitecture/Northwind
# A Powershell script for creating a new solution structure, it mimics the structure of
# the SharpArchitecture example solution at https://github.com/sharparchitecture/Northwind
Clear-Host
#The Split-Path cmdlet returns only the specified part of a path
$projectFolder = Split-Path -parent $MyInvocation.MyCommand.Definition
new-item -path $projectFolder -name app -itemtype "directory"
@johnathan-sewell
johnathan-sewell / Console.cs
Created July 28, 2011 21:42
Bare bones NHibernate schema export
using System;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using lexikon.console.domain;
namespace lexikon.console
{
class Program
{