Skip to content

Instantly share code, notes, and snippets.

View diego-augusto's full-sized avatar
🎯
Focusing

Diego Augusto diego-augusto

🎯
Focusing
  • Campina Grande, Paraíba, Brazil
View GitHub Profile
package main
import (
"context"
"log"
"os"
"os/signal"
"sync"
"time"
)
@diego-augusto
diego-augusto / gs.go
Created July 30, 2022 05:23
Graceful Shutdown in Go
package main
import (
"context"
"log"
"os"
"os/signal"
"sync"
"time"
)
we, ok := err.(mongo.WriteException)
if ok {
if strings.Contains(we.WriteErrors.Error(), "E11000") {
if strings.HasPrefix(event.Data.Conversation.Protocol, "20220322") {
event.Data.Conversation.Protocol = replaceAtIndex(event.Data.Conversation.Protocol, '3', 8)
fmt.Printf("\nnew protocol: %s", event.Data.Conversation.Protocol)
err := handler(event)
if err != nil {
37fc3610-e82b-4e49-b3e3-2fecf60ee2fc
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "App",
"program": "${workspaceFolder}\\index.js",
"env": {
"NODE_ENV": "development",
try
{
_unitOfWork.Commit();
}
catch (DbEntityValidationException e)
{
_logger.Error($"Exception: {e.Message}");
_logger.Error($"Inner: {e.InnerException?.Message}");
_logger.Error($"StackTrace: {e.StackTrace}");
@diego-augusto
diego-augusto / CustomEnumDropDownListFor.cs
Created March 3, 2018 16:13
Custom DropDownListFor for nullable types
private static Type GetNonNullableModelType(ModelMetadata modelMetadata)
{
Type realModelType = modelMetadata.ModelType;
Type underlyingType = Nullable.GetUnderlyingType(realModelType);
if (underlyingType != null)
{
realModelType = underlyingType;
}
return realModelType;
@diego-augusto
diego-augusto / smart-merging-unity.md
Last active April 24, 2023 11:05
Smart Merging in Unity with Meld (Windows)
  1. In Unity, go to Edit > Project Settings > Edit > Asset Serialization > Mode and select Force Text.
  2. Add UnityYAMLMerge.exe in %PATH%. (C:\Program Files\Unity\Editor\Data\Tools)
  3. In .gitconfig (C:\Users<user>) add at the end of the file:
	[merge]
		tool = unityyamlmerge
	[mergetool "unityyamlmerge"]
		trustExitCode = false
		cmd = UnityYAMLMerge merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED"
@diego-augusto
diego-augusto / how-to-keystore.txt
Last active July 14, 2017 11:24
How to create a keystore and recover sha1 fingerprint
keytool -genkey -v -keystore release.keystore -alias example -keyalg RSA -keysize 2048 -validity 10000
keytool -list -v -keystore mykeystore.keystore -alias example -storepass example -keypass example