Skip to content

Instantly share code, notes, and snippets.

View schittli's full-sized avatar

Tom-- schittli

  • Biel / Bienne, Switzerland
  • 06:24 (UTC +02:00)
View GitHub Profile
@Jaykul
Jaykul / Set-CodeCmd.ps1
Last active March 7, 2018 19:21
This makes it so you can type just `code` to start VS Code (even Insiders) in the current folder, even ... in Explorer!
#requires -RunAsAdministrator
<#
.Synopsis
Creates (or alters) a "code" command for opening Visual Studio Code (or VS Code Insiders)
.Description
Recreates the "code.cmd"" batch file command that starts Visual Studio Code (or VS Code Insiders)
1. Adds logic to make it open in the current folder if you don't pass parameters.
2. Makes "code" work as a command in Windows 10 Explorer's address bar.
#>
[CmdletBinding()]
@mklement0
mklement0 / Select-StringAll.ps1
Last active April 24, 2021 13:19
PowerShell function that wraps the Select-String cmdlet with conjunctive matching (ALL search patterns must match).
<#
Prerequisites: PowerShell v3+
License: MIT
Author: Michael Klement <[email protected]>
DOWNLOAD and INSTANT DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/356acffc2521fdd338ef9d6daf41ef07/raw/Select-StringAll.ps1 | iex
@Jaykul
Jaykul / SelfCleaningJob.ps1
Last active April 8, 2018 01:35 — forked from anonymous/SelfCleaningJobs.ps1
Self-cleaning jobs make more jobs to clean themselves up!
function New-SelfCleaningJob {
param(
$Name=$([Guid]::NewGuid().Guid)
)
$job = Start-Job -Name $Name { 1..10 | % { Write-Output $_ } }
$jobCleanup = Register-ObjectEvent $job -EventName StateChanged -Action {
if($EventArgs.JobStateInfo.State -eq "Completed") {
# Note this prints to host no matter what's going on right now ....
Receive-Job $Sender | out-host
@kootenpv
kootenpv / github_orgy.py
Last active December 13, 2017 07:55
As it is impossible to find out about new repos created by an org, this awkwardly named script exists.
""" github_orgy -- monitor github organizations for new repos.
Usage:
python3.5 github_orgy.py deepmind tensorflow facebookresearch google watson-developer-cloud
Or with cron:
@hourly /usr/bin/python github_orgy.py deepmind tensorflow facebookresearch google watson-developer-cloud
"""
import time
import os
@GaliTW
GaliTW / sniper.ahk
Last active December 23, 2021 23:17
AutoHotKey's script for Sniper Mode(Left Windows Key + N Key)
; Example: This is a hotkey that temporarily reduces the mouse cursor's speed, which facilitates precise positioning.
; Hold down the Hot key to slow down the cursor. Release it to return to original speed.
LWin & n::
SPI_GETMOUSESPEED = 0x70
SPI_SETMOUSESPEED = 0x71
; Retrieve the current speed so that it can be restored later:
DllCall("SystemParametersInfo", UInt, SPI_GETMOUSESPEED, UInt, 0, UIntP, OrigMouseSpeed, UInt, 0)
; Now set the mouse to the slower speed specified in the next-to-last parameter (the range is 1-20, 10 is default):
DllCall("SystemParametersInfo", UInt, SPI_SETMOUSESPEED, UInt, 0, UInt, 10, UInt, 0)
@mklement0
mklement0 / Out-FileUtf8NoBom.ps1
Last active May 2, 2025 01:58
PowerShell function that emulates Out-File for creating UTF-8-encoded files *without a BOM* (byte-order mark).
<#
Prerequisites: PowerShell version 3 or above.
License: MIT
Author: Michael Klement <[email protected]>
DOWNLOAD and DEFINITION OF THE FUNCTION:
irm https://gist.github.com/mklement0/8689b9b5123a9ba11df7214f82a673be/raw/Out-FileUtf8NoBom.ps1 | iex
The above directly defines the function below in your session and offers guidance for making it available in future
@MarkTiedemann
MarkTiedemann / download-latest-release.ps1
Last active January 5, 2025 10:28
Download latest GitHub release via Powershell
# Download latest dotnet/codeformatter release from github
$repo = "dotnet/codeformatter"
$file = "CodeFormatter.zip"
$releases = "https://api.github.com/repos/$repo/releases"
Write-Host Determining latest release
$tag = (Invoke-WebRequest $releases | ConvertFrom-Json)[0].tag_name
@jdhitsolutions
jdhitsolutions / Add-Border.ps1
Last active March 10, 2022 02:41
Insert a text-based border around a string in PowerShell
#add a border around a string of text
Function Add-Border {
<#
.Synopsis
Create a text border around a string.
.Description
This command will create a character or text based border around a line of text. You might use this to create a formatted text report or to improve the display of information to the screen.
# From PowerShell ADMINISTRATOR session run
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
# Open new PowerSheel Administrator session and run
# $cred=Get-Credential domain\username (can also use [email protected] MSA style username)
# Install-BoxstarterPackage -PackageName https://gist.githubusercontent.com/tylergibson/bd7a4c923db6bc0bd0a3ca05473dd4f7/raw -Credential $cred
# Initialize reboot log file
$reboot_log = "C:\installation.rbt"
if ( -not (Test-Path $reboot_log) ) { New-Item $reboot_log -type file }
@mklement0
mklement0 / New-EncodingTestFiles.ps1
Last active August 16, 2022 08:18
PowerShell scripts for creating and reading test files with the standard Unicode character encoding schemes and default encodings.
<#
.SYNOPSIS
Creates test text-based files with various character encodings.
.DESCRIPTION
Creates text-based test files using
* all 5 byte order-marked Unicode character encoding schemes,
both with and without BOM (Unicode signature)
* default encodings,
with the the platform's default encoding, [System.Text.Encoding]::Default