Skip to content

Instantly share code, notes, and snippets.

View SanariSan's full-sized avatar
😯
1 2 Fizz 4 Buzz

SanariSan

😯
1 2 Fizz 4 Buzz
  • krak.ai
  • Georgia, Tbilisi
View GitHub Profile
@SanariSan
SanariSan / axios_proxy.js
Created October 18, 2021 17:43
Axios proxy http/s socks
// socks
// const axios_ = require("axios");
// const SocksProxyAgent = require("socks-proxy-agent");
import { default as axios_ } from "axios";
import SocksProxyAgent from "socks-proxy-agent";
const httpsAgent = new SocksProxyAgent("socks://127.0.0.1:1080");
const httpAgent = httpsAgent;
const axios = axios_.create({ httpsAgent, httpAgent });
@SanariSan
SanariSan / CommonJS-Modules.md
Last active February 27, 2022 17:21
__dirname / __filename with "Modules"

Replacement for __dirname and __filename when using Modules over CommonJS

import {fileURLToPath} from 'url';
import path from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@SanariSan
SanariSan / charles.sh
Created January 16, 2022 19:23
Charles notes
# Installing cert on ubuntu:
# Save .pem file from chares, convert it to .crt with
openssl x509 -in cert.pem -inform PEM -out cert.crt
# Move to /usr/local/share/ca-certificates/extra
sudo mv cert.crt /usr/local/share/ca-certificates/extra
# Run
sudo update-ca-certificates
#
# Import .pem to Firefox or anywhere
@SanariSan
SanariSan / puppeteerIncognito.js
Created February 4, 2022 21:45 — forked from regevbr/puppeteerIncognito.js
How to open "incognito" context in puppeteer
"use strict";
const Promise = require('bluebird');
const Page = require('puppeteer/node6/lib/Page');
function newPageWithNewContext(browser) {
let browserContextId;
let targetId;
let target;
return Promise.resolve()
@SanariSan
SanariSan / SERVICES.TXT
Created February 17, 2022 10:45
adb socket interaction
ORIGIN: https://android.googlesource.com/platform/system/core/+/android-2.3.4_r1/adb/SERVICES.TXT
This file tries to document all requests a client can make
to the ADB server of an adbd daemon. See the OVERVIEW.TXT document
to understand what's going on here.
HOST SERVICES:
host:version
Ask the ADB server for its internal version number.
As a special exception, the server will respond with a 4-byte
hex string corresponding to its internal version number, without
@SanariSan
SanariSan / OVERVIEW.TXT
Created February 17, 2022 10:46
adb key moments
ORIGIN: https://android.googlesource.com/platform/system/core/+/android-2.3.4_r1/adb/OVERVIEW.TXT
Implementation notes regarding ADB.
I. General Overview:
The Android Debug Bridge (ADB) is used to:
- keep track of all Android devices and emulators instances
connected to or running on a given host developer machine
- implement various control commands (e.g. "adb shell", "adb pull", etc..)
for the benefit of clients (command-line users, or helper programs like
DDMS). These commands are what is called a 'service' in ADB.
@SanariSan
SanariSan / reset.js
Created March 3, 2022 19:43 — forked from 19h/reset.js
Node.js — Clear Terminal / Console. Reset to initial state.
console.reset = function () {
return process.stdout.write('\033c');
}
@SanariSan
SanariSan / socket.js
Created March 5, 2022 12:15
Nodejs socket
//_____________________
// Server + Client
// Server
require('net').createServer((socket) => {
console.log("connected");
socket.on('data', (data) => {
console.log(data.toString());
});
@SanariSan
SanariSan / fetch-timeout.js
Last active April 5, 2022 18:18
Fetch timeout using abort controller
// by https://stackoverflow.com/a/50101022/15516769
// more info https://developers.google.com/web/updates/2017/09/abortable-fetch
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 30 * 1000);
fetch(url, { signal: controller.signal })
.then((response) => {
// completed request before timeout fired