Skip to content

Instantly share code, notes, and snippets.

View mcpar-land's full-sized avatar
🤠

John mcpar-land

🤠
View GitHub Profile
@mcpar-land
mcpar-land / find-all-tags.sh
Created May 14, 2026 16:15
Find all xml tags
# You can use this to find all the tags present in a set of XML files.
# Useful for determining a schema while also spotting tags that are very uncommon.
rg "<([a-zA-Z]+)" . -g "*.xml" -r '$1' -NoI | sort | uniq -c | sort -nr
@mcpar-land
mcpar-land / git-anasysis.sh
Created April 8, 2026 16:43
Git repository analysis commands
# https://piechowski.io/post/git-commands-before-reading-code/
cd ${1?.}
echo "# Most changed files, last year"
echo '```'
git log --format=format: --name-only --since="1 year ago" \
| sort \
| uniq -c \
| sort -nr \
@mcpar-land
mcpar-land / test.php
Last active January 27, 2025 19:43
initialize static PHP variable
<?php
class STATIC_CLASS_TEST {
static $foo;
static function init() {
self::$foo = ['foo', 'bar', 'baz', $_ENV['MY_ENV_VARIABLE']];
}
}
@mcpar-land
mcpar-land / README.md
Created December 18, 2024 20:51
Brand Domains Owned By Valnet
@mcpar-land
mcpar-land / running_average.go
Created August 1, 2023 17:23
go running average
package main
import (
"fmt"
"math/rand"
)
func main() {
src := []float64{}
for i := 0; i < 100; i++ {
@mcpar-land
mcpar-land / build.rs
Created June 29, 2023 05:34
add tailwind to rust build script
use std::process::Command;
fn main() {
let tailwind_cmd = "npx tailwindcss -i input.css -o assets/app.css";
if cfg!(target_os = "windows") {
Command::new("cmd").arg("/C").arg(tailwind_cmd).status()
} else {
Command::new("sh").arg("-c").arg(tailwind_cmd).status()
}
@mcpar-land
mcpar-land / uniques_by_col.py
Created March 1, 2023 19:43
Pandas Unique Values By Column
def uniques_by_col(df: pd.DataFrame, drop_columns=[]) -> pd.DataFrame:
u = {}
for col in df.columns.tolist():
if str(col) not in drop_columns:
u[col] = pd.Series([(i[0], v) for i, v in dftxt[[col]].value_counts().iteritems()], dtype="object")
df2 = pd.DataFrame.from_dict(u, orient="index").T.replace({None: np.nan})
col_order = []
for col in df2.columns.tolist():
if str(col) not in drop_columns:
df2[[(str(col), "Val"), (str(col), "Count")]] = pd.DataFrame(df2[col].tolist(), index=df2.index)
@mcpar-land
mcpar-land / main.go
Last active May 23, 2022 16:46
Golang 1.18 undo example
package main
import (
"fmt"
)
func main() {
fmt.Print("Hello, ", "playground\n")
s := AppState{}
a := ActionStack[AppState]{}
@mcpar-land
mcpar-land / main.rs
Created September 7, 2020 16:47
Bevy Ui Crash
use bevy::prelude::*;
pub struct GlobalChildRef(pub Entity);
pub struct GlobalChild;
fn setup(
mut commands: Commands,
mut materials: ResMut<Assets<ColorMaterial>>,
global_child: ResMut<GlobalChildRef>,
) {
@mcpar-land
mcpar-land / menu.tsx
Created July 14, 2020 17:45
React subcomponents with styled-components and typescript
import React from 'react'
import styled from 'styled-components'
const MenuBase = styled.div`
display: flex;
flex-direction: column;
`
const MenuItem = styled.div`
padding: 5px;