Skip to content

Instantly share code, notes, and snippets.

View Beej126's full-sized avatar

Beej Beej126

View GitHub Profile
@Beej126
Beej126 / gist:28114aef95817491a18f2293cfc3d0a6
Created March 7, 2024 09:17
React iterate to generate elements sample
<ul>
{[1, 2, 3, 4, 5].map(i => <li>{i}</li>)}
</ul>
@Beej126
Beej126 / eztv_scraper.js
Last active June 13, 2023 23:28
browser console script for pulling eztv.unblockit.tv episode links in bulk
//helper function
function groupBy(objectArray, property) {
return objectArray.reduce((acc, obj) => {
const key = obj[property];
if (!acc[key]) {
acc[key] = [];
}
// Add object to list for given key's value
acc[key].push(obj);
return acc;
@Beej126
Beej126 / .gitignore
Last active February 18, 2023 07:53
dnlib copy source dll methods to destination dll (patch tool)
dest.cs
dest/
save.ps1
source.cs
source.dll
@Beej126
Beej126 / script.sh
Created February 4, 2022 01:09
hackintosh config.plist convert hex <=> base64
# base64 to hex
echo -n AwCYPg== | base64 -d | xxd -ps
# hex to base64
echo -n 0300983e | xxd -r -p | base64
@Beej126
Beej126 / bigcsvsplitter.ps1
Last active June 2, 2022 18:17
Split big CSV quickly (multiple gigs < minute) based on column, powershell with embedded C#
# C# syntax works under both pwsh core and legacy Windows Powershell which is capped at C# 5.0 and .Net Framework vs dotnet core
Add-Type @"
using System;
using System.IO;
public static class BigCsvSplitter
{
public static void Run()
@Beej126
Beej126 / html2svg.js
Last active May 20, 2022 16:50
html2svg download in chrome page
//https://github.com/bubkoo/html-to-image
//load systemjs as a way to import html-to-image library which is published as node module with require dependencies
//you could do this via normal <script> tag as well
var script = document.createElement("script");
script.setAttribute("src", "https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.21.6/system.js"); //new SystemJs doesn't support CJS modules
document.body.appendChild(script);
//set .js as default extension for nested dependencies "require()'d" from index.js below
System.config({
@Beej126
Beej126 / README.md
Last active April 18, 2022 15:41
Scripted Windows 10 "Win+X" Menu (aka "Power User Menu")
@Beej126
Beej126 / csharp-repl.ps1
Created April 18, 2022 04:07 — forked from noseratio/csharp-repl.ps1
C# REPL with Microsoft.Net.Compilers.Toolset
# https://www.nuget.org/packages/Microsoft.Net.Compilers.Toolset
md cs-repl | cd
nuget install Microsoft.Net.Compilers.Toolset
# run a CS script, a useful alternative to PowerShell itself
echo 'Console.WriteLine("hello");' > script.csx
. (gci -recurse csi.exe).FullName script.csx
# run in REPL mode
@Beej126
Beej126 / AutoUnZip.wsh.js
Last active March 24, 2022 20:02
Windows File Explorer auto extract zips like Mac Finder
function CheckFolderExistsAndCreate(folder) {
if (fso.FolderExists(folder)) {
WScript.Echo("destination folder already exists: " + folder);
WScript.Quit(1);
}
fso.CreateFolder(folder);
}
//probe the zip file for depth/complexity
@Beej126
Beej126 / dotnet_watch_monitor.ps1
Last active December 22, 2021 17:59
"dotnet watch" output monitor to autorun other tooling
# all syntax is pwsh v7+ compatible
###########################################
# the basic scenario is wanting to fire another codegen tool whenever `dotnet watch run` reports a change to specific source files
# it's very fortunate dotnet watch already reports exactly what we need to trigger on
###########################################
# this code is very customized to watch my ServiceStack webapi project
# and run the ServiceStack CLI tooling that autogens typescript DTOs from C# DTOs.
#
# i've also tailored to watching for specific errors, and trimming the debug output verbosity and changing console text color to catch the eye