Skip to content

Instantly share code, notes, and snippets.

View xixilive's full-sized avatar
🌴
On vacation

xixilive xixilive

🌴
On vacation
View GitHub Profile
@xixilive
xixilive / PDF_process.md
Created June 21, 2024 05:01
PDF process

PDFCPU steps for Horizontal-to-Vertical layout:

1. split Horizontal pages;

pdfcpu split horizontal_input.pdf ./out

2. crop splitted pages;

@xixilive
xixilive / withNativeWechat.ts
Last active January 3, 2024 16:18
a expo config plugin for native-wechat
import fs from 'node:fs'
import path from 'node:path'
import { ExpoConfig } from '@expo/config-types'
import {
ConfigPlugin, createRunOncePlugin, IOSConfig, AndroidConfig,
withInfoPlist, withEntitlementsPlist, withXcodeProject,
withMainApplication, withAndroidManifest, AndroidManifest
} from 'expo/config-plugins'
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
@xixilive
xixilive / createStorageMessageFrame.js
Last active April 10, 2019 06:44
use storage event in iframe
function createStorageMessageFrame(){
const listener ='function(e){window.top.postMessage({key: e.key, oldValue: e.oldValue,newValue: e.newValue}, \''+ window.location.origin +'\')}'
const frame = document.createElement('iframe')
frame.style.width = 0
frame.style.height = 0
frame.style.border = 'none'
frame.style.overflow = 'hidden'
frame.style.visibility = 'hidden'
document.body.appendChild(frame)
@xixilive
xixilive / utils.js
Last active March 9, 2019 14:31
utils for node fs
// utitlies module
const path = require('path')
const fs = require('fs')
const noop = () => {}
const debug = process.env.DEBUG ? console.log : noop
// lang functions
const toString = Object.prototype.toString
const typeChecker = (expect) => (val) => toString.call(val) === `[object ${expect}]`
@xixilive
xixilive / regexp_performance.js
Created September 4, 2018 02:46
Performance testing of a javascript RegExp matching
function strip1(name){
return name.replace(/^(\/*)|(\/*)$/g, '')
}
function strip2(name){
return name.replace(/^(\/+)|(\/+)$/g, '')
}
let str = "///packages/comm/packa/packages/packages/commocomm/packages/"
@xixilive
xixilive / weapp-inspector.js
Created January 6, 2017 02:36
wechat applet simulator features inspector
/**
A simple inspector function to detect applet runtime features, such as new functions, new globals etc.
It will report detecting result in the console panel.
*/
const features = {
object: {
assign: true,
is: true,
setPrototypeOf: true,
keys: true,

微信小程序模块化开发实践

准备

npm install \
--registry=http://registry.npm.taobao.org \
--dist-url=http://npm.taobao.org/mirrors/node \
--build-from-source=v8-profiler\
--phantomjs_cdnurl=http://cnpmjs.org/downloads
@xixilive
xixilive / email_regexp.js
Created June 11, 2015 09:54
Email RegExp from Loopback.io
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;