This file contains hidden or 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
function Test-IsOnline { | |
param([Alias('t', 'timeout', 'timeout-secs')][int] $timeout_secs) | |
$urls = 'https://google.com/generate_204', ` | |
'http://google.com/generate_204', ` | |
'https://edge-http.microsoft.com/captiveportal/generate_204', # not sure if MS supports https? | |
'http://edge-http.microsoft.com/captiveportal/generate_204', ` | |
'https://connectivity-check.ubuntu.com', ` | |
'https://connectivity-check.ubuntu.com' | |
$okcodes = '204', '200' # above URLs should always return 204 | |
if ($timeout_secs -lt 0) { $timeout_secs = 0 } |
This file contains hidden or 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
# Returns a string with the version of the installed Windows Terminal. | |
# Using `winget list` since the `wt --version` uses a dialog box. | |
# | |
# Usage: | |
# Get-WTVersion [-IncludeBuildNoAs LOCATION] | |
# | |
# Options: | |
# -IncludeBuildNo LOCATION: This option includes the build number at the | |
# specified LOCATION. Alias: -b LOCATION | |
# if 'none' returns the default "major.minor.patch" |
This file contains hidden or 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
# ---------------------------------------- | |
# Command: Start-Scratchpad (Written in PowerShell 7) | |
# Used in my daily script to open a new scratchpad file for the day. | |
# File naming follows the following format: ~/.scratch/yyyy-MM-dd-scratchpad.md | |
# ---------------------------------------- | |
# Includes code for Get-Editor and Get-TerminalEditor dependencies | |
# ---------------------------------------- | |
# Returns the editor specified in the VISUAL or EDITOR environment variables. | |
# If none is specified, a platform default is returned. |
This file contains hidden or 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
# ============================================================================== | |
# Justfile implementation of the Go project makefile from Alex Edwards: | |
# https://www.alexedwards.net/blog/a-time-saving-makefile-for-your-go-projects | |
# Notes: | |
# - I'm a newbie in both Go and justfiles, so let me know what can be improved | |
# - should be cross-platform, but only tested in Windows and Ubuntu under WSL | |
# - confirm task is not needed as it is built-in using [confirm] attribute | |
# - removed the `-race` argument in the test targets; | |
# it requires CGO_ENABLED=1 (at least on Windows). | |
# - commented out the `upx` call in the deploy target; I don't currently use it. |
This file contains hidden or 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
// 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": |
This file contains hidden or 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 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 |
This file contains hidden or 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
[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 |
This file contains hidden or 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
# 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 | |
[*] |
This file contains hidden or 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
/// <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<IFoo, Foo>(); |
This file contains hidden or 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
#!/bin/bash | |
while : | |
do | |
clear | |
git --no-pager log --graph --pretty=oneline --abbrev-commit --decorate --all $* | |
sleep 1 | |
done |
NewerOlder