Skip to content

Instantly share code, notes, and snippets.

View jand187's full-sized avatar

Jan Daniel Anderse jand187

View GitHub Profile
@jand187
jand187 / All open windows and doors
Created October 18, 2025 09:53 — forked from EverythingSmartHome/All open windows and doors
A collection of useful templates for Home Assistant dashboards
{{ states.binary_sensor
| selectattr('attributes.device_class', 'in', ['door','window'])
| selectattr('state', 'equalto', 'on')
| list | count }}
@jand187
jand187 / Generic builder with extensions
Last active November 3, 2021 18:14
Generic builder with extensions
public class GenericBuilder<TEntity> where TEntity : new()
{
private readonly List<Func<TEntity, object>> setters;
public GenericBuilder()
{
setters = new List<Func<TEntity, object>>();
}
public GenericBuilder<TEntity> With(params Func<TEntity, object>[] props)
@jand187
jand187 / gist:4537031
Last active December 11, 2015 03:19
Basic setup for Fluent NHibernate SQLite.InMemory
var sessionFactory = Fluently.Configure()
.Database(SQLiteConfiguration.Standard.InMemory())
.ShowSql())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<AdjecentType>())
.ExposeConfiguration(cfg =>
{
var schemaExport = new SchemaExport(cfg);
schemaExport.Execute(true, true, false);
})
.BuildSessionFactory();
@jand187
jand187 / gist:4537021
Created January 15, 2013 07:53
Basic setup for Fluent NHibernate SQL-Server
var sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(@"Data Source=.\<instance>;Initial Catalog=<database>;Integrated Security=True")
.ShowSql())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<AdjecentType>())
.ExposeConfiguration(cfg =>
{
var schemaExport = new SchemaExport(cfg);
schemaExport.Execute(true, true, false);
})