Skip to content

Instantly share code, notes, and snippets.

View grenade's full-sized avatar

rob thijssen grenade

View GitHub Profile
@grenade
grenade / Add-WindowTransparencyToProfile.ps1
Last active January 5, 2024 08:25
make powershell and cmd terminals transparent
if (-not Test-Path -Path $profile) { New-Item -path $profile -type file -force }
Add-Content -Path $profile -Value '$user32 = Add-Type -Name ''User32'' -Namespace ''Win32'' -PassThru -MemberDefinition ''[DllImport("user32.dll")]public static extern int GetWindowLong(IntPtr hWnd, int nIndex);[DllImport("user32.dll")]public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);[DllImport("user32.dll", SetLastError = true)]public static extern bool SetLayeredWindowAttributes(IntPtr hWnd, uint crKey, int bAlpha, uint dwFlags);'''
Add-Content -Path $profile -Value 'Get-Process | Where-Object { @(''powershell'', ''cmd'') -contains $_.ProcessName } | % { $user32::SetWindowLong($_.MainWindowHandle, -20, ($user32::GetWindowLong($_.MainWindowHandle, -20) -bor 0x80000)) | Out-Null;$user32::SetLayeredWindowAttributes($_.MainWindowHandle, 0, 200, 0x02) | Out-Null }'

How to build firefox on Windows

@grenade
grenade / PowerShellLsaWrapper.cs
Last active November 28, 2019 08:46
Grant privileges needed by sshd user for key based auth and impersonation. See also: http://www.ehow.com/how_10069214_configure-sshd-cygwin.html, https://cygwin.com/ml/cygwin/2008-08/msg00155.html
using System;
using System.Collections.Generic;
using System.Text;
namespace PowerShellLsaWrapper {
using System.Runtime.InteropServices;
using System.Security;
using System.Management;
using System.Runtime.CompilerServices;
using System.ComponentModel;
@grenade
grenade / taskbarpin.ps1
Created March 31, 2016 10:34
pin stuff to the windows taskbar from powershell
((New-Object -c Shell.Application).Namespace('{0}\system32' -f $env:SystemRoot).parsename('cmd.exe')).InvokeVerb('taskbarpin')
@grenade
grenade / Get-DiskPartitions.ps1
Last active August 19, 2025 23:25
get disk, partition, drive info in powershell...
function Get-DiskPartitions {
$partitions = Get-WmiObject -Class Win32_DiskDriveToDiskPartition | % {
$dDep = $_.Dependent
$p = Get-WmiObject -Class Win32_DiskPartition | Where-Object { $_.Path.Path -eq $dDep }
$d = Get-WmiObject -Class Win32_LogicalDiskToPartition | Where-Object { $_.Antecedent -in $dDep } | % {
$lDep = $_.Dependent
Get-WmiObject -Class Win32_LogicalDisk | Where-Object { $_.Path.Path -in $lDep }
}
New-Object PSObject -Property @{
Drive = if ($d -eq $null) { $null } else { $d.DeviceID };
function Write-Log {
<#
.Synopsis
Logs to the userdata run log file, with timestamps.
.Parameter message
The body of the log message
.Parameter severity
The severity of the message, to enable filtering in log aggregators or reporting.
.Parameter path
The full path to the log file.
@grenade
grenade / fedora-git-upgrade.sh
Created March 26, 2016 11:14
Upgrade git to 2.7.4 on Fedora 23
sudo dnf erase -y git
sudo dnf install -y curl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel asciidoc xmlto docbook2X
sudo ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi
wget https://www.kernel.org/pub/software/scm/git/git-2.7.4.tar.gz
wget https://www.kernel.org/pub/software/scm/git/git-2.7.4.tar.sign
gpg2 --keyserver gpg.mozilla.org --recv-keys 96AFE6CB
gunzip git-2.7.4.tar.gz
gpg2 --verify git-2.7.4.tar.sign git-2.7.4.tar
:: Taskcluster friendly wrapper for performing fx desktop builds via mozharness.
:: Inputs, with defaults
::if not defined MOZHARNESS_SCRIPT set MOZHARNESS_SCRIPT=mozharness\scripts\fx_desktop_build.py
::if not defined MOZHARNESS_CONFIG set MOZHARNESS_CONFIG=builds\releng_base_windows_64_builds.py
if not defined TOOLTOOL_CACHE set TOOLTOOL_CACHE=%SystemDrive%\home\worker\tooltool-cache
if not defined NEED_XVFB set NEED_XVFB=false

solution: provisioner should handle this by only spinning up instances as required. Still need to understand why all y-2012 instances stay up always.

@grenade
grenade / impersonate.go
Created February 8, 2016 11:07 — forked from kostix/impersonate.go
A demonstration example for http://stackoverflow.com/a/26124494
// A demonstration example for http://stackoverflow.com/a/26124494
// It runs a goroutine locked to an OS thread on Windows
// then impersonates that thread as another user using its name
// and plaintext password, then reverts to the default security
// context before detaching from its OS thread.
package main
import (
"log"
"runtime"