Skip to content

Instantly share code, notes, and snippets.

View jo32's full-sized avatar
🎯
Focusing

jo32

🎯
Focusing
View GitHub Profile
@jo32
jo32 / error.md
Created October 7, 2023 12:42
jest-unit-error-closevector_web
 FAIL  src/vectorstores/tests/closevector_web.test.ts
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.
@jo32
jo32 / machine.js
Last active May 10, 2020 10:53
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
interface GWxApiOpts<T, K> {
success?: (callbackPayload: T) => any,
fail?: (callbackPayload: K) => any
}
type WxApiOpts<T, K, V> = {
[X in keyof V]: V[X]
} & GWxApiOpts<T, K>
/**
@jo32
jo32 / promisify.ts
Created August 16, 2019 07:53
Promisify WeApp API in TypeScript and preserving type.
interface WxApiOpts<T, K>{
[k: string]: any,
success?: (callbackPayload: T) => any,
fail?: (callbackPayload: K) => any
}
/**
* 本方法将类似于 wx.request 等函数转化为 Promise 调用方式
* @param callbackStyleFunction 被转换的函数,该类型函数只接受一个 Object 类型参数,且必须具备 success 和 fail 回调。
* @param opts 防止 success 回调叫 success 的情况,传此参数进行重载。
@jo32
jo32 / RecursiveLinkedStateMixin.js
Last active February 1, 2016 11:27
LinkedStateMixin supporting linked dot expression
/**
* not offical link state mixin, created by jolamjiang, 20160201184405
* Usage:
* <input type="text" className="form-control" id="rule-name" valueLink={this.linkState('rule.rule_name')} />
*/
'use strict';
var ReactLink = require('react/lib/ReactLink');
function getKeyValueRecursively(obj, key) {
if (!obj || !key) {
@jo32
jo32 / toc.js
Created December 16, 2015 07:58
auto toc
var autoToc = (function() {
function getHeadingArray(container, headingStartLevel) {
var array = [];
var currentNode = document.querySelector(container + ' h' + headingStartLevel);
var counter = 0;
while (currentNode) {
if (currentNode.tagName.match(/^H[1-9]$/)) {
var id = "SECTION-" + ++counter;
currentNode.setAttribute('id', id);
@jo32
jo32 / douyu-block-anchor.js
Created October 26, 2015 16:36
Douyu Anchors Block Script for Greasemonkey
// ==UserScript==
// @name Block Douyu Author
// @namespace http://jiangdl.com/
// @version 0.1
// @description Block Douyu Author
// @author You
// @match http://www.douyutv.com/directory/game/*
// @grant none
// ==/UserScript==
@jo32
jo32 / cf120f.md
Last active October 20, 2015 03:30
CODEFORCE 120F

cpp 版显示 wrong answer,没有输出, python 版显示 runtime error,没有提示,但是本地测试过测试用例都没有问题,算法应该是正确的。

@jo32
jo32 / cf459e.cpp
Last active October 18, 2015 18:06
CODEFORCE 459E
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAX 300007
using namespace std;
struct Edge {
int u;
@jo32
jo32 / cf159d.cpp
Last active October 15, 2015 14:42
CODEFORCE 159D
#include <cstdio>
#include <cstring>
#include <iostream>
const int maxN = 2048;
int dpLR[maxN];
int dpRL[maxN];
bool dpPalin[maxN][maxN];
char s[maxN];
long long ans = 0;