Skip to content

Instantly share code, notes, and snippets.

View xdite's full-sized avatar

Yi-Ting Cheng xdite

View GitHub Profile
@hanxiao
hanxiao / testRegex.js
Last active November 3, 2024 19:02
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;
output_file="/Users/jwheeler/Desktop/combined_src_files.txt"
www_src_directory="/Users/jwheeler/Projects/demofun/www/src"
api_src_directory="/Users/jwheeler/Projects/demofun/api/src"
# Clear the output file if it already exists
> "$output_file"
# Function to process files
process_files() {
local directory=$1
@dharrawal
dharrawal / dspy_logger.py
Last active September 8, 2024 20:32
A simple framework for logging calls to DSPy programs in a minimally obtrusive way
"""
DSPy Logging Utilities
Author: Dhar Rawal
Works with DSPy to log forward calls and their results, using a custom handler function.
Works with typed predictors too!
"""
import functools
import json
from typing import Any, Callable, Dict, Optional, Tuple
@hSATAC
hSATAC / gist:5591270
Last active December 17, 2015 09:59
Shell function to send pull request using hub
# Usage: pr (pull request current branch into develop)
# Usage 2: pr stable (pull request current branch into stable)
# Notice: replace "team" with your github team account.
function pr() {
base=$1;
if [ "$1" == "" ]; then
base="develop"
fi
hub pull-request -b team:"$base" -h team:`git rev-parse --abbrev-ref HEAD`;
@penk
penk / TPB.AFK.2013.480p.h264-SimonKlose.CHT.srt
Last active June 5, 2017 03:49
《TPB AFK 海盜灣 - 暫時離開》 中文字幕
1
00:01:47,959 --> 00:01:51,400
三名瑞典人於今日遭到逮捕
罪名是涉嫌架設-
2
00:01:51,560 --> 00:01:57,400
-全世界最大的非法下載站台
3
@jakeonrails
jakeonrails / Ruby Notepad Bookmarklet
Created January 29, 2013 18:08
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@xdite
xdite / 42-things.md
Created July 14, 2012 05:11
Ten (42) Things You Didn't Know Rails Could Do
@yorkxin
yorkxin / avoid-jquery-when-possible.md
Created July 7, 2012 13:04
Avoid jQuery When Possible

Avoid jQuery When Possible

jQuery does good jobs when you're dealing with browser compatibility. But we're living in an age that fewer and fewer people use old-school browsers such as IE <= 7. With the growing of DOM APIs in modern browsers (including IE 8), most functions that jQuery provides are built-in natively.

When targeting only modern browsers, it is better to avoid using jQuery's backward-compatible features. Instead, use the native DOM API, which will make your web page run much faster than you might think (native C / C++ implementaion v.s. JavaScript).

If you're making a web page for iOS (e.g. UIWebView), you should use native DOM APIs because mobile Safari is not that old-school web browser; it supports lots of native DOM APIs.

If you're making a Chrome Extension, you should always use native APIs, not only because Chrome has almost the latest DOM APIs available, but this can also avoid performance issue and unnecessary memory occupation (each jQuery-driven extension needs a separate