Skip to content

Instantly share code, notes, and snippets.

View agritheory's full-sized avatar

Tyler Matteson agritheory

View GitHub Profile
clip-claude() {
local base_dir="${1:-.}" # Use current directory if no directory specified
local pattern="${2:-*/*.ts}" # Default to */*.ts if no pattern specified
(
find "$base_dir" -type f -name "$pattern" | sort | while read -r file; do
echo "// File: $file"
cat "$file" 2>/dev/null || echo "File not found: $file"
done
) | clip.exe
}
-- First, create a recursive CTE function to handle role inheritance
CREATE OR REPLACE FUNCTION get_inherited_roles(role_uuid UUID)
RETURNS TABLE (role_id UUID) AS $$
WITH RECURSIVE role_hierarchy AS (
-- Base case: the role itself
SELECT id, parent_role
FROM role
WHERE id = role_uuid AND active = TRUE
UNION
@agritheory
agritheory / unreconciled_sales_return_example.md
Last active May 8, 2024 20:59
Unreconciled Sales Return example.md

A Customer purchased two Items and paid in cash. The ERPNext user created the Sales Invoice including payment. This is appropriate since the issue of inventory, consent to sell and payment are co-temporal.

Account Stock Ledger Debit Credit
Cost of Goods Sold $100.00
Inventory on Hand 2 @ $50.00 $100.00
Accounts Receivable $100.00
Sales $100.00
Accounts Receivable $100.00
Bank / cash account $100.00
import { existsSync, readFile, writeFile } from "fs";
import { remark } from 'remark';
import RemarkLinkRewrite from './rewrite.js';
import shelljs from "shelljs"
const { exec } = shelljs;
if (!existsSync("./content/")) {
exec("mkdir -p ./content");
}
@agritheory
agritheory / unshallow_clone_repo.md
Last active May 7, 2024 06:11
Create a full clone of a Frappe app locally

Create a full clone of a Frappe app locally

Synthesized from several helpful stackoverflow responses and some trial and error. This is intended for use in a development or possibly staging environment.

bench get-app cloud_storage [email protected]:agritheory/cloud_storage.git --skip-assets

This will complete the default clone/install (but not build) of a Frappe app.

In [1]: simple_dictionary = {'celtics': "Let's go", 'heat': 'Beat the'}
In [2]: simple_dictionary.get('la')
In [3]: simple_dictionary.get('la', '!!!')
Out[3]: '!!!'
In [4]: frappe_dictionary = frappe._dict({'celtics': "Let's go", 'heat': 'Beat the'})
In [5]: frappe_dictionary.get('la')
from frappe.modules.utils import export_customizations
def export_dimension_fields():
doctypes = [
"GL Entry",
"Sales Invoice",
"Purchase Invoice",
"Payment Entry",
"Expense Claim Detail",
"Expense Taxes and Charges",
@agritheory
agritheory / add_github_deploy.sh
Last active November 14, 2024 16:47
Add deploy key
# on local machine generate public and private keys
ssh-keygen -t ed25519
$ Generating public/private ed25519 key pair.
$ Enter file in which to save the key (/home/tyler/.ssh/id_ed25519): deploy_key
# add deploy_key.pub to github deploy keys via UI
# add both keys to server
# modify permissions
@agritheory
agritheory / edgewise_create_data.py
Created April 1, 2020 17:28
Generate Company and User with Mimesis
import csv
import random
import typing
from pathlib import Path
import mimesis
def write_to_file(filename: str, data: list) -> typing.NoReturn:
raw_path = Path(__file__).parent / filename