Skip to content

Instantly share code, notes, and snippets.

View chenhunghan's full-sized avatar
🐢

Henry Chen chenhunghan

🐢
View GitHub Profile
@chenhunghan
chenhunghan / llama_cpp_dspy_evaluate.py
Created April 1, 2024 13:15
DSPy llm evaluation with metric using llama.cpp
# A gist for using the `llama.cpp` model with the `dspy` library.
#
# DSPy features used in this gist
# - `dspy.Predict`
# - `dspy.Signature`
# - `dspy.context`
# - `dspy.evaluate.Evaluate`
#
# The script first prompts the model to answer a example question and assess the correctness and engagingness of the answer using a evaluator.
#
@chenhunghan
chenhunghan / llama_cpp_dspy_metric.py
Last active April 1, 2024 13:05
DSPy prompt evaluation with metric using llama.cpp
# A gist for using the `llama.cpp` model with the `dspy` library.
#
# DSPy features used in this gist
# - `dspy.Predict`
# - `dspy.Signature`
# - `dspy.context`
# The script first prompts the model to answer a example question and assess the correctness and engagingness of the answer.
#
# Install `llama.cpp` from brew with built-in OpenAI-compatible server.
# brew install ggerganov/ggerganov/llama.cpp
@chenhunghan
chenhunghan / hackRequest.md
Last active December 14, 2017 12:27
Hijacking Request with Service Worker

Hijacking img requests

self.addEventListerner('fetch', (event) => {
  if (event.request.url.endsWith('.jpg')) {
    event.respondWith(
      fetch('/img/someLocalImage.jpg')
    );
  }
}
@chenhunghan
chenhunghan / Install CJK fonts to reMarkable Tablet.md
Last active November 11, 2024 19:25
How to install Noto Sans CJK fonts for reMarkable Tablet

reMarkable is a paper tablet by https://remarkable.com/.

The reMarkable tablet is the best e-paper in the market. However, it does not have built-in support for CJK (Chiniese, Korean and Japanese) users.

Luckily, this could be resolved by installing CJK fonts on the tablet.

  1. Go to Preference > Storage > Enable USB web interface (Beta).
  2. Connect reMarkable with your PC via a microUSB cable.
  3. SSH to the device as user "root" using the password find in Preference > About. e.g. ssh root@10.11.99.1
  4. Download "NotoSansCJK[you language]-Regular.otf" from *note, there is limited space on the device, so do not sue "Super OpenType/CFF Collection (Super OTC)", an language-specific OTC is ok.
@chenhunghan
chenhunghan / ckrender.coffee
Created November 14, 2013 03:55
a small coffescript for building coffeecup-html with error logging, file-watch and helpers
#!/usr/bin/env coffee
fs = require 'fs'
ck = require 'coffeecup'
path = require 'path'
viewhelpers = {}
viewhelper_merge = (vhs)->
for k, v of vhs
@chenhunghan
chenhunghan / d3.js.force.fundamental in coffeescript
Created October 4, 2013 08:59
d3.js fundamentals of force(), nodes() and links()
doctype 5
html ->
head ->
meta charset: 'utf-8'
title 'hello'
script src: 'http://codeorigin.jquery.com/jquery-1.10.2.min.js'
script src: 'http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js'
script src: 'http://d3js.org/d3.v3.min.js'
link rel: 'stylesheet', href: 'http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css'
style '''
@chenhunghan
chenhunghan / bopomofo.schema.yaml
Last active March 4, 2017 07:57
注音輸入法模式 for Squirrel 0.9.20.4 on Mac OSX 10.8.2 please put bopomofo.schema.yaml, default.custom.yaml and squirrel.custom.yaml in ~/Library/Rime then 重新部屬
# Rime schema
# encoding: utf-8
schema:
schema_id: bopomofo
name: 正體
version: "1.3"
author: 這樣 是
- 佛振 <chen.sst@gmail.com>
- turtleknight(修正臺灣使用者輸入習慣) <stk.chen@gmail.com>