Show newer

林俊杰可千万别翻车啊,我还想听他的歌的

王小美 boosted

恭喜@孤高云镇魂雨 @唐家造 @Hoshi丶可乐 等5位同学中奖,已私信通知,详情请点击互动抽奖查看。
//转发自: @坎公骑冠剑: ​互动抽奖 ‍
🆕坎公快讯!《坎公骑冠剑》原声CD第一期上线!流浪歌手塞西尔🎻原声CD现已上线《坎公骑冠剑》官方bilibili账号,守护者可前往【投稿 - 音频】进行下载畅听!社区征集活动 社区现已开启!

即日起~8月10日23:59,守护者带话题 ,分享塞西尔歌曲相关的创作视频(形式不限!翻唱、创作、用于BGM均可)。@坎特伯雷公主求鸡腿 会不定期奉上自己的“一键三连”,并且转发分享在 中!此外,我们将在活动结束后,为投稿点赞量最高的3位守护者,送出《坎公骑冠剑》官方周边1份!

期待各路守护者的精彩创作!转发并关注本条动态,我们将在8月2日抽取5位守护者,送出塞西尔钥匙扣和随机游戏色纸一份!

:sys_bilibili: t.bilibili.com/554215716522070

已更新到 Mastodon v3.4.1 (实际上是更新到latest commit),两三个月没合代码,rebase了一早上 :genshin_hutao_yawn:

王小美 boosted

KMP算法实现字符串匹配和替换,JS ver.

class Solution {
  public static matchTable(str: string) {
    const strLen = str.length;
    const table: number[] = [];
    for (let pos = 0; pos < strLen; pos++) {
      let prefix: string[] = [];
      let suffix: string[] = [];
      for (let cursor = 0; cursor <= pos; cursor++) {
        prefix.push(str.slice(0, cursor));
        suffix.push(str.slice(cursor + 1, pos + 1));
      }
      prefix = prefix.filter((s) => s);
      suffix = suffix.filter((s) => s);
      const match: string[] = [""];
      prefix.forEach((pf) => {
        suffix.forEach((sf) => {
          if (pf === sf) {
            match.push(pf);
          }
        });
      });
      table.push(Math.max(...match.map((s) => s.length)));
    }
    return table;
  }

  public static matchString(target: string, search: string): number {
    const matchTable = this.matchTable(search);
    const targetLen = target.length;
    const searchLen = search.length;
    if (targetLen < searchLen) return -1;
    let pos = 0;
    while (pos <= targetLen - searchLen) {
      for (let cursor = 0; cursor < searchLen; cursor++) {
        if (target[pos + cursor] === search[cursor]) {
          if (cursor === searchLen - 1) {
            return pos;
          } else {
            continue; // for
          }
        } else {
          pos += cursor + 1 - matchTable[cursor];
          break; // for
        }
      }
    }
    return -1;
  }

  public static replace(A = "hello world", B = "hello", C = "Mars") {
    const lenA = A.length;
    const lenB = B.length;
    let res = A;
    const pos = this.matchString(res, B);
    if (pos >= 0) {
      res = res.slice(0, pos) + C + res.slice(pos + lenB, lenA);
      return res;
    } else {
      this.replace(res, B, C);
    }
    return res;
  }
}

console.log(Solution.replace("hello world", "world", "mars"));
王小美 boosted

埋头写了一个月,没跑eslint,今天一跑完蛋 :genshin_diona_restless:

王小美 boosted
王小美 boosted

Vue3 useKeepAliveWindowScrollTop hook 

import { onDeactivated, watch, onActivated } from 'vue'
import { useWindowScroll } from '@vueuse/core'
import { useState } from '@/hooks'

export default function () {
  const { scrollTop, scrollLeft } = (function () {
    const { x, y } = useWindowScroll()
    return { scrollTop: y, scrollLeft: x }
  })()

  const [scrollTopCache, setScrollTopCache] = useState(0)
  const [isScrollTopSet, setIsScrollTopSet] = useState(false)

  watch(scrollTop, (value) => {
    if (!isScrollTopSet.value) return
    setScrollTopCache(value)
  })

  onActivated(() => {
    window.scrollTo(scrollLeft.value ?? 0, scrollTopCache.value)
    setIsScrollTopSet(true)
  })

  onDeactivated(() => {
    setIsScrollTopSet(false)
  })
}
王小美 boosted
王小美 boosted
王小美 boosted
王小美 boosted
王小美 boosted
王小美 boosted

等了三年终于返场了,阿离是我玩的最多的一个英雄,可惜今年那个牛年限定皮肤的手感不好,创造营那个bulinbulin的不舒服,花间舞嘛,用了上千局,确实有点腻了 :weibo_d_erha:

王小美 boosted

Congratulations to Day 3's winners @ElySimpTq, @Wolfthedark15! Please send the required information to [email protected]. Retweet the original post each day and you might have a chance to win all the rewards!

Arknights_EN: Dear Doctor, we're holding a giveaway event to celebrate Arknights' 1.5 anniversary. Retweet this post with your wish (words or images) for Arknights and 2 tags: , and you will get a chance to win the following rewards!

:sys_twitter: twitter.com/ArknightsEN/status

Show older
小森林

每个人都有属于自己的一片森林,也许我们从来不曾走过,但它一直在那里,总会在那里。迷失的人迷失了,相逢的人会再相逢。愿这里,成为属于你的小森林。