Skip to content

Instantly share code, notes, and snippets.

@taylorc
taylorc / OnLoad.cs
Created May 12, 2013 11:43
Debug form onload event
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
XmlConfigurator.Configure();
serviceRun.Start();
appender = new CustomMemoryAppender();
//Get the logger repository hierarchy.
var logRepository = (Hierarchy)LogManager.GetRepository();
@taylorc
taylorc / HomeController.cs
Created July 23, 2013 11:14
Dapper.Net glimpse
DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.SqlClient");
using (DbConnection conn = factory.CreateConnection()) {
conn.ConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
conn.Open();
var list = conn.Query<Category>("select * from categories").ToList();
}
<Target Name="MakeWebConfig">
<ItemGroup>
<Namespaces Include="Mynamespace">
<Prefix>x</Prefix>
<Uri>urn:nhibernate-configuration-2.2</Uri>
</Namespaces>
</ItemGroup>
<MSBuild.ExtensionPack.Xml.XmlFile
TaskAction="UpdateElement"
File="%(BuildArtifactsDirWebConfig.FullPath)"
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MsSqlCeDialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlServerCeDriver</property>
<property name="connection.connection_string">Data Source=FirstSample.sdf</property>
</session-factory>
</hibernate-configuration>
public static void CallWaiting(Action fn, int retryAttempts = 100, int threadSleepValue = 1000)
{
// We will try to call the function up to 100 times...
int j = 0;
for (int i = 0; i < retryAttempts; ++i)
{
j = i;
try
{
// We call the function passed in and return the result...
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
export class IncrementCount {
static readonly type = '[Home] Increment Count';
}
export class DecrementCount {
static readonly type = '[Home] Decrement Count';
}
import { Action, State, StateContext } from '@ngxs/store';
import { DecrementCount, IncrementCount } from './home.actions';
//step 1
export interface HomeStateModel {
count: number;
}
//step 2
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
import { Select, Store } from '@ngxs/store';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { DecrementCount, IncrementCount } from './home.actions';
import { HomeState, HomeStateModel } from './home.store';
// tslint:disable-next-line:import-blacklist
<div class="middleDiv">
<p>
<button (click)='addOneToCount()'>Increment</button>
<button (click)='subtractOneFromCount()'>Decrement</button>
</p>
<div class="slidingVertical">{{state.count}}</div>
</div>