Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@huanggm
huanggm / interview.md
Last active October 12, 2023 09:38
面试题-笔试题记录

第一题:考察this和作用域

inner = 'window';

function say() {
    console.log(inner);
    console.log(this.inner);
}
@huanggm
huanggm / pre-app-install.md
Last active November 28, 2021 08:39
初始化一台电脑需要的软件

软件

谷歌浏览器

登陆谷歌账号-同步主题和插件
安装DevDocs应用

iterm2

In iTerm2 preferences, click on the "Keys" tab. In the bottom left, under "Hotkey", check "Show/hide iTerm2 with a system-wide hotkey" and assign the hotkey you'd like to use.

Command Line Tools

安装命令1:git --version

@huanggm
huanggm / pentagon5.js
Last active July 17, 2020 07:48
只用svg path命令绘制空心正五边形,需要注意fill的规则
//min: 内径长度
//max: 外径长度
function pentagon5(min, max) {
const minPoint = transform(getBasePoint(min), max);
const maxPoint = transform(getBasePoint(max), max);
maxPoint.reverse();
return toStr(minPoint) + toStr(maxPoint)
function getBasePoint(base) {
// 录音数据是共享内存的,所以在一个回调事件内是有效的
// 下一个回调事件内则会把上一份数据覆盖
const f32 = event.inputBuffer.getChannelData(0);
// 复制一份内存数据
const f32Ret = new Float32Array(f32);
// 把一个音频文件切片,分次上传
this.http.get('http://local.yuanfudao.ws:3000/assets/rec-001.wav', {
responseType: 'blob'
@huanggm
huanggm / 测网速原理.js
Created April 14, 2020 08:47
测试网速可以使用XMLHttpRequest对象的onprogress事件实现
function speedtest() {
var xmlhttp = new XMLHttpRequest(),
method = "GET",
url = "http://109.123.87.183/speedtest.256mb";
const start = Date.now();
xmlhttp.open(method, url, true);
xmlhttp.onprogress = function (e) {
const dnow = Date.now();
const miao = (dnow - start) / 1000;
const mb = 1024 * 1024;
@huanggm
huanggm / baiduyun.js
Last active April 13, 2020 03:30
获取百度云文件夹大小
async function getCurrentSize() {
let dirCount = 0, fileCount = 0;
let path = location.href.match(/path=([^&]+)/);
path = decodeURIComponent(path[1])
console.log('starting...')
const res = await getSize(path)
console.log(res, dirCount, fileCount)
async function getSize(path) {
const res = await getInfo(path)
@huanggm
huanggm / xcode
Created October 27, 2019 12:44
安装xcode
You also need to install the XCode Command Line Tools by running xcode-select --install.
Alternatively, if you already have the full Xcode installed, you can find them under the menu
Xcode -> Open Developer Tool -> More Developer Tools....
This step will install clang, clang++, and make.
var ms = new SpeechSynthesisUtterance("ある程度の人数を集めなければいけなかったので、実父の趣味で「祭り」の仲間に大勢来てもらう事が出来ました。そのおかげで、友人は居ませんでしたが、和太鼓の演舞や新郎を簡易のお神輿に乗せて練り歩く等の余興をしてもらう事ができて、とても賑やかな式になりました。 (40歳/女性)");
msg.lang = 'ja-JP';
msg.rate = 0.8;
var list = speechSynthesis.getVoices();
var newlist = list.filter(l => l.lang.indexOf('ja') >= 0)
console.log(newlist)
msg.voice = newlist[0]
window.speechSynthesis.speak(msg);
@huanggm
huanggm / chrome extensions gist.js
Last active January 5, 2019 07:23
浏览器扩展
//content scripts 与页面通信
var port = chrome.runtime.connect();
window.addEventListener("message", function(event) {
// We only accept messages from ourselves
if (event.source != window)
return;
if (event.data.type && (event.data.type == "FROM_PAGE")) {
console.log("Content script received: " + event.data.text);
//重写UploadFile和xhrUploadImg
function changeGlobalUploadFilePrototype() {
if (!window.FileReader || !window.FormData) {
// 如果不支持html5的文档操作,直接返回
return;
}
var E = wangEditor;
wangEditor.UploadFile.fn.selected = function(e, input) {