Skip to content

Instantly share code, notes, and snippets.

View gitfvb's full-sized avatar
👋

Florian von Bracht gitfvb

👋
View GitHub Profile
@gitfvb
gitfvb / README.md
Last active June 1, 2022 18:41
First steps with Himalaya Matrix Core ESP32
@gitfvb
gitfvb / readme.md
Last active May 11, 2022 07:38
Raspberry Pi (raspi) helpful commands

Deactivate WIFI

Check your current network status with

ifconfig

If your wifi has an ip address, it is still connected and active. Deactivate it temporarily with

@gitfvb
gitfvb / Test-Credential.ps1
Created April 12, 2022 11:42
A script to test if the input credential is valid, because Get-Credential allows everything without validation. This script is maintained here https://github.com/Apteco/HelperScripts/tree/master/functions/Security
function Test-Credential {
[CmdletBinding()]
param (
[Parameter(
Mandatory = $false
,ValueFromPipeLine = $true
#,ValueFromPipelineByPropertyName = $true
)]
@gitfvb
gitfvb / readme.md
Last active March 12, 2022 21:25
Remove unnecessary windows apps, that are not installed by the user

To show all installed apps, use this

Get-AppxPackage -AllUsers * | Out-GridView

or something like

Get-AppxPackage -AllUsers * | Select Name, PackageFullName | ft
@gitfvb
gitfvb / queries.md
Last active January 10, 2022 15:14
Show last executed queries on sqlserver

Show last executed queries on sqlserver

SELECT deqs.last_execution_time AS [Time]
	,dest.TEXT AS [Query]
FROM sys.dm_exec_query_stats AS deqs
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
WHERE lower(dest.TEXT) LIKE '%binaries%'
ORDER BY deqs.last_execution_time DESC
@gitfvb
gitfvb / example.ps1
Last active December 22, 2021 17:03
Examples and snippets around PowerShell String encoding and convert it between different encodings
<#
# A helpful code snippet to change console encoding
# Change encoding of powershell console (this does not change [System.Text.Encoding]::Default
ping | Out-Null
# Change the console output to UTF8
$originalConsoleCodePage = [Console]::OutputEncoding.CodePage
[Console]::OutputEncoding = [text.encoding]::utf8
@gitfvb
gitfvb / example.ps1
Created December 10, 2021 16:48
Note about always returning arrays in powershell
<#
Sometimes it is hard to make sure a function passes an array back if it is only one element
With @( ) you can make sure you have an array, even with one element. But in the function to always return an array,
do something like below, inspired by https://evotec.xyz/powershell-returning-one-object-from-function-as-an-array/
#>
Function Do-Foo() {
# Check the installed capabilites
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
# Install OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
# Start service and set it automatically
Start-Service sshd
@gitfvb
gitfvb / readme.md
Created November 30, 2021 23:36
Using npgsql via powershell 5.1 with .net 4.x

Used the following files from nuget

        FileDescription                        CompanyName           FileVersionRaw
        ---------------                        -----------           --------------
        Microsoft.Bcl.AsyncInterfaces          Microsoft Corporation 4.700.20.21406
        Npgsql                                 Npgsql                4.0.12.0
        System.Buffers                         Microsoft Corporation 4.6.28619.1
        System.Memory                          Microsoft Corporation 4.6.28619.1
@gitfvb
gitfvb / readme.md
Last active November 18, 2021 17:23
calculate processing times in sqlite

if you have multiple columns and want to calculate the differences in seconds and milliseconds, a query like this can help to produce output like in the csv file in this gist.

This is the query

select
	"timestamp"
	,strftime('%f',julianday("inserted")-julianday("timestamp")) "Timestamp to inserted"
	,strftime('%f',julianday("response_calculated")-julianday("inserted")) "Response calculated"
	,strftime('%f',julianday("response_timestamp")-julianday("response_calculated")) "API Call finished"