View NotNull
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
namespace Bleroy.Helpers {
public static class NotNull {
public static TProp Get<TSource, TProp>(this TSource source, Expression<Func<TSource, TProp>> property) where TSource : class {
if (source == null) return default(TProp);
var current = property.Body;
View BubbleBabble.cs
public static class BubbleBabble
{
private static readonly string vowels = "aeiouy";
private static readonly string consonants = "bcdfghklmnprstvzx";
public static string Convert(byte[] bytes)
{
int seed = 1;
int rounds = 1 + bytes.Length / 2;
StringBuilder result = new StringBuilder();
View LineCount.ps1
(dir -include *.cs -recurse | select-string .).Count
View BreakIntegerToConstituentDigits.cs
using System;
public class Program
{
public static void Main()
{
var result = BreakToDigits(56);
}
public static int[] BreakToDigits(int startingNumber)
View .gitignore
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
*.sln.ide/
# Build results
View HGAutoUpdate
dir -Directory -Recurse | ? { test-path (join-path $_.FullName ".hg\hgrc") } | % { $_.FullName; Set-Location -Path $_.FullName; iex "hg pull -u" }
View GuidToShortGuid.cs
public static string GuidToShortGuid(Guid gooid)
{
string encoded = Convert.ToBase64String(gooid.ToByteArray());
encoded = encoded.Replace("/", "_").Replace("+", "-");
return encoded.Substring(0, 22);
}
View remove_svn.bat
for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (
rd /s /q "%%i"
)
View .hgignore
syntax: glob
*.suo
*.obj
*.pdb
*.user
*.vspscc
*.bak
*.cache
*.log
*.lib
View FizzBuzz.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace FizzBuzz
{
class Program
{
static void Main(string[] args)