Skip to content

Instantly share code, notes, and snippets.

cd ~/source/myapp/ui
$files = (ll -r *.yml | sls -SimpleMatch 'APPOFFICEODATA_URL');
$files
#$files2 = $files[8..14]
#foreach ($f in $files2) {
foreach ($f in $files) {
sed -i "$($f.LineNumber - 1) a\ - APPDATA_URL=/myapp/admin" $f.Path | tee.exe -a sed-log.log;
echo (" APPDATA_URL added to "+$f.Path) | tee.exe -a sed-log.log;
@yzorg
yzorg / vscode.md
Created May 19, 2023 13:36
VSCode notes, yzorg

my VSCode notes

regex in VSCode

  • (?<!/)MIDOFFICE
    • only match if there is NOT a slash (/) before the match (i.e. don't match URLs)
  • (?<=- "?)MIDOFFICE
    • trying to match kustomize env var literal

extensions I really like

@yzorg
yzorg / CsvWriterCounter.cs
Last active April 4, 2023 16:50
For counting CSV rows. Helpful when querying with EF Core .AsAsyncEnumerable().
using System.Globalization;
using CsvHelper;
//namespace AppFoo;
// Counts rows. Helps when streaming to CSV from query that uses EF Core `.AsAsyncEnumerable()`.
public class CsvWriterCounter : CsvWriter
{
int _counter;
$fromDir='/code/repo01'; cd $fromDir
$todir='../repo02';
git diff --name-only --cached | %{ cp $_ (join-path $todir $_) -WhatIf } # WhatIf shows what it will do
Read-Host -Prompt 'Press any key to continue or CTRL+C to quit';
git diff --name-only --cached | %{ cp $_ (join-path $todir $_) -v }
@yzorg
yzorg / git-cp-ahmed.sh
Created March 30, 2023 15:58
copy GIT changed files to new folder
#!/bin/sh
# by ahmed on SO, https://stackoverflow.com/a/74122351/195755, NOT by @yzorg
FILES=`git ls-files --modified`
export_dir="place your export dir"
for x in $FILES
do
prev_dir=$PWD
folder=$(dirname $x)
echo "Exporting to..." $export_dir/$x
cp $prev_dir/$x $export_dir/$x
@yzorg
yzorg / set-win-resize-border-100.ps1
Created February 10, 2023 17:13
Make Win10/Win11 window borders a bit easier to resize. Key is from https://superuser.com/a/1767917/31557
# reg key is from https://superuser.com/a/1767917/31557
$BorderWidthValue = -100
#$BorderWidthValue = -200 # uncomment this to make them really wide, @yzorg likes -100 so kept that default
# make a backup of current value
pushd ~\Documents
reg export 'HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics' .\registry-WindowMetrics-old.reg
pushd ('HKEY_CURRENT_USER\Control Panel\Desktop' -replace 'HKEY_CURRENT_USER','HKCU:')
@yzorg
yzorg / convert-utf8.sh
Last active January 27, 2023 18:35
find all UTF-16 files and convert to UTF-8
#!/bin/bash
# see https://gist.github.com/yzorg/e4e9813fc07bef4af10ae43febca38d9
# function to convert file to UTF-8
convert_to_utf8() {
iconv -f UTF-16 -t UTF-8 "$1" -o "$1".utf8
mv "$1".utf8 "$1"
}
# output the list before making the 1st change
@yzorg
yzorg / Program.cs
Last active June 11, 2021 16:31
simplest k8s Main()
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Middle.MyApp
{
@yzorg
yzorg / note.md
Created September 15, 2020 15:53
OData in Core 3.1 - route confusion
@yzorg
yzorg / Index.cshtml
Created February 19, 2020 00:46
ASP.NET Core Razor Page - Paging
<h1>Index</h1>
<form method="get">
<p>
page @Model.PageNumber of @Model.TotalPages,
showing @Math.Min(Model.PageSize, Model.Count) of @Model.Count rows
</p>
<button type="button" class="btn btn-dark"
@Html.DisabledIf(Model.PageNumber <= 1)