Skip to content

Instantly share code, notes, and snippets.

static string uniqueCode()
{
string characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#";
string ticks = DateTime.UtcNow.Ticks.ToString();
var code = "";
for (var i = 0; i < characters.Length; i += 2)
{
if ((i + 2) <= ticks.Length)
{
var number = int.Parse(ticks.Substring(i, 2));
public abstract class Enumeration : IComparable
{
private readonly int _value;
private readonly string _displayName;
protected Enumeration()
{
}
protected Enumeration(int value, string displayName)
public class EntitytMap:ClassMap<Entity>
{
public EntitytMap()
{
Table("TableName");
Schema(Session.TenantName);
Id(p => p.Id, "Id").GeneratedBy.Identity();
}
}
//If you want to have each tenant in their own schema, this should work. If you want to keep the schema the same but have a prefix on the table, you could change to:
public sealed class Singleton
{
Singleton()
{
}
public static Singleton Instance
{
get
{
IF(@@SERVERNAME = 'BS-DVP22\SQLEXPRESS')
BEGIN
USE [STD50_DEV_Sprint4];
declare @n char(1)
set @n = char(10)
declare @stmt nvarchar(max)
-- procedures
@hoangitk
hoangitk / kill_connection.sql
Created November 7, 2014 04:31
Kill all connections to SQL Server
USE master
go
DECLARE @dbname sysname
SET @dbname = '<your database name>'
DECLARE @spid int
SELECT @spid = min(spid) from master.dbo.sysprocesses where dbid = db_id(@dbname)
WHILE @spid IS NOT NULL
BEGIN
With git log check which commit is one prior the merge. Then you can reset it using:
git reset --hard commit_sha
There's also another way
git reset --hard HEAD~5
will get you back 5 commits.
As @Velmont suggested below in his answer, in this direct case using:
@hoangitk
hoangitk / email.regex.cs
Created November 11, 2014 03:57
Email validation follow RFC 2822
@"^((?>[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+\x20*" + @"|""((?=[\x01-\x7f])[^""\\]|\\[\x01-\x7f])*""\x20*)*" + @"(?<angle><))?" + @"((?!\.)(?>\.?[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+)+" + @"|""((?=[\x01-\x7f])[^""\\]|\\[\x01-\x7f])*"")" + @"@" + @"(((?!-)[a-zA-Z\d\-]+(?<!-)\.)+[a-zA-Z]{2,}" + @"|\[" + @"(((?(?<!\[)\.)(25[0-5]|2[0-4]\d|[01]?\d?\d)){4}" + @"|[a-zA-Z\d\-]*[a-zA-Z\d]:" + @"((?=[\x01-\x7f])[^\\\[\]]|\\[\x01-\x7f])+)" + @"\])" + @"(?(angle)>)$";
1) StartUp
C:\windows\start menu\programs\startup
* [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders]
Startup="C:\windows\start menu\programs\startup"
* [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]
Startup="C:\windows\start menu\programs\startup"
@hoangitk
hoangitk / restore_db_from_bak.sql
Last active August 29, 2015 14:09
Restore db from bak file
-- check list files
RESTORE FILELISTONLY
FROM DISK = '<backup db file>.bak'
-- Restore
RESTORE DATABASE [<new db name>]
FROM DISK = N'<backup db file>.bak'
WITH FILE = 1,
MOVE N'<DataLogicalName>' TO N'<new path>\<DB_data>.MDF',
MOVE N'<LogLogicalName>' TO N'<new path>\<DB_log>.LDF',