Skip to content

Instantly share code, notes, and snippets.

// https://go.dev/play/p/lrWohXeh1vG
// https://goplay.tools/snippet/lrWohXeh1vG
func getOsDefaultEditor() string {
switch runtime.GOOS {
case "darwin":
return "textedit"
case "linux", "freebsd", "netbsd", "openbsd":
return "vi"
case "windows":
@algonzalez
algonzalez / RegexPatterns.cs
Created August 21, 2023 20:55
SSN Validation Regex
public class RegexPatterns
{
/// <summary>
/// Regular expression used to validate an US Social Security Number (SSN)
/// formatted as nine-digits with hyphens (###-##-####).
/// </summary>
/// <example>
/// <code>
/// var ssnRegex = new Regex(RegexPatterns.Ssn);
/// ssnRegex.IsMatch("078-05-1120"); // should return false
[core]
editor = \"C:\\Users\\Alberto.Gonzalez\\tools\\VSCode\\Code.exe\" --wait
[diff]
tool = winmerge
[merge]
tool = winmerge
[difftool "diffmerge"]
cmd = $USERPROFILE/tools/DiffMerge/sgdm.exe \"$LOCAL\" \"$REMOTE\"
prompt = false
@algonzalez
algonzalez / .editorconfig
Last active October 6, 2021 00:53
Basic .editorconfig with some .NET rules
# see http://editorconfig.org/ for details
# top-most EditorConfig file; stops searching parent directories.
root = true
# Defaults: UTF-8, Windows-style newline,
# 4 space indents,
# newline ending every file,
# trim trailing whitespace
[*]
/// <summary>
/// Initial attempt at a simple <see cref="System.Text.Json.Serialization.JsonConverter"/>
/// that handles conversion between objects and interfaces.
/// <p>
/// Appears to fix the loss of interface typed values during serialization,
/// as well as the "Deserialization of interface types is not supported" exception.</p>
/// </summary>
/// <example>
/// // Register the converter with a <see cref="System.Text.Json.JsonSerializerOptions"/> instance:
/// <pre><code>var converter = new ObjectInterfaceJsonConverter&lt;IFoo, Foo&gt;();
@algonzalez
algonzalez / git-loglive
Last active March 23, 2021 18:08 — forked from tlberglund/git-loglive
Log Live Git Command
#!/bin/bash
while :
do
clear
git --no-pager log --graph --pretty=oneline --abbrev-commit --decorate --all $*
sleep 1
done
@algonzalez
algonzalez / ShowWiFiInfo.bat
Created February 17, 2015 16:20
Current Wi-Fi connection Info
rem display current Wi-Fi connection info including SSID
netsh wlan show interface
rem display more details of current Wi-Fi connection
rem NOTE: replace {SSID} with value from found with previous command
netsh wlan show profiles name={SSID}
rem same as above, but includes the password
netsh wlan show profiles name={SSID} key=clear
@algonzalez
algonzalez / vs.config.usingWinMerge
Last active August 29, 2015 14:14
Configure Visual Studio User Tools to use WinMerge
// To Compare
Extensions: .*
Operation: Compare
Command: C:\Program Files (x86)\WinMerge\WinMergeU.exe
Arguments: /maximize /e /u /wl /dl %6 /dr %7 %1 %2
// To Merge
Extensions: .*
Operation: Merge
Command: C:\Program Files (x86)\WinMerge\WinMergeU.exe
@algonzalez
algonzalez / CloneFromTfsToGit.cmd
Created January 28, 2015 20:43
Using Git-TF to clone a project from TFS to Git
rem Git-TF can be found here https://gittf.codeplex.com/
rem call "{path to git-tf}\git-tf help clone" for available command options
{path to git-tf}\git-tf clone {project collection URL} {project path to be cloned} {target directory for clone} --deep --no-tag
rem example:
rem git-tf clone http://tfs:8080/tfs/DefaultCollection $/some_project c:\dev\some_project.git --deep --no-tag
rem -----
rem alternative: see https://github.com/git-tfs/git-tfs