This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Answer to https://leetcode-cn.com/problems/integer-to-roman/ | |
function intToRoman(num) { | |
return [['X', 'V', 'I', 1], ['C', 'L', 'X', 10], ['M', 'D', 'C', 100], ['', '', 'M', 1000]] | |
.reduceRight(function (ret, item, index) { | |
let count = ~~(num / item[3]) % 10; | |
if (!count) return ret; | |
if (count % 5 == 4) return ret + item[2] + item[count > 5 ? 0 : 1]; | |
return ret + item[1].repeat(count >= 5 ? 1 : 0) + item[2].repeat(count % 5); | |
}, ''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
ffmpegParam="-hide_banner -y"; | |
videoEncodeParam="-c:v libx264 -crf 23 -profile:v main -level 3.1 -pix_fmt yuv420p -movflags +faststart -s 1024x768"; | |
audioEncodeParam="-an"; | |
fileSizeParam="-b:v 1.6M -maxrate 1.6M -bufsize 2m"; | |
echo "Convert: $1 -> $2"; | |
# Use two-pass to reduce size https://trac.ffmpeg.org/wiki/Encode/H.264 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# soagent consumes too much cpu resources for unknown reasons. | |
# The one way which i know so far to stop it is deleting it. | |
# Don't worry. An OS-update will take them back. (Just my personal experience) | |
rm -rf "/System/Library/LaunchAgents/com.apple.soagent.plist" | |
rm -rf "/System/Library/PrivateFrameworks/MessagesKit.framework/Versions/A/Resources/soagent.app" | |
rm -rf "~/Library/Application Scripts/com.apple.soagent" | |
rm -rf "~/Library/Containers/com.apple.soagent" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function smoothScrollTo(selector, duration) { | |
const FPS = 24 | |
let currentScrollY = window.scrollY | |
let targetScrollY = document.querySelector(selector).getBoundingClientRect().top + currentScrollY | |
let deltaY = (targetScrollY - currentScrollY) / (duration * FPS) | |
let interval = 1E3 / FPS | |
let scrollTimer | |
let scrollCallback = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const L = require('./leaflet-0.5.0-coord-part') | |
const simpleCrs = L.Util.extend({}, L.CRS, { | |
code : 'simple', | |
projection : L.Projection.LonLat, | |
transformation : new L.Transformation(1,0,-1,0) | |
}) | |
console.log( | |
L.CRS.EPSG3857.pointToLatLng( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path') | |
var fs = require('fs') | |
// 先在浏览器中把地图移动到右下角,一点一点放大,保证每个 level 的最大坐标的图片被请求了 | |
// 然后 network 中 copy all as curl 保存到 urls.txt 里 | |
var maxs = fs.readFileSync(path.join(__dirname, 'urls.txt'), 'utf8').split('\n').map(function (url) { | |
url = url.trim() | |
let i = url.indexOf('\'') + 1 | |
return url.substring(i, url.indexOf('\'', i)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function copyText(value) { | |
let fakeElem = document.createElement('TEXTAREA') | |
fakeElem.style.position = 'absolute' | |
fakeElem.style.left = '-9999px' | |
fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px' | |
fakeElem.readonly = true | |
fakeElem.value = value | |
document.body.appendChild(fakeElem) | |
fakeElem.focus() | |
fakeElem.setSelectionRange(0, value.length) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>test</title> | |
<style type="text/css"> | |
div { | |
width: 100px; | |
height: 100px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo rm -rf "/Applications/Calendar.app"; | |
sudo rm -rf "/Applications/Chess.app"; | |
sudo rm -rf "/Applications/Contacts.app"; | |
sudo rm -rf "/Applications/DVD Player.app"; | |
sudo rm -rf "/Applications/FaceTime.app"; | |
sudo rm -rf "/Applications/Mail.app"; | |
sudo rm -rf "/Applications/Maps.app"; | |
sudo rm -rf "/Applications/Notes.app"; | |
sudo rm -rf "/Applications/Photo Booth.app"; | |
sudo rm -rf "/Applications/Photos.app"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 在 m.weibo.cn 的 console 里跑 | |
*/ | |
let startPageNo = 1 | |
let pageLength = 90 | |
let delInterval = 1543 | |
let options = { |