Skip to content

Instantly share code, notes, and snippets.

View nmcc's full-sized avatar

Nuno Caneco nmcc

  • Philip Morris International
  • Lisbon, Portugal
View GitHub Profile
git log master --since="2019-01-01" --format="%ae" | sort | uniq -c | sort -nr
@nmcc
nmcc / git-aliases.sh
Created July 19, 2018 04:59
A set of useful aliases for git CLI
git config --global alias.co checkout
git config --global alias.cof "!f(){ teamName=$1; ticketNum=$2; git checkout \"features/${teamName}/${teamName}-${ticketNum}\"; }; f"
git config --global alias.cobf "!f(){ teamName=$1; ticketNum=$2; git checkout -b \"features/${teamName}/${teamName}-${ticketNum}\"; }; f"
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.ca "commit -a"
git config --global alias.st status
git config --global alias.unstage "reset HEAD --"
git config --global alias.last "log -1 HEAD"
git config --global alias.hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short"
@nmcc
nmcc / LazyExtensions.cs
Created June 5, 2017 08:02
Lazy<T> for IDisposable classes
public static class LazyExtensions
{
public static void Dispose<T>(this Lazy<T> target) where T : IDisposable
{
if (target?.IsValueCreated ?? false)
{
target.Value.Dispose();
}
}
}
@nmcc
nmcc / CONSOLAS.md
Last active March 12, 2024 07:57
Install Consolas font on Mac

Download and install the font

  1. Download the Consolas font from http://www.fontpalace.com/font-details/Consolas/
  2. Open Finder and navigate to Downloads directory
  3. Double click the Consolas.ttf file
  4. A dialog box appears displaying the details about the font
  5. Click Install font button

Using Consolas font on IntelliJ IDEA:

  1. Open IDEA Preferences Window (Press Command + ,)
  2. Editor > Colors & Fonts > Font
@nmcc
nmcc / MainSingleton.cs
Last active March 28, 2017 08:00
Singletin article - Main Singleton
var serviceProvider = new ServiceCollection()
.AddTransient<ImageStore>(...)
@nmcc
nmcc / MainTransient.cs
Created March 28, 2017 07:57
Singleton .NET Core - Main Transient
var serviceProvider = new ServiceCollection()
.AddTransient<ImageStore>((ctx) =>
{
var imageStore = new ImageStore();
for (int i = 0; i < 10; i++) imageStore.AddImage($"image_{i}", File.ReadAllBytes("potato.png"));
return imageStore;
})
.BuildServiceProvider();
@nmcc
nmcc / ImageStore.cs
Last active March 28, 2017 07:59
Singleton .NET Core
public class ImageStore
{
private readonly IDictionary<string, byte[]> imagemMap = new Dictionary<string, byte[]>();
public void AddImage(string name, byte[] imageContent) =>
this.imagemMap.Add(name, imageContent);
}