Skip to content

Instantly share code, notes, and snippets.

View andli's full-sized avatar

Andreas andli

  • Sectra
  • Sweden
View GitHub Profile
@andli
andli / pwshnice.ps1
Created November 23, 2021 15:16
PowerShell nice2have
# alias to command with params
Function checkprom {Invoke-WebRequest -Uri http://10.33.18.192:8800/ | Select-Object -Expand Content}
Set-Alias -Name check -Value checkprom
@andli
andli / ohmyposhv3-anehs.json
Created November 23, 2021 10:50
ohmyposhv3-anehs.json
{
"final_space": true,
"console_title": true,
"console_title_style": "folder",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 0,
@andli
andli / Microsoft.PowerShell_profile.ps1
Last active December 8, 2021 13:12
Microsoft.PowerShell_profile.ps1
Import-Module -Name Terminal-Icons
Import-Module oh-my-posh
oh-my-posh --init --shell pwsh --config ~/ohmyposhv3-anehs.json | Invoke-Expression
# Aliases
Function touch ([string]$filename) {
$null > $filename
}
@andli
andli / switcheroo.ahk
Created December 31, 2020 23:21
Autohotkey script to switch screen for two named apps
#SingleInstance Force
#SC029::
MMPrimDPI := 1.0 ;DPI Scale of the primary monitor (divided by 100).
MMSecDPI := 1.0 ;DPI Scale of the secondary monitor (divided by 100).
SysGet, MMCount, MonitorCount
SysGet, MMPrimary, MonitorPrimary
SysGet, MMPrimLRTB, Monitor, MMPrimary
WinGetPos, MMWinGetX, MMWinGetY, MMWinGetWidth, MMWinGetHeight, A
MMWinGetXMiddle := MMWinGetX + (MMWinGetWidth / 2)
@andli
andli / provision.ps1
Last active February 5, 2022 11:28
New workstation win10
# Step 0, manually:
# * Install new Edge
# * Install new Terminal from windows store
# "colorScheme": "One Half Dark"
# "fontFace": "Fira Code"
# * Add OneDrive work account
# * Add OneDrive personal account to get keepass database
# Get scoop
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
@andli
andli / .bash_profile
Created August 27, 2019 09:05
SSH agent in bash
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
}
(Get-FileHash .\file.zip -Algorithm sha256).Hash -eq 'XXXXXX'
@andli
andli / scripts.ahk
Last active January 27, 2022 14:07
My AutoHotKey script collection
#Requires AutoHotkey v2-
#SingleInstance force
;#Warn All, Off
; Type some characters that are not easily available on your keyboard.
:?*:,oe::ø
:?*:,OE::Ø
; Mutes an MS Teams meeting by sending ctrl-shift-m to it. Needs to be focused to work.
Scrolllock::
@andli
andli / showseriesdatalabels.vba
Created May 10, 2019 13:27
Edit all data labels in an Excel graph to show series name
Sub datalabels()
For Each myChart In ActiveSheet.ChartObjects
For Each mySrs In myChart.chart.SeriesCollection
With mySrs
If Not .HasDataLabels Then
.ApplyDataLabels
End If
.datalabels.ShowSeriesName = True
#!/bin/bash
IF=$1
if [ -z "$IF" ]; then
IF=`ls -1 /sys/class/net/ | head -1`
fi
RXPREV=-1
TXPREV=-1
echo "Listening $IF..."
while [ 1 == 1 ] ; do
RX=`cat /sys/class/net/${IF}/statistics/rx_bytes`