Skip to content

Instantly share code, notes, and snippets.

@AKuederle
AKuederle / ahk_audio_changer.ahk
Last active August 29, 2015 14:14
Simple autohotkey script to select one of two audio devices under Windows. Bit clumsy, but it does its job. Inspiration from: www.autohotkey.com/board/topic/2306-changing-default-audio-device/page-4
#+*F6:: ; assign hotkey (windows+Shift+F6)
Run, mmsys.cpl
WinWait,Sound
ControlSend,SysListView321,{Down 1} ; By changing the number behind Down the audiodevice can be selcted
ControlClick,&Set Default
ControlClick,OK
return
#+*F7::
Run, mmsys.cpl
@AKuederle
AKuederle / get_path.ps1
Last active August 29, 2015 14:14
Get and refresh the currently avaible path inside a PowerShell session (usefull, when troubleshooting or installing things from the shell)
# prints the current path avaible in the PowerShell
function path
{
$curr = Get-Location
cd env:
(ls path).value.split(“;”)
cd $curr
}
@AKuederle
AKuederle / read-clipboard.ps1
Last active August 29, 2015 14:14
Functions to manipulate the clipboard from the PowerShell
function read-clipboard
{
PowerShell -NoProfile -STA -Command {
Add-Type -Assembly PresentationCore
[Windows.Clipboard]::GetText()
}
}
@AKuederle
AKuederle / git-finder.sh
Last active August 29, 2015 14:15
Find the name of all folders, which have a .git repo inside. Can be used to find the name sof all Git "Projects" on the machine
find ~ -type d -name .git | xargs -n 1 dirname | xargs -n 1 basename
@AKuederle
AKuederle / find_nearest.py
Created February 11, 2015 10:50
simple Python function to find the index of an array, which corrosponding value is nearest to a given float
def find_nearest(array, value):
return (np.abs(array - value)).argmin()
@AKuederle
AKuederle / textwidth.tex
Created February 11, 2015 11:31
Print the current textwidth inside your latex document
\the\textwidth
@AKuederle
AKuederle / auto_lock.sh
Created February 22, 2015 18:45
Lock the screen after 10 min of not using the PC when using xfce as a desktop enviroment. It has to be placed in .xinitrc.
xautolock -time 10 -notify 30 -notifier "notify-send 'Locking screen in 30 s' --icon=appointment" -locker xflock4
@AKuederle
AKuederle / gist:507f4d9a2fa00037ca69
Created June 28, 2015 23:12
Overwrite of powershell promt which works with gitposh and provides last argument and last command varibales
function global:prompt {
$realLASTEXITCODE = $LASTEXITCODE
$global:l = "$($(Get-History)[-1])"
$temp = "$($(Get-History)[-1])" -split " "
$global:lc = $temp[0]
$global:lp = $temp[1..($temp.length-1)]
# Reset color, which can be messed up by Enable-GitColors
$Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor
Write-Host($(Split-Path $pwd -Leaf)) -nonewline -foregroundcolor Blue
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AKuederle
AKuederle / hotkey.sh
Last active November 8, 2016 08:14
Get Windows like App Hotkey Start-up behavior. First Argument: Path to app. Second argument: App-class (wmctrl -lx)
#!/bin/bash
contains() {
[[ $1 =~ $2 ]] && return 0 || return 1
}
app_list=$(wmctrl -lx | awk '{print $3}')
if contains "$app_list" "$2";