Skip to content

Instantly share code, notes, and snippets.

Avatar
😂
Notion 出 API 前不会再造轮子了,bug 也没时间修,见谅

Mayne mayneyao

😂
Notion 出 API 前不会再造轮子了,bug 也没时间修,见谅
View GitHub Profile
View openapi.yaml
openapi: 3.0.0
servers:
- url: //petstore.swagger.io/v2
description: Default server
- url: //petstore.swagger.io/sandbox
description: Sandbox server
info:
description: |
This is a sample server Petstore server.
You can find out more about Swagger at
View vika-bot.js
// 钉钉机器人 webhook 请求,在 figma 插件中存在跨域限制,这个 proxy 脚本可以解决这个问题。
// https://gist.github.com/mayneyao/0688303382f999f9cfeed082a733fc0e
// deno deploy 暂不支持私密仓库的部署,先使用公开的 gist。
async function handleRequest(request) {
// For making a POST request we need to specify the method property
// as POST and provide data to the body property in the same object.
// https://post.deno.dev echoes data we POST to it.
const url = new URL(request.url);
const text = url.searchParams.get("text")
View deno_demo.ts
async function handleRequest(request) {
// We pass the url as the first argument to fetch and an object with
// additional info like headers, method, and body for POST requests as
// the second argument. By default fetch makes a GET request,
// so we can skip specifying method for GET requests.
const response = await fetch("https://api.github.com/users/denoland", {
headers: {
// Servers use this header to decide on response body format.
// "application/json" implies that we accept the data in JSON format.
accept: "application/json",
@mayneyao
mayneyao / notion2blog.js
Last active Sep 18, 2021
Notion.so > Personal Blog | custom domain + disqus comment
View notion2blog.js
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@mayneyao
mayneyao / README-Template.md
Created Aug 4, 2019 — forked from PurpleBooth/README-Template.md
A template to make good README.md
View README-Template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@mayneyao
mayneyao / dict2obj.py
Created Jul 19, 2019
Python 中字典转对象演示
View dict2obj.py
from types import SimpleNamespace
npc = {
'name': {
'first': 'san',
'last': 'zhang'
},
'hp': 1000
}
npc
npc = SimpleNamespace(**npc)
@mayneyao
mayneyao / github.bash
Created Mar 5, 2019 — forked from igrigorik/github.bash
Open GitHub URL for current directory/repo...
View github.bash
alias gh="open \`git remote -v | grep git@github.com | grep fetch | head -1 | cut -f2 | cut -d' ' -f1 | sed -e's/:/\//' -e 's/git@/http:\/\//'\`"
View notion_api.js
const axios = require('axios')
const { URLSearchParams } = require('url')
const getFullBlockId = (blockId) => {
if (typeof blockId !== 'string') {
throw Error(`blockId: ${typeof blockId} must be string`)
}
if (blockId.match("^[a-zA-Z0-9]+$")) {
return blockId.substr(0, 8) + "-"
+ blockId.substr(8, 4) + "-"
@mayneyao
mayneyao / react_conetxt_api 
Last active Jan 7, 2019
React(16.3+) Context API
View react_conetxt_api 
import React, {Component, createContext} from 'react';
import {setName} from "./actions";
const Context = createContext();
export class Provider extends Component {
genActions = () => {
let actions = {};
@mayneyao
mayneyao / export netease music top100
Last active Dec 28, 2018
导出 网易云音乐 听歌排行前100到 Spotify
View export netease music top100
let allSongsDiv = document.querySelectorAll('div.song > div.tt > div > span');
let songList = [];
allSongsDiv.forEach(item=>songList.push(item.innerText));
let clearSongList = songList.map(item=>{
let [name,artist] = item.split(" -");
return `${name} - ${artist}`
})
let text = clearSongList.join('\n');
text