Skip to content

Instantly share code, notes, and snippets.

@umonaca
umonaca / Sphinx.md
Last active November 23, 2021 00:04
Sphinx
@umonaca
umonaca / VS Code Python.md
Last active November 18, 2021 16:53
VS Code Settings for Python with Formatters and Linters

VS Code settings with Formatters and Linters

Tools / Packages

  • Black
  • Flake8
  • mypy
  • isort
  • darglint

.vscode/settings.json

@umonaca
umonaca / API draft.md
Last active March 5, 2021 23:00
Kikoeru API 草案

目前API路由非常混乱,产生安全性问题、性能问题等,也为了实现有效的前后端分离,需要大规模重构。
这里先预留一个位置,之后有空了编辑。

锁表原因?

我想了一下最可能造成此次锁表的原因。你是程序在线的时候执行的knex-migrate up吗?那样这次是有可能锁死。 如果你cherry-pick了 935681b14f4f41a6af27977d5cc1cae6c2f5817a 这个是为了解决之前打错字的情况,也为了这次你执行knex-migrate up能正确运行而不至于直接挂在前面的错误文件上。

当你执行knex-migrate的时候,它会读取knex_migrations表,对比没有执行过的migration文件,然后执行并把完成的migration记录文件名到这个表里面。

也就是说本次你应该是看到执行了两个migration:
20210223200240_drop_not_null_constraints.js
20210304101412_fix_view_userMetatdata.js

@umonaca
umonaca / 2019-https-localhost.md
Created January 28, 2021 12:28 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@umonaca
umonaca / cf-mastodon-proxy.js
Last active July 12, 2023 17:51
Unfinished Mastodon Cloudflare Worker Proxy
// Website you intended to retrieve for users.
//const upstream = 'www.google.com'
const upstream = '5a1eddaec0e1.ngrok.io'
// Custom pathname for the upstream website.
const upstream_path = '/'
// Website you intended to retrieve for users using mobile devices.
//const upstream_mobile = 'www.google.com'
const upstream_mobile = '5a1eddaec0e1.ngrok.io'
@umonaca
umonaca / cfworker.js
Last active February 18, 2023 05:49
Cloudflare worker media proxy (for Mastodon)
// DO Spaces isn't handling OPTIONS properly so I am manually setting them. It does not affect user experience, though.
// For DO Spaces, if Origin header is not set, DO won't return CORS headers at all. Must be set in the worker.
// Other references:
// https://community.cloudflare.com/t/injecting-cors-headers-in-response-larger-requests-fail/98479/7
// https://www.digitalocean.com/community/questions/setting-access-control-allow-origin-in-my-space-doesn-t-work-with
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
@umonaca
umonaca / avatar-cat.md
Last active February 7, 2023 15:30
Avatar cat for mastodon
.notification .status__avatar::before,
.notification .status__avatar::after {
  display: none !important;
}

.status__wrapper .status:first-child .status__avatar::before,
.status__wrapper .status:first-child .status__avatar::after,
.entry.h-entry .status__avatar div::before,
.entry.h-entry .status__avatar div::after,
@umonaca
umonaca / Mastodon-CI-CD.md
Last active July 8, 2020 09:22
Yet another simple CI/CD pipeline for mastodon using CircleCI
version: 2

aliases:
  - &defaults
    docker:
      - image: circleci/ruby:2.7-buster-node
        environment: &ruby_environment
          BUNDLE_JOBS: 3
          BUNDLE_RETRY: 3
@umonaca
umonaca / Upgrade-to-ver314.md
Last active June 30, 2020 09:22
升级指南

升级指南

备份好全站数据库。node最低10建议12,ruby 2.6.6.

主要功能上的变化是:

  • 增加一个在federated timeline和hashtag timeline上去除/显示本地toot的界面开关和相应的API endpoint

/api/v1/timelines/public 参数remote boolean