Skip to content

Instantly share code, notes, and snippets.

View pjmagee's full-sized avatar
🤨

Patrick Magee pjmagee

🤨
View GitHub Profile
public static void PerformAs<TOut>(this IEntity item, Action<TOut> perform) where TOut : class, IEntity
{
var conversionResult = item as TOut;
conversionResult.Perform(converted => perform(converted));
}
public static IEnumerable<T> OrEmptyIfNull<T>(this IEnumerable<T> source)
{
return source ?? Enumerable.Empty<T>();
@pjmagee
pjmagee / Client.cs
Created January 13, 2015 15:18
SendTimesheets
public int SendTimesheetsApprovalNotifications(DateTime weekEndingDate)
{
var items = new List<EmailQueueItem>();
var email = EmailTemplate.GenerateApprovalNotificationEmail();
// #28051 - There should only be notification if they can actually approve the timesheet, which means there must be hours entered.
var timesheets = FindTimesheetsOrCreate(weekEndingDate).Where(i => !i.IsApproved && i.EnteredHours > 0).ToList();
var branches = GetBranchesForTimesheets(timesheets);
branches.Do(branch => AddClientUsersForEmail(branch, email, items));
- Remove large scale code generation and replace with snippets.
- Remove Geeks Chat and replace with HipChat.
- More memory in dev machines.
- Flexible working hours.
- Remove GitBlit and replace with Github Enterprise edition.
- Remove Sanity and replace with Selenium C# based testing with Page Object Design Pattern, or Selenium IDE for non-programmer test engineers.
- Remove Geeks AMP and replace with JIRA, youTrack.
- Ability to remote work.
entryTemplate: '<li>{date} - <a href="{url}">{title}</a><br/>{shortBodyPlain}</li>',
<GUIProfile Version="1">
<TargetPortrait>
<anchorXOffset Type="3" Value="208.000000" />
<anchorAlignment Type="3" Value="8.000000" />
<anchorYOffset Type="3" Value="-213.000000" />
<scale Type="3" Value="1.000000" />
<enabled Type="2" Value="1" />
<alpha Type="3" Value="100.000000" />
<FlipHorizontal Type="2" Value="1" />
<EffectsOnBottom Type="2" Value="0" />
# PowerShell Execution policy needs to be changed to execute this script.
# Run Power shell as Admin and execute the following line
# Set-ExecutionPolicy -ExecutionPolicy Unrestricted
# Author: Patrick Magee
# Version 1.0.2
#
# PowerShell Tools for Visual Studio
# http://visualstudiogallery.msdn.microsoft.com/c9eb3ba8-0c59-4944-9a62-6eee37294597
# Useful variables
void Main()
{
#region Question 1
var numbers = new[] { 5, 2, 1, 3, 10, 16 };
numbers.Sum().Dump("Expecting:");
Func<int[], int> ForLoop = ((items) => {
void Main()
{
// Write code to test your extensions here. Press F5 to compile and run.
}
public static class Extensions
{
static Extensions()
{
Random r = new Random();
string alphabet = "abcdefghijklmnopqrstuvwyxzeeeiouea";
Func<char> randomLetter = () => alphabet[r.Next(alphabet.Length)];
Func<int, string> makeName =
(length) => new string(Enumerable.Range(0, length)
.Select(x => x==0 ? char.ToUpper(randomLetter()) : randomLetter())
.ToArray());
string first = makeName(r.Next(5) + 5);
string last = makeName(r.Next(7) + 7);
string company = makeName(r.Next(7) + 7) + " Inc.";
var watch = new Stopwatch();
var htmlString = "<div class='isc-content-block' data-contentmanagerid='60dd19b0-e3ba-4629-935c-a2dd00e052b8' data-contentmanagername='Product: B456009805'>456009806</div>";
var regex = new Regex(">(.*)</.*>", RegexOptions.None); // NORMAL REGEX
// REGEX START
watch.Start();
// WARM UP JITTER
for(int i = 0; i < 10000000; i++)