Skip to content

Instantly share code, notes, and snippets.

View yihong0618's full-sized avatar
🏃‍♂️
Running

yihong yihong0618

🏃‍♂️
Running
View GitHub Profile
local obj = {}
obj.__index = obj
-- Metadata
obj.name = "HammerspoonSwitchIME"
obj.version = "0.1"
obj.author = "Qiangning Hong"
obj.license = "MIT"
local ENGLISH_ID = "com.apple.keylayout.US"
@frostming
frostming / json_parser.py
Last active December 13, 2024 09:32
Python JSON Parser
from __future__ import annotations
import re
from typing import Any, Never
class JSONParseError(Exception):
pass
@grantslatton
grantslatton / gpt4chess.py
Created September 6, 2023 09:00
GPT4 Chess
import chess
import chess.engine
from collections import defaultdict
from marvin import ai_fn, ai_model
from pydantic import BaseModel, Field
def describe_board(board, illegal_moves):
result = ""
me = board.turn
@cloudwu
cloudwu / sortnumber.c
Created August 1, 2023 05:38
sort telephone number
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#define N (100000063/64)
struct bitset {
uint64_t bits[N];
@yihong0618
yihong0618 / shanbay_remember.js
Last active January 8, 2025 13:27
扇贝加密破解自动发送今日新词到 telegram
const https = require("https");
const token = ""; // change this to you telegram bot token!
const chatId = ""; // change this to your telegram chat id!
const cookie = ""; // change this to your shanbay cookie!
const PATH_API = (page) =>
`/wordsapp/user_material_books/blozps/learning/words/today_learning_items?ipp=10&page=${page}&type_of=NEW`;
const options = {
@tomsoderlund
tomsoderlund / Map.js
Last active December 3, 2024 17:40
Using fitBounds in ReactMapGL to center points on map
import React, { useState } from 'react'
import ReactMapGL, { Marker } from 'react-map-gl'
import { WebMercatorViewport } from '@deck.gl/core'
const getBoundsForPoints = (points, { width = 200, height = 500, padding = 0 } = {}) => {
// Calculate corner values of bounds
const pointsLong = points.map(point => point.coordinates._long)
const pointsLat = points.map(point => point.coordinates._lat)
const cornersLongLat = [
[Math.min(...pointsLong), Math.min(...pointsLat)],
@leihuang23
leihuang23 / trie.js
Created March 29, 2020 23:07
Trie implemented in JavaScript
class TrieNode {
constructor(char) {
this.char = char;
this.validWord = false;
this.parent = null;
this.children = [];
}
}
class Trie {
@dabeaz
dabeaz / aproducer.py
Created October 17, 2019 17:46
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
@crazyboycjr
crazyboycjr / word_list.js
Created September 1, 2019 09:03
扇贝背单词小插件
// usage: open chrome console, paste this and enter
const WORD_PER_PAGE = 10;
const START_PAGE = 1;
const END_PAGE = 10;
const BOOK_ID = 'tvbmg';
// const WORD_LIST_TYPE = 4; // 今日新词
const WORD_LIST_TYPE = 5; // 今日复习
function playItHere(e, link) {
@justsml
justsml / fetch-api-examples.md
Last active April 5, 2025 13:18
JavaScript Fetch API Examples