Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Marc Bruins MarcBruins

🏠
Working from home
View GitHub Profile
@MarcBruins
MarcBruins / returnullfornull.cs
Created Dec 16, 2018
Returning null for null Uri
View returnullfornull.cs
public static Uri EnsureTrailingSlash(Uri uri)
{
if (uri == null)
return null;
return new Uri(uri.ToString() + "/");
}
View fixreturningnull.cs
public static IReadOnlyCollection<string> FirstPopulatedList(List<string> list1, List<string> list2)
{
if (HasElements(list1))
return list1;
if (HasElements(list2))
return list2;
return new List<string>();
}
@MarcBruins
MarcBruins / returnnull.cs
Last active Dec 16, 2018
Returning null
View returnnull.cs
public static IReadOnlyCollection<string> FirstPopulatedList(List<string> list1, List<string> list2)
{
if (HasElements(list1))
return list1;
if (HasElements(list2))
return list2;
return null;
}
@MarcBruins
MarcBruins / Pullrequestinitliazeproperty.cs
Created Dec 16, 2018
PullRequest initialize property explicitly
View Pullrequestinitliazeproperty.cs
public class PullRequestRequest
{
public PullRequestRequest(string body)
{
Body = body;
}
public string Body { get; set; }
}
@MarcBruins
MarcBruins / pullrequestnullable.cs
Created Dec 16, 2018
PullRequest with nullable property
View pullrequestnullable.cs
public string Body? { get; set; }
@MarcBruins
MarcBruins / pullrequestreqeust.cs
Created Dec 16, 2018
PullRequest not nullable property
View pullrequestreqeust.cs
public class PullRequestRequest
{
public PullRequestRequest()
{
}
public string Body { get; set; }
}
@MarcBruins
MarcBruins / fixnullablecontstructorparams.cs
Created Dec 16, 2018
Fix nullable constructor params
View fixnullablecontstructorparams.cs
public class AuthSettings
{
public AuthSettings(Uri apiBase, string token, string? username)
{
Username = username;
//Handle other params
}
public string? Username { get; }
}
@MarcBruins
MarcBruins / nullablecontructorparam.cs
Last active Dec 16, 2018
Nullable contructor parameter
View nullablecontructorparam.cs
public class AuthSettings
{
public AuthSettings(Uri apiBase, string token, string username = null)
{
ApiBase = apiBase;
Token = token;
Username = username;
}
}
View .hyper.js
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
View MyViewSource.cs
public class MyViewSource : MBAutoCompleteViewSource
{
private ICollection<string> _suggestions;
private string _cellIdentifier = "CellId";
public override void NewSuggestions(ICollection<string> suggestions)
{
_suggestions = suggestions;
}
You can’t perform that action at this time.