Skip to content

Instantly share code, notes, and snippets.

View latel's full-sized avatar
😉
I may be slow to respond.

LaTale latel

😉
I may be slow to respond.
View GitHub Profile
const waitForJSBridge = new Promise((resolve, reject) => {
if (typeof window.StockJSBridge === 'undefined') {
let initTimer;
let _resolve = () => {
window.clearTimeout(initTimer);
resolve();
};
initTimer = window.setTimeout(() => {
reject();
}, 6000);
@latel
latel / futu.js
Last active August 28, 2020 02:27
抢futu美股现金种子和股票卡
let scriptLoaded = 0;
let scriptDayjs = document.createElement('script');
scriptDayjs.src =
'https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.8.16/dayjs.min.js';
let scriptJQuery = document.createElement('script');
scriptJQuery.src = 'https://libs.baidu.com/jquery/2.0.0/jquery.min.js';
let csrf = document.querySelector('meta[name="csrf-token"]').content;
let uid = document.cookie.match(/uid=(\d+)/)[1];
let ticker = 0;
let limit = 1;
@latel
latel / resolveNestedPromises.ts
Created February 15, 2019 08:55
Finds nested promises within the provided value/object and returns one promise that resolves when all nested promises are resolved.
/**
* Finds nested promises within the provided value/object and returns one
* promise that resolves when all nested promises are resolved.
* @param value The value to promisify.
*/
export const resolveNestedPromises = async <T>(value: T): Promise<T> => {
if (value instanceof Promise) return value;
if (value instanceof Array) {
const elements = value.map(entry => resolveNestedPromises(entry));
@latel
latel / jsonCookie.js
Created June 28, 2018 00:12
make document.cookie as json
var domain = location.host, jsonCookie = [];
document.cookie.split(';').forEach(cookie => {
let [ name, value] = cookie.trim().split('=');
jsonCookie.push({ name, value, domain,
expirationDate: 8880000000,
hostOnly: false,
httpsOnly: false,
path: '/',
sameSite: 'no_restriction',
secure: false,
@latel
latel / install.sh
Last active February 1, 2020 03:46
MacOS重装系统后快速恢复生产力
# sh -c "$(curl -L https://gist.githubusercontent.com/latel/0ce075dbbd47144fc1f3554607749dbd/raw/)" > install.log
#######run command above to recover #######
# install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# directories used to
mkdir -p ~/codes/playground
mkdir -p ~/codes/stockfe
mkdir -p ~/Documents/Tencent/stockfe
@latel
latel / disable_wechat_twitter
Created April 2, 2018 02:31
disable wechat-dev-tools from twittering
var _console = {
_disabledGroupFlags: [],
log: window.console.log.bind(window.console),
info: window.console.info.bind(window.console),
debug: window.console.debug.bind(window.console),
group: window.console.group.bind(window.console),
groupEnd: window.console.groupEnd.bind(window.console)
};
window.console.info = function() {
// 开发者工具中不显示vConsole的debug print
/*! Metro -v0.2.7 - 2015-05-29 */
!function() {
function template(filename, content) {
return (/string|function/.test(typeof content) ? compile : renderFile)(filename, content);
}
function toString(value, type) {
return "string" != typeof value && (type = typeof value, "number" === type ? value += "" : value = "function" === type ? toString(value.call(value)) : ""),
value;
}
/*
* 底部的播放条
* author: Kezhen Wang <latelx64@gmail.com>
* date: 2015/02/05
* version: 0.0.1
*/
define(
['LocalEvent', 'manSlider'],
function(LocalEvent, manSlider) {
@latel
latel / weight.php
Last active December 31, 2015 12:09
权重计算,用于返回一行文字在字典里哪一行的权重最高 变通一下亦可以用来做关键词匹配,分词等。
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------
// Name : Weight Calculat
// Description: provide weight calculation
// Date : 2013/12/16 08:51
// Authors : latel <latelx64@gmail.com>
// +------------------------------------------------------------------------
//