Skip to content

Instantly share code, notes, and snippets.

@maxgaurav
maxgaurav / functional-http-service.ts
Last active September 15, 2023 11:44
A Interceptor system for raw ajax on rxjs to get same functionality as in angular http client interceptor.
import { ajax, AjaxConfig, AjaxResponse } from 'rxjs/ajax';
import { from, Observable, of, OperatorFunction, switchMap } from 'rxjs';
export type BeforeInterceptors = (config: AjaxConfig) => Promise<AjaxConfig> | AjaxConfig | Observable<AjaxConfig>;
export type AfterInterceptors<T extends any = any> = (response: AjaxResponse<T>) => Observable<AjaxResponse<T>> | AjaxResponse<T> | Promise<AjaxResponse<T>>;
const BEFORE_INTERCEPTORS: BeforeInterceptors[] = [];
const AFTER_INTERCEPTORS: AfterInterceptors[] = [];
interface ConfigInterceptor {
http -v -j POST https://hkt-mobile-api.nowtv.now.com/09/1/getLiveURL mode=prod format=HLS callerReferenceNo=20190707123320 channelno=332 deviceType=5 deviceId=7634de3e186676d537OA
http -v -j POST https://api.viu.now.com/p8/2/getLiveURL mode=prod format=HLS callerReferenceNo=20190707123320 channelno=100 deviceType=5 deviceId=7634de3e186676d537
@dongri
dongri / uninstall-netskope.sh
Last active February 16, 2024 15:23
uninstall netskope
#!/bin/sh
sudo ps aux | grep Netskope | grep -v grep | awk '{ print "kill -9", $2 }' | sudo sh
echo '[✓] Kill Netskope Process'
sudo rm -rf /Applications/Remove\ Netskope\ Client.app
echo '[✓] Removed Remove Netskope Client.app'
sudo rm -rf /Library/Application\ Support/Netskope
echo '[✓] Removed Agent of Netskope Client.app'
@loopmode
loopmode / get-dev-dependencies.js
Last active November 11, 2019 06:45
Node.js function to get the names of all devDependencies in a yarn or lerna workspace
module.exports = async function getDevDependencies(globs = ['package.json', 'packages/*/*.json']) {
const globby = require('globby');
const packageFiles = await globby(globs, { absolute: true });
return packageFiles.reduce((result, file) => {
const pkg = require(file);
if (pkg.devDependencies) {
const names = Object.keys(pkg.devDependencies);
return result.concat(names.filter(name => !result.includes(name)));
}
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active May 3, 2024 12:55
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@ThaddeusJiang
ThaddeusJiang / React RoadMap 自检表.md
Last active April 21, 2023 14:43
React RoadMap 自检表

React RoadMap 自检表

2022年: react-roadmap-2022

2018年:

react-roadmap

1. Build Tools

@gongpeione
gongpeione / getWeiboDataBack.js
Last active April 4, 2024 07:51
微博炸号找回部分内容
/**
* 1 打开 https://m.weibo.cn/beta 登陆你被炸的账号
* 2 打开浏览器控制台
**/
function delay (time) {
return new Promise(r => {
setTimeout(() => r(), time || 1000); // 延时 1s,可适当增加延长时间
});
}
@Atinux
Atinux / async-foreach.js
Last active October 10, 2023 03:04
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@hectorguo
hectorguo / getLocalIP.js
Last active March 18, 2024 06:21
Get local IP address through Javascript
/**
* Get Local IP Address
*
* @returns Promise Object
*
* getLocalIP().then((ipAddr) => {
* console.log(ipAddr); // 192.168.0.122
* });
*/
function getLocalIP() {