Skip to content

Instantly share code, notes, and snippets.

View vexx32's full-sized avatar
💜
Turn your faults into faultlore and share them with the world.

Rain Sallow (/u/ta11ow) vexx32

💜
Turn your faults into faultlore and share them with the world.
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vexx32
vexx32 / Tender Buttons.svg
Created September 12, 2020 02:08
from Tender Buttons by Gertrude Stein
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vexx32
vexx32 / The Desert Music.svg
Last active September 12, 2020 01:48
The Desert Music, by William Carlos Williams
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vexx32
vexx32 / get-classes-and-ids.ps1
Created July 13, 2020 03:07
PowerShell script to retrieve lists of classes and ids from a html string and output a CSS skeleton for them
[System.Text.RegularExpressions.MatchCollection]$classesAndIds = [regex]::Matches($html, 'class="(?<Classes>[^"]+)"|id="(?<Id>[^"]+)"')
$classes = [System.Collections.Generic.HashSet[string]]::new()
$ids = [System.Collections.Generic.HashSet[string]]::new()
$classesAndIds.Captures.Groups.ForEach{
if ($_.Name -eq 'Classes') {
$_.Value -split '[\s\r\n]' -replace '\{/?block:[^}]\}' |
Where-Object {$_} |
ForEach-Object {
@vexx32
vexx32 / Get-Age.ps1
Last active June 20, 2020 03:53
for Mark Kraus ♥
function Get-Age {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[ValidateScript(
{
$_ -lt [datetimeoffset]::UtcNow
}
)]
[datetimeoffset]
@vexx32
vexx32 / ConvertJsonPropertiesToTitleCase.ps1
Created May 15, 2020 15:14
Converts a JSON object into a PSObject, replacing these_property_names with ThesePropertyNames
$Object = ConvertFrom-Json '{ "base_url": "https://foo.bar" }'
$Properties = foreach ($property in $Object.PSObject.Properties) {
$newNameFragments = @($property.Name -split '_').ForEach{
[CultureInfo]::CurrentCulture.TextInfo.ToTitleCase($_)
}
# Select-Object property rename via selector hashtable; Name is the new name, Expression is the original name
@{ Name = -join $newNameFragments; Expression = $property.Name }
}
@vexx32
vexx32 / GetEnclosedArea.cs
Last active March 24, 2020 01:38
Gets the approximate area enclosed by an SKPath instance by comparing its total bounded area to the percentage of evenly-distributed points that are "contained" within the path.
internal static float GetEnclosedArea(this SKPath path)
{
SKRect bounds = path.TightBounds;
var boundedArea = bounds.Width * bounds.Height;
var totalPoints = 10000;
var enclosedPoints = 0;
for (float x = bounds.Left; x < bounds.Right; x += bounds.Width / (float)Math.Sqrt(totalPoints))
{
for (float y = bounds.Top; y < bounds.Bottom; y += bounds.Height / (float)Math.Sqrt(totalPoints))
$string = 'hostname.database.table.schema'
if ($string -match '(?<Hostname>\w+)\.(?<Database>\w+)\.(?<Table>\w+)\.(?<Schema>\w+)') {
$matches.Remove(0)
[PSCustomObject]$matches
}