Skip to content

Instantly share code, notes, and snippets.

View frinkleko's full-sized avatar
🌸
Isekai travelling

Xinjie Shen frinkleko

🌸
Isekai travelling
View GitHub Profile
@frinkleko
frinkleko / latex_in_office.md
Created July 15, 2023 06:44
A Prefect and Elegant way to use latex equation in Word, PPT...

NO! Not Support

In latest version of office software, basic latex grammar for simple math expression is supported. The usual way to show math equation in PPT is typing it in Word, then click insert eqauation, then click transforming, finally copy and paste it in PPT.

That's already annoying. However, some fabulous equations or symbols can't be used in Word.

image-20230715143344621

Solution

@frinkleko
frinkleko / SPE.py
Last active March 29, 2024 13:57
Toy implementation of SPE: https://openreview.net/pdf?id=xAqcJ9XoTf
import numpy as np
from scipy.linalg import eigh
def soft_partition(eigenvectors, eigenvalues, num_partitions):
# Apply a weighted sum of eigenvectors in an eigenvalue-dependent manner
partitions = np.linspace(np.min(eigenvalues), np.max(eigenvalues), num_partitions)
encodings = np.zeros_like(eigenvectors)
for i, val in enumerate(partitions[:-1]):
start, end = partitions[i], partitions[i+1]
mask = (eigenvalues >= start) & (eigenvalues < end)
@frinkleko
frinkleko / ways.md
Last active July 29, 2024 06:50
Ways to download google drive's file avoiding virus checking

You can mainly refer to this PR and its issues: pyg-team/pytorch_geometric#8804

The easy and elegant way is just change the url.

def download_google_url(
    id: str,
    folder: str,
    filename: str,
 log: bool = True,
import numpy as np
from scipy.stats import shapiro, wilcoxon
# Example matrices A and B (10x10)
np.random.seed(42)  # For reproducibility
A = np.random.normal(0, 1, (15, 10))
B = np.random.normal(1, 1, (15, 10))
# Step 1: Calculate the mean of each column for both matrices
mean_A = A.mean(axis=0)
@frinkleko
frinkleko / monitor.js
Created September 16, 2024 14:36
Sample code for monitor `text input area` in next chat
<label class="chat_chat-input-panel-inner___IQHi" for="chat-input">
<textarea id="chat-input" class="chat_chat-input__PQ_oF" placeholder="Enter to send, Shift + Enter to wrap, / to search prompts, : to use commands" rows="3" style="font-size: 14px;"></textarea>
<button class="button_icon-button__VwAMf undefined undefined chat_chat-input-send__GFQZo clickable button_primary__dwYZ6" role="button">
<div aria-label="Send" class="button_icon-button-icon__AMZta no-dark">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" fill="none">
<defs>
<path id="send-white_svg__a" d="M0 0h16v16H0z"></path>
</defs>
<g>
<mask id="send-white_svg__b" fill="#fff">
// Input monitoring
function setupInputMonitoring() {
const inputBox = document.querySelector(CONFIG.ID_PROMPT_INPUT);
const sendButton = document.querySelector(CONFIG.QUERY_SEND_BTN);
inputBox.addEventListener('keydown', function(event) {
if (startTime === null) {
startTime = new Date();
console.log('Start typing at:', startTime.toLocaleString());
}
function ColdCode(input, code) {
this.charCodes = {
' ': [['none','none','none','none','none','none','none','none','none','none']],
'A': [['black','gray','gray','white','none','none','none','none','none','none']],
'B': [['black','gray','none','none','none','none','yellow','green','green','blue']],
'C': [['none','none','gray','white','red','orange','orange','yellow','none','none']],
'D': [['black','gray','none','none','none','none','yellow','green','none','none']],
'E': [['black','gray','none','none','none','none','none','none','none','none']],
'F': [['black','gray','none','none','red','orange','orange','yellow','none','none']],
'G': [['none','none','gray','white','none','none','yellow','green','green','blue']],
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ColdCode Example</title>
<style>
/* Basic styles for the visual elements */
.character {
display: inline-block;
@frinkleko
frinkleko / settings.json
Created June 22, 2025 07:33
My VsCode settings json
{
"latex-workshop.latex.recipes": [
{
"name": "pdflatex->bibtex->pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
import os
import json
import requests
from typing import Optional, List, Dict, Any
# List of supported Dartmouth models
SUPPORTED_MODELS = [
"llama-3-8b-instruct",
"llama-3-1-8b-instruct",