Skip to content

Instantly share code, notes, and snippets.

@davidsharp
davidsharp / force-xhr-status-with-proxy.js
Created April 22, 2022 10:27
Proxying a XMLHttpRequest to force the status received
XMLHttpRequest = new Proxy(XMLHttpRequest, {
construct:function(t,a){
const req = new t();
return new Proxy(req, {
get:function(o,p){
if(p=='status')return 9001
return typeof o[p] == 'function'?o[p].bind(o):o[p]
},
set: function(target, prop, value) {
Reflect.set(target, prop, value) // or target[prop] = value
@tabjy
tabjy / ws.js
Created March 11, 2021 00:31
WebSocket from scratch. In Node.js
const http = require('http')
const crypto = require('crypto')
const server = http.createServer((req, res) => {
console.log('got request', req.url)
res.writeHead(200, { 'Content-Type': 'text/plain' })
res.end('okay')
})
server.on('upgrade', function (req, socket) {
@MichaelCurrin
MichaelCurrin / README.md
Last active April 6, 2025 18:23
GitHub GraphQL - Get files in a repository

Get GitHub Files

Get the metadata and content of all files in a given GitHub repo using the GraphQL API

You might want to get a tree summary of files in a repo without downloading the repo, or maybe you want to lookup the contents of a file again without download the whole repo.

The approach here is to query data from GitHub using the Github V4 GraphQL API.

About the query

@mohanpedala
mohanpedala / bash_strict_mode.md
Last active July 31, 2025 09:32
set -e, -u, -o, -x pipefail explanation
@johnbianchi
johnbianchi / pfctl-cheatsheet.txt
Last active July 29, 2025 07:34
pfctl cheat sheet
#### General PFCTL Commands ####
$ pfctl -d disable # packet-filtering
$ pfctl -e enable # packet-filtering
$ pfctl -q # run quiet
$ pfctl -v -v # run even more verbose
#### Loading PF Rules ####
$ pfctl -f /etc/pf.conf # load /etc/pf.conf
$ pfctl -n -f /etc/pf.conf # parse /etc/pf.conf, but dont load it
$ pfctl -R -f /etc/pf.conf # load only the FILTER rules
$ pfctl -N -f /etc/pf.conf # load only the NAT rules
@leonardoaramaki
leonardoaramaki / helloworld.dex.md
Created May 24, 2017 04:58 — forked from lifuzu/helloworld.dex.md
execute the dex file in android with command
public class HelloWorld {
    public static void main(String[] args) {
         System.out.println("Hello World!");
    }
}

To run it on an android device:

javac HelloWorld.java
/*****************************************************************************
MIT License, http://www.opensource.org/licenses/mit-license.php
Contact: [email protected]
Copyright (c) 2018 SQL Workbooks LLC
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom
@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active July 30, 2025 02:08
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
// 已知有如下可用类型
public interface ITextWriter {
void Write(string text);
void Write(string text, int startIndex, int count);
void Write(char[] chars);
void Write(char[] chars, int startIndex, int count);
}
// 需实现以下类型,输出value对应的字符串(不考虑本地化)。