Skip to content

Instantly share code, notes, and snippets.

View alsotang's full-sized avatar

alsotang alsotang

View GitHub Profile
@alsotang
alsotang / 24_game.json
Created February 21, 2024 11:51
all solutions of 24 game
{
"1,1,1,8": [
"(1+1+1)×8"
],
"1,1,1,11": [
"(11+1)×(1+1)"
],
"1,1,1,12": [
"(1+1)×12×1"
],
@alsotang
alsotang / frame_rate.html
Created December 4, 2023 04:23
use requestAnimationFrame to calculate frameRate
<body>
<script>
// record every requestAnimationFrame interval and use them to calculate the average framerate.
let frameRate = 0;
let historyInterval = [];
let historyIntervalLength = 200;
let lastTime = Date.now();
requestAnimationFrame(function loop() {
@alsotang
alsotang / DirtyCheckComponent.ts
Last active October 23, 2023 02:41
在 cocos creator 中实现数据绑定视图
import { _decorator, Component } from 'cc'
const { ccclass, property } = _decorator;
/** 浅对比是否相同 */
function isShallowEqual(value: Record<string, any>, other: Record<string, any>) {
if (value === other) {
return true
}
if (!value || !other) {
return false
@alsotang
alsotang / query
Created November 19, 2022 17:03
query data transfer of a domain on Cloudflare
https://developers.cloudflare.com/analytics/graphql-api/
{
viewer {
zones(filter: {zoneTag: $tag}) {
httpRequests1dGroups(limit: 7, orderBy: [date_DESC], filter: {date_in: ["2022-11-19", "2022-11-18"]}) {
dimensions {
date
}
sum {
@alsotang
alsotang / P01iptables.sh
Created September 13, 2021 14:10
华硕路由器的科学上网插件与访客网络冲突的解决办法
# 新建一个这个文件,给 chmod +x 权限,放到此位置:/jffs/.koolshare/ss/postscripts/P01iptables.sh
#!/bin/sh
# shadowsocks script for HND/AXHND router with kernel 4.1.27/4.1.51 merlin firmware
# 此脚本是一个示例,实际写法按照自己的方法来做
# 更改此脚本的名字,保证此脚本的名字格式是: P+数字+名字.sh
# 例如在/koolshare/ss/postscripts下放入两个脚本:P01V2xxx.sh, P99Brook.sh
# SS插件运行后货自动按照数字从小到大顺序运行 P01xxx.sh start, P99Brook.sh start
@alsotang
alsotang / all_css_props.js
Created August 24, 2021 08:11
get all css props
// in chrome console
[...getComputedStyle(document.body)]
@alsotang
alsotang / strange_go_slice.go
Created July 17, 2021 17:40
strange_go_slice.go
package main
import "fmt"
func main() {
a := []int{1, 2, 3}
b := a[0:2]
fmt.Println(cap(a), cap(b))
@alsotang
alsotang / determin_ascii.js
Last active July 9, 2021 18:36
determin_ascii.js
/*
js logic x 8,931,284 ops/sec ±0.48% (90 runs sampled)
re x 9,434,634 ops/sec ±0.66% (92 runs sampled)
Fastest is re
*/
const Benchmark = require('benchmark')
var suite = new Benchmark.Suite;
const str = 'aldfkjlakdsjflajkdsflakjdfjzakljerowiuetoywoihgkhgkzjcvlzcnvkjsdfbalhdfl'
const start = 65;
@alsotang
alsotang / getLanAddress.js
Created May 11, 2021 08:09
get lan ip in node.js
const os = require('os')
function getLanAddress() {
const ifaces = os.networkInterfaces();
if (ifaces) {
for (const dev of Object.keys(ifaces)) {
for (const details of ifaces[dev]) {
if (details.family === 'IPv4' && details.mac !== '00:00:00:00:00:00') {
return details.address;
}
@alsotang
alsotang / weibo.js
Created April 16, 2021 13:25
把所有微博设成仅自己可见
// 在微博个人主页运行
// 途中需要手动删除不能被设置的微博,大概5分钟出现一次。原因不明。
// 此脚本最好运行3遍或以上。
window.ff = $;
window.addPage = function () {
window.ff('.page.next.S_txt1.S_line1').click()
};
setInterval(function () {
var oriy = window.scrollTop;
console.log(`orix`, oriy);