Skip to content

Instantly share code, notes, and snippets.

@omarrodriguez15
omarrodriguez15 / CoverScreen.ps1
Created July 30, 2022 13:53
Display a image full screen with a background gradient. (Purposefully include bug in this version for blog)
Add-Type -AssemblyName "System.Windows.Forms"
Add-Type -AssemblyName "System.Drawing"
$fileBytes = Get-Content -Encoding Byte 'C:\Users\rodri\Downloads\foo.jpg'
# $fileBytes = [Convert]::FromBase64String($fileContent)
$fileMemoryStream = [System.IO.MemoryStream]::new($fileBytes)
$imageStream = [System.Drawing.Image]::FromStream($fileMemoryStream)
[System.Windows.Forms.Application]::EnableVisualStyles()
$form = New-Object Windows.Forms.Form
$form.TopMost = $true
@omarrodriguez15
omarrodriguez15 / RevertAMerge.md
Created February 13, 2020 16:00
Reverts a git merge commit

Find the merge commit you want to revert

Look at the git log using git log --graph. In the commit message look at the Merge: section to check to see which parent tree you want to keep in the revert. Example commit message: (This was a commit from a feature branch into develop branch. develop branch is on the right 7c6b236 develop on the left 8989ee0)

commit 8f937c683929b08379097828c8a04350b9b8e183
Merge: 8989ee0 7c6b236
Author: Kirk James <kirk@enterprise.com>
Date: Wed Aug 17 22:49:41 2011 +0100
<?xml version="1.0" encoding="utf-8"?>
<obprofiles xmlns="http://www.logitech.com/Cassandra/2013.1/OnboardProfile">
<profile name="">
<device buttoncount="11" anglesnapping="0" powermode="1" model="Logitech.Gaming.Mouse.G602" reportrate="125">
<dpitable shift="500" defaultindex="2">
<dpi x="500" y="500"/>
<dpi x="1000" y="1000"/>
<dpi x="1500" y="1500"/>
<dpi x="2000" y="2000"/>
<dpi x="2500" y="2500"/>
BEGIN TRAN
UPDATE person
SET firstname='Omar'
OUTPUT deleted.*, inserted.*
where firstname='Omarr'
ROLLBACK TRAN
--OR
public static Dictionary<T, T> BuildPairwiseDcitionary<T>(this IEnumerable<T> lst)
{
var left = lst.Where((x, i) => i % 2 == 0);
var right = lst.Where((x, i) => i % 2 == 1);
return left
.Zip(right, (x, y) => new { Key = x, Value = y })
.ToDictionary(x => x.Key, y => y.Value);
}
@omarrodriguez15
omarrodriguez15 / InfiniteLoopBash.sh
Created October 11, 2019 20:45
An infinite one-line loop to monitor memory on and android device
while true; do dumpsys meminfo com.something.foo; sleep 2; done
@omarrodriguez15
omarrodriguez15 / ConvertTo-CompatJson.ps1
Last active November 24, 2024 11:04
Remove comments from json so that powershell can convert it into a Object without throwing up.
Get-Content .\settings.json | %{ if ($_.Contains('//')){ $_.SubString(0, $_.IndexOf('//')) } else {$_}} | ConvertFrom-Json
@omarrodriguez15
omarrodriguez15 / Git-EditCommitToCurrentDate.ps1
Last active July 18, 2019 21:51
During a rebase edit the commit you will be squashing into and run the following to update the date with the current date time
git commit --amend --no-edit --date "$(date)"
or
git commit --amend --reset-author
@omarrodriguez15
omarrodriguez15 / Get-EnabledWindowsFeatures.ps1
Last active July 1, 2019 21:55
This is for older windows servers that do not have the WebAdmin module installed so Get-WindowsFeature is not available.
# One-liner not efficent but it works. Max number of features is couple hundred.
dism /online /get-features /format:table | %{$s=$_.Split('|');if ($s.Length -eq 2 -and $s[1].Trim() -eq 'Enabled'){$_};}
Get-WindowsFeature | where {$_.InstallState -eq "Installed"}