Copy this file to ~/.claude/statusline-command.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ============================================================================== | |
-- Optimized UUIDv7 Implementation for PostgreSQL 17 on Google Cloud SQL | |
-- ============================================================================== | |
-- Main UUIDv7 function (current timestamp) | |
CREATE OR REPLACE FUNCTION uuid_v7() RETURNS uuid | |
LANGUAGE plpgsql VOLATILE AS $$ | |
DECLARE | |
timestamp_ms bigint; | |
bytes bytea; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
========== bash ========== | |
--- plain mode (bash ) --- | |
HAS_PIPEFAIL = 1 | |
HAS_ARRAY = 1 | |
HAS_EUO = 1 | |
HAS_EVAL = 1 | |
HAS_ASSOC_ARRAY = 1 | |
HAS_DBLBRACK = 1 |
This directory contains test files for the bash utility scripts used throughout the project.
- test.sh: Main test runner that executes all test files (located in this directory)
- utils.test.sh: Tests for
_utils.sh
utility functions - Additional test files should be named after the script they test with a
.test.sh
suffix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Helper function to detect if running in VSCode or Cursor | |
is_agent_context() { | |
# Multiple detection methods for Cursor context | |
# 1. Check if its vscode or cursor (both have the same TERM_PROGRAM) | |
# 2. Check if this is being executed from a non-interactive shell (common in agents) | |
if [[ "$TERM_PROGRAM" == "vscode" ]] && | |
[[ ! -o interactive ]]; then | |
return 0 # true in shell logic | |
else | |
return 1 # false in shell logic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference types="jest" /> | |
import { Guid } from './Guid'; | |
// Jest globals are likely configured in the project's tsconfig or type definitions | |
describe('Guid', () => { | |
describe('constructor', () => { | |
it('should create a valid GUID from a string', () => { | |
const guidStr = '123e4567-e89b-7123-8456-426614174000'; | |
const guid = new Guid(guidStr); | |
expect(guid.valueOf()).toBe(guidStr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function stringToColor(str) { | |
// Predefined set of colors | |
const colors = ['#FF5733', '#33FF57', '#3357FF', '#F833FF', '#FF8333', '#33FFF8']; | |
// Simple hash function | |
let hash = 0; | |
for (let i = 0; i < str.length; i++) { | |
const char = str.charCodeAt(i); | |
hash = ((hash << 5) - hash) + char; | |
hash = hash & hash; // Convert to 32bit integer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION time_histogram( | |
start_time timestamp, | |
end_time timestamp | |
) | |
RETURNS TABLE(bucket timestamp) AS $$ | |
DECLARE diff_hours int; | |
BEGIN | |
diff_hours = abs(extract(epoch from end_time - start_time) / 3600) | |
raise notice 'diff hours: ', diff_hours; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH RECURSIVE pg_inherit(inhrelid, inhparent) AS | |
(select inhrelid, inhparent | |
FROM pg_inherits | |
UNION | |
SELECT child.inhrelid, parent.inhparent | |
FROM pg_inherit child, pg_inherits parent | |
WHERE child.inhparent = parent.inhrelid), | |
pg_inherit_short AS (SELECT * FROM pg_inherit WHERE inhparent NOT IN (SELECT inhrelid FROM pg_inherit)) | |
SELECT table_schema | |
, TABLE_NAME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static bool IsLoopbackOrPrivate([NotNull] IPAddress clientIp) | |
{ | |
// RFC for private networks: | |
// http://www.faqs.org/rfcs/rfc1918.html | |
byte[] bytes = clientIp.GetAddressBytes(); | |
switch(bytes[0]) | |
{ | |
case 10: | |
return true; |
NewerOlder