Skip to content

Instantly share code, notes, and snippets.

View hagbarddenstore's full-sized avatar

Kim Johansson hagbarddenstore

View GitHub Profile
var text = txtserver.Text;
if (!string.IsNullOrEmpty(text))
{
IpAddress ipAddress;
Uri url;
if (IpAddress.TryParse(text, out ipAddress))
{
// Valid IP
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Content Include="App.config">
<SubType>Designer</SubType>
</Content>
<Content Include="App.Base.config">
<DependentUpon>App.config</DependentUpon>
</Content>
<Content Include="App.Debug.config">
namespace Whoaverse.Models
{
using System;
using System.Collections.Generic;
public partial class Comment
{
public void Upvote(int userId)
{
}
interface EventStream
{
// Just a marker interface to let you know which classes are persisted.
}
class Site : EventStream
{
private readonly HashSet<string> _registeredUsers = new HashSet<string>();
public string Id { get; private set; }
// Domain
interface IUsersRepository
{
IEnumerable<User> FindAll(int pageIndex, int pageSize);
}
class User
{
public int Id { get; private set; }
public static string Replace(string input, string regex)
{
var match = System.Text.RegularExpressions.Regex.Match(regex, @"^s(.)(?<Regex>.*?)(?:(?<!\\)\1)(?<Replace>.*?)(?:(?<!\\)\1)$");
var replaced = Regex.Replace(input, match.Groups["Regex"].Value, match.Groups["Replace"].Value);
return replaced;
}
var order = allCalls.Select((number, index) => new
{
Number = number,
Duration = allDuration[index]
})
.GroupBy(x => x.Number)
.Select(x => new
{
Number = x.Key,
Count = x.Count(),
class Queries
{
public static readonly string FindPrices = @"
SELECT *
FROM prices
";
public static readonly string FindOneUserByUsername = @"
SELECT *
FROM users
interface IDependOn<T>
{
}
class A
{
}
class B
{
@hagbarddenstore
hagbarddenstore / Example.cs
Last active August 29, 2015 14:01
Example that removes the need for regions
interface IRepository<TEntity>
{
TEntity FindOne(Guid id);
void Save(TEntity entity);
}
interface IUsersRepository : IRepository<User>
{
User FindOneByUsername(string username);
}