In a previous blog post I detailed how you can speed up array access in certain cases. This time I’m taking a look at what is happening when we access arrays in .Net, and digging into why multidimensional arrays are slow. First a quick refresher on array types. Array This is just a standard array. But in the… Read More »
In .Net memory access is safe by default. This means that every time you access an array item the index is checked against the length of the array. In this post I explore how you can speed up plain old array access by allowing the compiler to prove that you will do no harm. I compile the C#… Read More »
Automatically unlock encrypted volumes in QNAP via network using a BASH-script in a Cron-job. This script will log on, list locked drives and unlock them. Data stored on the disks are encrypted, and you need a key do access the disks. The key is kept in memory, so if power is lost the disks are no longer unlocked.… Read More »
If you have used async/await, but feel some details are still a bit fuzzy then this may be for you. I thought I’d hop down into the rabbit hole and give some examples of how async/await actually works. Hopefully this will provide some understanding and get you further on your journey to become an expert. Async/await is a… Read More »
PowerShell script to recursively recompress ZIP-files with higher compression. Note that Deflate64 isn’t strictly zip standard afaik, but it works for most zip applications.
Remove-Item temp -Recurse -Force -Confirm:$false -ErrorAction Ignore
foreach ($file in $(gci -Recurse *.zip))
Write-Host "Extract $($file.Name)" -ForegroundColor Green
& "C:\Program Files\7-Zip\7z.exe" x "$($file.FullName)" -y
Write-Host "Compress $($file.Name)" -ForegroundColor Green
Remove-Item $file -Recurse -Force -Confirm:$false
& "C:\Program Files\7-Zip\7z.exe" a "$($file.FullName)" -y -tzip -sdel -slp -aoa -mx=9 -mm=Deflate64 -mfb=257 -mmt=on -mpass=15
Remove-Item temp -Recurse -Force -Confirm:$false
$totalSaved += $before - $after
Write-Host "$($file.Name) bytes saved: $($before - $after)." -ForegroundColor Yellow
Write-Host "Total bytes saved by recompressing $($fileCount) files: $($totalSaved)" -ForegroundColor Yellow
Response cache is fine for simpler operations, but sometimes you need more fine grained control. System.Runtime.Caching.MemoryCache has builtin support for in-memory cache with expiry.
ASP.NET Core comes with built-in support for response caching. Unlike cache-control header that tells client/proxies how long to cache data, the response cache will cache output of an action.
Whether writing stand alone application or web application you may want to put database related code into a separate project. I find it good for separating concerns.