Skip to content

Instantly share code, notes, and snippets.

View mavaddat's full-sized avatar
🏠
Working from home

Mavaddat Javid mavaddat

🏠
Working from home
View GitHub Profile
@mavaddat
mavaddat / embed64.ps1
Created November 11, 2022 23:37
Create Base64 Encoded Font Files from WOFF for HTML, SVG or XML
$css = @"
@font-face{
font-family:"Roboto Condensed";
src:url(data:application/font-woff;charset=utf-8;base64,your_base64_encoded_long_string) format("woff");
font-weight: normal;
font-style: normal;
}
"@
Get-ChildItem -Path $env:TEMP -Filter *.woff -Recurse | ForEach-Object {
$base64 = [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes($_))
@mavaddat
mavaddat / fish_greeting.fish
Last active November 6, 2022 02:43 — forked from dan-c-underwood/fish_greeting.fish
Custom fish greeting (for fish shell)
function fish_greeting
echo ' '(set_color F00)'___
___======____='(set_color FF7F00)'-'(set_color FF0)'-'(set_color FF7F00)'-='(set_color F00)')
/T \_'(set_color FF0)'--='(set_color FF7F00)'=='(set_color F00)') '(set_color red)(whoami)'@'(hostname)'
[ \ '(set_color FF7F00)'('(set_color FF0)'0'(set_color FF7F00)') '(set_color F00)'\~ \_'(set_color FF0)'-='(set_color FF7F00)'='(set_color F00)')'(set_color yellow)' Uptime: '(set_color white)(uptime | sed 's/.*up \([^,]*\), .*/\1/')(set_color red)'
\ / )J'(set_color FF7F00)'~~ \\'(set_color FF0)'-='(set_color F00)') IP Address: '(set_color white)(hostname -I)(set_color red)'
\\\\___/ )JJ'(set_color FF7F00)'~'(set_color FF0)'~~ '(set_color F00)'\) '(set_color yellow)'Version: '(set_color white)(echo $FISH_VERSION)(set_color red)'
\_____/JJJ'(set_color FF7F00)'~~'(set_color FF0)'~~ '(set_color F00)'\\
'(set_color FF7F00)'/ '(set_color FF0)'\ '(set_color FF0)', \\'(set_color F00)'J'(set_color
@mavaddat
mavaddat / SandboxWithSharedFolder.wsb
Created October 13, 2022 03:33
Sandbox with 7-Zip
<Configuration>
<Networking>Enable</Networking>
<ProtectedClient>Enable</ProtectedClient>
<ClipboardRedirection>Disable</ClipboardRedirection>
<MappedFolders>
<MappedFolder>
<HostFolder>C:\Users\Public\Documents</HostFolder>
<SandboxFolder>C:\Users\WDAGUtilityAccount\Documents</SandboxFolder>
<ReadOnly>true</ReadOnly>
</MappedFolder>
# One time setup
if (-not (Get-Package 'Portable.BouncyCastle' -ErrorAction Ignore)) {
if (-not (Get-PackageSource -Name NuGet -ErrorAction Ignore)) {
Register-PackageSource -Name NuGet -Location https://api.nuget.org/v3/index.json -ProviderName NuGet | Set-PackageSource -Trusted
}
Install-Package -Name 'Portable.BouncyCastle' -Source NuGet -Scope CurrentUser -SkipDependencies
}
# Download the MySQLite repository (for PowerShell <5 without PowerShellGet)
if (-not(Get-Module -Name MySQLite -ErrorAction Ignore) -and ($PSVersionTable.PSVersion.Major -lt 5)) {
$RepositoryZipUrl = 'https://api.github.com/repos/jdhitsolutions/MySQLite/zipball/master'
@mavaddat
mavaddat / CSVParse.ps1
Last active September 27, 2022 14:47
Parse Outlook CSV Dump into data that is readable by Excel
$csv = Get-Content -Path $env:USERHOME\EXAMPLE.CSV
$bodies = $csv | Where-Object -FilterScript { $_ -match '^"[^,][^,"]+","'} | ForEach-Object { $csv.IndexOf($_) }
$emails = for($i=0; $i -lt $bodies.Count; $i++){ $csv[$bodies[$i]..($bodies[$i+1]-1)] | Out-String | ForEach-Object { $_ -replace '[\r\n]+','¶' -replace '\t','⇥' -replace '"¶','"'} | Write-Output }
$emails | Out-File -FilePath ($temp = New-TemporaryFile) -Encoding utf8
$temp | Out-Host
@mavaddat
mavaddat / garminize.ps1
Created September 6, 2022 02:24
Garmin FIT File Parser. Expects the Garmin SDK in %APPDATA%
$gpx = Get-Clipboard -Raw | ForEach-Object { [xml]$_ }
foreach ($trkpt in $gpx.gpx.trk.trkseg.trkpt)
{
$lat = $trkpt.lat
while ($lat.Length -lt 32)
{
$lat += Get-Random
}
$trkpt.lat = -join $lat[0..31]
$lon = $trkpt.lon
@mavaddat
mavaddat / updateFFmpeg.ps1
Last active March 10, 2023 18:51
Windows ffmpeg updater in PowerShell
# Updates FFMPEG to the latest version
$ffmpegGH = @{OWNER = 'GyanD'; REPO = 'codexffmpeg' }
$extractTo = Join-Path -Path $env:USERPROFILE -ChildPath 'ffmpeg'
if (-not ([System.Management.Automation.PSTypeName]'SevenZipExtractor.ArchiveFile').Type)
{
if (-not (Get-Package -Name SevenZipExtractor -ErrorAction Ignore))
{
Install-Package SevenZipExtractor -Source nuget.org -Scope CurrentUser
}
Get-Package -Name SevenZipExtractor | ForEach-Object { Add-Type -LiteralPath ($_.Source | Split-Path | Get-ChildItem -Filter 'netstandard*' -Recurse -Directory | Get-ChildItem -Filter *.dll -Recurse -File ).FullName }
@mavaddat
mavaddat / cue_to_mp3.py
Last active August 11, 2022 05:25 — forked from bancek/cue_to_mp3.py
CUE splitter using ffmpeg (to mp3)
from slugify import slugify
cue_file = r'''C:/Users/mavad/Downloads/Philip Glass - Akhnaten/CD1/Philip Glass - Akhnaten (CD1).cue'''
d = open(cue_file).read().splitlines()
general = {}
tracks = []
current_file = None
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Install-Package AngleSharp -Scope CurrentUser -Source Nuget -SkipDependencies
Get-Package -Name 'AngleSharp' | ForEach-Object { Split-Path $_.Source } | Get-ChildItem -Filter '*.dll' -Recurse | Where-Object {$_ -Like "*standard*"} | Select-Object -Last 1 | ForEach-Object { Add-Type -Path $_ -ErrorAction SilentlyContinue -Verbose }
$searchTerm=$identifier
$request = Invoke-WebRequest -Uri 'http://libgen.is/search.php?req=9780199568925&open=0&res=25&view=simple&phrase=1&column=identifier&sort=year&sortmode=DESC'
$parser = [AngleSharp.Html.Parser.HtmlParser]::new()
$parsedContent = $parser.ParseDocument($request.Content)
$requestDL = Invoke-WebRequest -Uri ($parsedContent.QuerySelector('body > table.c').QuerySelector("body > table.c > tbody > tr:nth-child(2) > td:nth-child(10) > a").href)
$parsedDLContent = $parser.ParseDocument($requestDL.Content)
$uri = [uri]::new(($parsedDLContent.QuerySelector("#download > h2 > a").href))
Invoke-WebRequest -Uri ($parsedDLContent.QuerySelector("#download > h2 > a").href) -Ou