Skip to content

Instantly share code, notes, and snippets.

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

yihong yihong0618

🏃‍♂️
Running
View GitHub Profile
@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 December 1, 2022 04:40
扇贝加密破解自动发送今日新词到 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 November 6, 2024 14:49
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 August 20, 2024 19:31
JavaScript Fetch API Examples
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active November 16, 2024 05:10
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).