This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace IssuesList | |
{ | |
using System; | |
using System.Linq; | |
using System.IO; | |
using System.Reflection; | |
using Newtonsoft.Json; | |
class Program | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class EnumerableExtensions | |
{ | |
public static IEnumerable<T> NullToEmpty<T>(this IEnumerable<T> items) | |
{ | |
return items ?? Enumerable.Empty<T>(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Result | |
{ | |
private const int UNKNOWN_STATUS_CODE = -1; | |
private const string UNKNOWN_STATUS_PHRASE = @"WAT?"; | |
public static Result<t> Success(T result = default(T)) | |
{ | |
return Result<t>.Success(new[] { result }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyCoolService | |
{ | |
public Result<CoolThing> Fetch(Uri uri) | |
{ | |
HttpResponseMessage response = CallThatThingInTheCloud(uri); | |
return response.IsSuccessStatusCode | |
? Result<CoolThing>.Success(Deserialize(response)) | |
: Result<CoolThing>.Error(response.StatusCode, response.ReasonPhrase); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Result<T> | |
{ | |
public bool IsSuccess { get; private set; } | |
public string ErrorMessage { get; private set; } | |
public IEnumerable<T> Results { get; private set; } | |
private Result() | |
{ } | |
public static Result<T> Success(IEnumerable<T> results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyCoolService | |
{ | |
public Result<CoolThing> Fetch(Uri uri) | |
{ | |
HttpResponseMessage response = CallThatThingInTheCloud(uri); | |
if (response.IsSuccessStatusCode) | |
{ | |
return new Result<CoolThing> | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Result<T> | |
{ | |
public bool IsSuccess { get; set; } | |
public string ErrorMessage { get; set; } | |
public IEnumerable<T> Results { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyTestsExplicit | |
{ | |
public void RunOnlyOnDemand() | |
{ | |
throw new Exception("You ran me on purpose, didn't you?"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sweep | |
// by BARRAGAN <http://barraganstudio.com> | |
// This example code is in the public domain. | |
#include <Servo.h> | |
Servo myservo; // create servo object to control a servo | |
// a maximum of eight servo objects can be created | |
int pos = 0; // variable to store the servo position |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$WarningDuration = 5 | |
$MessagePlural = "" | |
if ($WarningDuration -gt 1) { $MessagePlural = "s" } | |
[System.Media.SystemSounds]::Asterisk.play() | |
[void] [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | |
[windows.forms.messagebox]::show(("Save your work. Sleep in {0} minute{1}." -f $WarningDuration, $MessagePlural)) | |
Start-Sleep -Second ($WarningDuration * 60) | |
[System.Media.SystemSounds]::Beep.play() |
NewerOlder