Skip to content

Instantly share code, notes, and snippets.

View Zxilly's full-sized avatar
🌐
R.I.P

Zxilly

🌐
R.I.P
View GitHub Profile
/**
* Check out the blog post, "How to mock a third party ES6 export in Vitest", at:
* https://dev.to/erikpuk/how-to-mock-a-third-party-es6-export-in-vitest-38ff
*/
// Import the module:
import * as Firestore from "firebase/firestore"
import { test, vi } from "vitest"
type FakeFirestore = { onSnapshot(this: void): void }
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/product.schema.json",
"title": "sing-box config schema",
"type": "object",
"$defs": {
"listableString": {
"$comments": "ref:https://github.com/SagerNet/sing-box/blob/b0db869b052aa32ec1716e43f7c1f50d7e491057/option/types.go#L77",
"description": "allow not having to be an array when there's single item",
"oneOf": [
@MaxXSoft
MaxXSoft / Dockerfile
Created November 27, 2022 09:40
A fun tool for generating an x86-64 Linux program that runs in reverse order.
FROM ubuntu:20.04
RUN apt update && DEBIAN_FRONTEND="noninteractive" apt install -y \
python3 build-essential
WORKDIR /root
@sxzz
sxzz / QQ-NT-package.json
Last active February 28, 2024 02:43
package.json for QQ-NT
{
"name": "QQ-NT",
"version": "6.8.3-4068",
"private": true,
"description": "QQ-NT",
"productName": "QQ-NT",
"author": {
"name": "Tencent",
"email": "QQ-Team@tencent.com"
},
@abersheeran
abersheeran / proxy.worker.js
Last active April 13, 2024 08:45
A proxy download cloudflare worker
addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
async function handleRequest(request) {
const url = getUrl(request)
@sindresorhus
sindresorhus / esm-package.md
Last active July 22, 2024 10:50
Pure ESM package

Pure ESM package

The package that linked you 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.
@FreddieOliveira
FreddieOliveira / docker.md
Last active July 22, 2024 05:32
This tutorial shows how to run docker natively on Android, without VMs and chroot.

Docker on Android 🐋📱

Edit 🎉

All packages, except for Tini have been added to termux-root. To install them, simply pkg install root-repo && pkg install docker. This will install the whole docker suite, left only Tini to be compiled manually.


Summary

@varunon9
varunon9 / AlwaysRunningAndroidService.md
Last active April 20, 2024 23:38
How to create an always running service in Android

Full Source Code: https://github.com/varunon9/DynamicWallpaper/tree/always_running_service

Steps-

  1. Create a Foreground Service (MyService.java)
  2. Create a Manifest registered Broadcast Receiver (MyReceiver.java) which will start your Foreground Service
  3. In onDestroy lifecycle of MyService, send a broadcast intent to MyReceiver
  4. Launch the MyService on app start from MainActivity (see step 8)
  5. With above 4 steps, MyService will always get re-started when killed as long as onDestroy of Service gets called
  6. onDestroy method of Service is not always guaranteed to be called and hence it might not get started again
@unitycoder
unitycoder / AndroidManifest.xml
Last active March 30, 2024 19:39
Oculus Quest Android Manifest (with READ_EXTERNAL_STORAGE, LAUNCHER and SkipPermissionsDialog)
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto">
<uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" /><!-- Request the headset DoF mode -->
<application
android:label="@string/app_name"
android:icon="@mipmap/app_icon">
<activity
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
@shyiko
shyiko / weakmap.go
Created June 16, 2019 04:05
go sync/weakmap
package weakmap
import (
"reflect"
"runtime"
"sync"
)
type Key = interface {}
type Value = interface {}