Skip to content

Instantly share code, notes, and snippets.

View davistran86's full-sized avatar

davistran86

View GitHub Profile

Delete non-leaf user in Active Directory

Extended control

https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ldap/extended-controls

Example

const { Client } = require("ldapts");
const { Control } = require("ldapts/controls");
@davistran86
davistran86 / fix.md
Last active November 28, 2020 07:41
Fix MacOS EXC_CRASH (Code Signature Invalid)

Install xcode command line tool

xcode-select --install

Fix crashed app:

sudo codesign --force --deep --sign - /Applications/SonicWall\ Mobile\ Connect.app
@davistran86
davistran86 / README.org
Created November 17, 2020 08:49 — forked from jcouyang/README.org
Promise All with Limit of Concurrent N

The Promise All Problem

in case of processing a very large array e.g. Promise.all(A_VERY_LARGE_ARRAY_OF_XHR_PROMISE)

which would probably blow you browser memory by trying to send all requests at the same time

solution is limit the concurrent of requests, and wrap promise in thunk

Promise.allConcurrent(2)([()=>fetch('BLAH1'), ()=>fetch('BLAH2'),...()=>fetch('BLAHN')])

@davistran86
davistran86 / settings.json
Created September 18, 2020 09:33
Windows Terminal settings with black theme
// This file was initially generated by Windows Terminal 1.2.2381.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/mentation
{
"$schema": "https://aka.ms/iles-schema",
const delay = (ms) => new Promise((res) => setTimeout(res, ms));

Use:

const test = async () => {
  await delay(1000)
  console.log("This will print after 1s")
}
```
https://www.instagram.com/{public_profile_name}/?__a=1
```

In packages.json add resolutions and fix version of package E.g

{
  "name": "learn-typescript",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
 "lite-server": "^2.5.4"
@davistran86
davistran86 / reactjs-learning-path-2020.md
Created June 28, 2020 16:49 — forked from paulnguyen-mn/reactjs-learning-path-2020.md
Lộ trình học ReactJS cơ bản cho người mới bắt đầu 2020 🚀

Lộ trình học ReactJS cơ bản cho người mới bắt đầu 2020 🎉

  • Đôi tượng: mới bắt đầu học ReactJS mà không biết học những gì.
  • Yêu cầu kiến thức:
@davistran86
davistran86 / morgan-log.md
Created June 24, 2020 07:19
Morgan log with only POST request
morgan.token("person", (request, response) => {
  return JSON.stringify(request.body);
});

morgan.token("remote-addr", function (req) {
  return (
    req.headers["x-real-ip"] ||
 req.headers["x-forwarded-for"] ||

Download Udemy course videos using youtube-dl

$ youtube-dl --list-extractors | grep udemy

Steps

  1. Get link to the course to download. e.g. https://www.udemy.com/course-name/
  2. Login into udemy website, save the cookie from Firefox (cookies.txt)[1] export extension. Save it to file cookies.txt

$ youtube-dl https://www.udemy.com/course-name/ --cookies ./cookies.txt > $ youtube-dl -u username -p password -o './videos/%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s' https://www.udemy.com/course-name --cookies ./cookies.txt --verbose