Skip to content

Instantly share code, notes, and snippets.

View lloydzhou's full-sized avatar
:octocat:
Focusing

Lloyd Zhou lloydzhou

:octocat:
Focusing
View GitHub Profile
@MeMartijn
MeMartijn / jina_text_segmenter.py
Created October 29, 2024 15:01
Jina AI's Segmenter ported to Python
import regex
from typing import List
# Define constants
MAX_HEADING_LENGTH = 7
MAX_HEADING_CONTENT_LENGTH = 200
MAX_HEADING_UNDERLINE_LENGTH = 200
MAX_HTML_HEADING_ATTRIBUTES_LENGTH = 100
MAX_LIST_ITEM_LENGTH = 200
MAX_NESTED_LIST_ITEMS = 6
@LukasKriesch
LukasKriesch / gist:e75a0132e93ca989f8870c4f95be734b
Created August 26, 2024 09:12
Python translation Jina AI chunking regex
import regex as re
import requests
MAX_HEADING_LENGTH = 7
MAX_HEADING_CONTENT_LENGTH = 200
MAX_HEADING_UNDERLINE_LENGTH = 200
MAX_HTML_HEADING_ATTRIBUTES_LENGTH = 100
MAX_LIST_ITEM_LENGTH = 200
MAX_NESTED_LIST_ITEMS = 6
MAX_LIST_INDENT_SPACES = 7
@hanxiao
hanxiao / testRegex.js
Last active April 22, 2025 02:43
Regex for chunking by using all semantic cues
// Updated: Aug. 20, 2024
// Run: node testRegex.js whatever.txt
// Live demo: https://jina.ai/tokenizer
// LICENSE: Apache-2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// COPYRIGHT: Jina AI
const fs = require('fs');
const util = require('util');
// Define variables for magic numbers
const MAX_HEADING_LENGTH = 7;
@dedlim
dedlim / claude_3.5_sonnet_artifacts.xml
Last active April 24, 2025 07:28
Claude 3.5 Sonnet, Full Artifacts System Prompt
<artifacts_info>
The assistant can create and reference artifacts during conversations. Artifacts are for substantial, self-contained content that users might modify or reuse, displayed in a separate UI window for clarity.
# Good artifacts are...
- Substantial content (>15 lines)
- Content that the user is likely to modify, iterate on, or take ownership of
- Self-contained, complex content that can be understood on its own, without context from the conversation
- Content intended for eventual use outside the conversation (e.g., reports, emails, presentations)
- Content likely to be referenced or reused multiple times
@guillermodlpa
guillermodlpa / HMAC.js
Last active February 25, 2025 21:08 — forked from stevendesu/HMAC.js
A simple, open-source, HMAC-SHA256 implementation in pure TypeScript. Designed for efficient minification.
// From https://gist.github.com/stevendesu/2d52f7b5e1f1184af3b667c0b5e054b8
// To ensure cross-browser support even without a proper SubtleCrypto
// impelmentation (or without access to the impelmentation, as is the case with
// Chrome loaded over HTTP instead of HTTPS), this library can create SHA-256
// HMAC signatures using nothing but raw JavaScript
/* eslint-disable no-magic-numbers, id-length, no-param-reassign, new-cap */
// By giving internal functions names that we can mangle, future calls to
@vested-sigil
vested-sigil / notion.yaml
Created January 26, 2024 00:07
swagger spec for notion.so for custom GPTS
openapi: 3.0.0
info:
title: Notion API
description: API for interacting with Notion resources such as pages and databases.
version: 1.0.0
servers:
- url: https://api.notion.com/v1
description: Main API server
paths:
/pages/{page_id}:
@bmaupin
bmaupin / tiling-extensions-for-gnome.md
Last active January 20, 2025 12:51
Tiling extensions for Gnome

Goal: find a Linux alternative to FancyZones for Windows

Name Recommended Type Supports main colum Supports layouts Multiple windows in same tile Windows can span multiple zones Notes
Tiling Shell 👍👍👍 Gnome extension yes yes yes yes Explicitly inspired by Windows tiling, works great out of the box
gSnap 👍👍 Gnome extension yes yes yes yes Can be configured almost just like FancyZones; in the settings:
  • disable Show tabs
  • enable Hold CTRL to snap windows
gTile Gnome extension no?
Tiling Assistant ([Now bundled with Ubuntu](https://www.omgubuntu.co.uk/2023/06/
import openai
import pinecone
from sentence_transformers import SentenceTransformer
class GPTConversationManager:
def __init__(self, api_key, pinecone_api_key, index_name):
self.api_key = api_key
openai.api_key = self.api_key
self.conversation_history = []
self.pinecone_api_key = pinecone_api_key
@DavidBuchanan314
DavidBuchanan314 / widevine_fixup.py
Last active September 13, 2024 21:45
Patch aarch64 widevine blobs from ChromeOS to work on non-ChromeOS linux, including platforms with 16K page size like Apple Silicon / Asahi Linux
"""
MIT License
Copyright (c) 2023 David Buchanan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@diyism
diyism / x11docker (linux sanbox like android shelter app)
Last active October 9, 2024 01:57
x11docker (linux sanbox like android shelter app)
========update============
不需要x11docker, 更简单的方法, 直接允许容器访问host的X server:
https://gist.github.com/diyism/8f0d4b1cdfc4e9d0839927e78c90a327
=========================
"现在有很多国产linux程序了,比如 钉钉/飞书,
则linux上也有了隔离国产程序的需求,
试了1.virtualbox, 2.firejail, 3.docker theasp/novnc,
都不够方便实用, 最好用启动单个程序最快的是x11docker
@_:10个我离不开的android应用: