Skip to content

Instantly share code, notes, and snippets.

View kebot's full-sized avatar
🏠
Working from home

Keith Yao kebot

🏠
Working from home
View GitHub Profile
@kebot
kebot / gen-epub.ts
Last active October 25, 2023 07:55
Generate Epub for Omnivore Articles (new version see here -> https://github.com/agrmohit/omnivore-epub )
// get a list of articles based on search endpoint
import { gql, GraphQLClient } from 'npm:graphql-request'
import sanitizeHtml from 'npm:sanitize-html'
import epub, { Chapter } from 'npm:epub-gen-memory'
const OMNIVORE_API_KEY = ''
const OMNIVORE_ENDPOINT = 'https://api-prod.omnivore.app/api/graphql'
const graphQLClient = new GraphQLClient(OMNIVORE_ENDPOINT, {
headers: {
@kebot
kebot / docker-compose.yml
Created November 4, 2022 10:54
Mastodon homelab/nas with Cloudflare tunnel
version: '2.4'
networks:
http_network:
external: true
mastodon_network:
external: false
internal: true
@kebot
kebot / remove-zhihu.js
Created December 2, 2020 09:45
userscript: remove zhihu
// ==UserScript==
// @name Remove Zhihu
// @namespace http://pornhub.com/
// @version 0.1
// @description browse zhihu without login
// @author You
// @match https://www.zhihu.com/*
// @grant none
// ==/UserScript==
@kebot
kebot / hfn.once.js
Created July 30, 2018 09:57
hfn - hot functions
const asyncOnce = (fn) => {
const promise
return (...args) => {
if (!promise) {
promise = fn.apply(null, args)
}
return promise
}
}
@kebot
kebot / anmeldung-wohnung.js
Created July 14, 2017 12:57
check Anmeldung einer Wohnung in Berlin
const request = require('request')
const cheerio = require('cheerio')
const urls = [
'https://service.berlin.de/terminvereinbarung/termin/tag.php?termin=1&anliegen[]=120686&dienstleisterlist=122210,122217,122219,122227&herkunft=http%3A%2F%2Fservice.berlin.de%2Fdienstleistung%2F120686%2F',
'https://service.berlin.de/terminvereinbarung/termin/tag.php?termin=1&dienstleister=122210&anliegen[]=120686&herkunft=1',
'https://service.berlin.de/terminvereinbarung/termin/tag.php?termin=1&dienstleister=122217&anliegen[]=120686&herkunft=1',
'https://service.berlin.de/terminvereinbarung/termin/tag.php?termin=1&dienstleister=122219&anliegen[]=120686&herkunft=1',
'https://service.berlin.de/terminvereinbarung/termin/tag.php?termin=1&dienstleister=122227&anliegen[]=120686&herkunft=1',
'https://service.berlin.de/terminvereinbarung/termin/tag.php?termin=1&anliegen[]=120686&dienstleisterlist=122231,122243&herkunft=http%3A%2F%2Fservice.berlin.de%2Fdienstleistung%2F120686%2F',
// matchfilters performance: https://github.com/yarnpkg/yarn/blob/master/src/util/filter.js#L96
const path = require('path');
let filter = {
base: 'node_modules/xml-escape',
isNegation: false,
regex: /^(?:(?!\.)(?=.)[^\/]*?\.seed)$/i
},
basename = 'branches',
@kebot
kebot / TTPlayer(LRC).py
Created June 3, 2016 09:49 — forked from douo/TTPlayer(LRC).py
Lyrics Grabber2 的千千静听歌词抓取脚本
# -*- coding: utf-8 -*-
import encodings.utf_8
import math
import urllib, urllib2
import random
import re
from xml.dom import minidom
from LevenshteinDistance import LevenshteinDistance
from grabber import LyricProviderBase
@kebot
kebot / lodash-v3-import-to-v4.js
Created May 21, 2016 16:56
codemod that upgrade lodash v3 import to v4
// this codemod will replace all 'lodash/<whatever>/<func>' -> 'lodash/<func>'
// usage: jscodeshift -t tools/lodash-3-4.js src
let transformModuleName = (name) => {
let matchObj = name.match(/^lodash\/(.*)\/(.*)/)
if(matchObj) {
return ['lodash', matchObj[2]].join('/')
}
return name
}
@kebot
kebot / webpack.config.js
Last active February 18, 2016 08:33
Mix normal css and css-module in webpack
module.exports = {
// ...
module: {
loaders: [{
test: /\.module\.(scss|css)$/,
loaders: [
'style-loader', 'css-loader?module', 'autoprefixer-loader',
'sass-loader'
]
}, {
int stepSize = 5;
int r = -45;
draw() {
rotate(radians(r));
r += stepSize;