This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
import re | |
from typing import Any, Never | |
class JSONParseError(Exception): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TrieNode { | |
constructor(char) { | |
this.char = char; | |
this.validWord = false; | |
this.parent = null; | |
this.children = []; | |
} | |
} | |
class Trie { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
NewerOlder