Skip to content

Instantly share code, notes, and snippets.

@glorat
glorat / README.md
Created April 10, 2025 14:29
Litellm for ollama
  1. Running It

Install dependencies:

pip install -r requirements.txt

Run LiteLLM:

python run_litellm.py

@glorat
glorat / README.md
Last active March 29, 2025 14:23
GitHub Actions Runner Idle Shutdown

GitHub Actions Runner Idle Shutdown

This gist contains a solution to automatically shut down an Azure VM running a GitHub Actions self‑hosted runner when it has been idle for a specified period. It does so by monitoring the last modified time of the runner’s Worker logs in the _diag folder. If no new Worker logs have been created for a set threshold (for example, 30 minutes), the script triggers a shutdown.

Files

  • check_idle_worker.sh
    A Bash script that:
    • Scans the actions-runner/_diag directory for files whose names start with Worker_.
  • Calculates how long it has been since the most recent update.
@glorat
glorat / tour.ts
Created February 25, 2025 15:06
Shepherd.js
import * as ShepherdNamespace from 'shepherd.js'
import 'shepherd.js/dist/css/shepherd.css'
// Create a singleton instance of Shepherd.Tour
class TourService {
private static instance: TourService
private tour: ShepherdNamespace.Tour
private matterIdStep?: ShepherdNamespace.Step
private constructor() {
@glorat
glorat / usePdfViewerSelection.ts
Created November 30, 2024 01:13
PDF Viewer selection
import { Ref, watch } from 'vue'
import type { VPVInstance } from '@vue-pdf-viewer/viewer'
/**
* Represents the data structure for text selection within a PDF viewer
*/
export interface SelectionData {
/** The selected text content */
text: string
/** Information about the selection range within the document */
@glorat
glorat / Dockerfile
Created September 24, 2024 06:45
Posthog Reverse proxy for nginx
FROM nginx:alpine
COPY nginx.conf /etc/nginx/nginx.conf
@glorat
glorat / slugify.ts
Created August 13, 2024 07:39
Slugify
import transliterate from './transliterate';
const builtinOverridableReplacements = [
['&', ' and '],
['🦄', ' unicorn '],
['♥', ' love ']
];
const matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
function escapeStringRegexp (str:string) {
if (typeof str !== 'string') {
@glorat
glorat / ChatGPTClient.ts
Created June 7, 2024 06:50
ChatGPTClient - Typescript
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
/**
* Taken from https://github.com/glorat/node-chatgpt-api/blob/main/src/ChatGPTClient.js
* but with the following mods to make it browser friendly:
* - Replace cacheOptions with cache, to decouple from keyv, which doesn't work in browser
* - Remove undici, which doesn't work in browser
* - Remove proxying support
* - use uuid instead of crypto
@glorat
glorat / up.mjs
Created June 7, 2024 06:25
Upgrade a typescript project to langchain v0.2
import { updateEntrypointsFrom0_x_xTo0_2_x } from "@langchain/scripts/migrations";
const pathToMyProject = "./functions/src"; // This path is used in the following glob pattern: `${projectPath}/**/*.{ts,tsx,js,jsx}`.
updateEntrypointsFrom0_x_xTo0_2_x({
projectPath: pathToMyProject,
tsConfigPath: "tsconfig.json", // Path to the tsConfig file. This will be used to load all the project files into the script.
// testRun: true, // If true, the script will not save any changes, but will log the changes that would be made.
shouldLog: true,
});
@glorat
glorat / cloudbuild.yaml
Last active May 7, 2024 13:50
Import unstructured-api image to artifact registry for use with Google Cloud Run
steps:
- name: 'gcr.io/cloud-builders/docker'
args:
- 'pull'
- 'quay.io/unstructured-io/unstructured-api:latest'
- name: 'gcr.io/cloud-builders/docker'
args:
- 'tag'
- 'quay.io/unstructured-io/unstructured-api:latest'
- 'asia-southeast1-docker.pkg.dev/glorat-gptapps/sg-unstructured/unstructured-api:latest'
@glorat
glorat / gist:2179505f380b9984cb4f
Last active August 29, 2015 14:05
Brainwallet bitcoinsig with bitcoinjs-lib 1.0.3 - And a bug
/**
* Created by Kevin Tam on 08/08/2014.
*/
var Base58 = require('bs58');
var Crypto = require('crypto');
var BigInteger = require('bigi');
var assert = require('assert');
var Bitcoin = require('../../')