Thursday, May 26, 2022

20220526 git move folders with their history to another repo

Main ref: https://mattsch.com/2015/06/19/move-directory-from-one-repository-to-another-preserving-history/

If there are multiple folders, we need to do thing differently.

  1. Source repo
    1. git remote rm origin
    2. git filter-branch --index-filter 'git rm --cached --ignore-unmatch -rf XXX' --prune-empty -f HEAD
      1. for all other folders or files
      2. for all subtrees, just do a clean up
  2. Dest repo
    1. git remote add <branch> <source repo directory>
    2. git checkout <branch>
    3. git checkout <Dest repo working branch>
    4. git merge develop --allow-unrelated-histories
    5. git push
    6. add back subtree
    7. git push
The assumption is that the directory names in the source repo remain the same in the dest repo.  If different, the commit history needs to change. 
  • Directory name and level manipulation shall be done at the Source repo side.  This shall greatly simplify the merge. 

Thursday, April 28, 2022

20220428 LDAP query

Download and install Remote Server Administration Tools for Windows 10

  • https://www.microsoft.com/en-us/download/details.aspx?id=45520

Open up a Powershell console and use Active Directory cmdlets

  • https://docs.microsoft.com/en-us/powershell/module/activedirectory/?view=windowsserver2022-ps

Examples:

Get-ADUser -Identity "username"

  • get basic user info

Get-ADPrincipalGroupMembership username| select name

  • get all groups that a user belongs to


Get-ADGroup

Get-ADGroupMembers



Wednesday, March 30, 2022

20220330 powershell configure pagefile.sys

 Only for Powershell 5

Get-Volume; $pagefile = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges; $pagefile.AutomaticManagedPagefile = $false; $pagefile.put(); $pagefileset = Get-WmiObject Win32_pagefilesetting; $pagefileset.InitialSize = 1024; $pagefileset.MaximumSize = 8339; $pagefileset.put();Gwmi win32_Pagefilesetting | Select Name, InitialSize, MaximumSize; restart-computer -force


Monday, March 1, 2021

Youtube mp3/mp4 download

https://github.com/ytdl-org/youtube-dl/blob/master/README.md#readme

on Windows PC

start CMD.exe

type wsl

sudo apt update

sudo apt install youtube-dl

youtube-dl -x --audio-format mp3 --embed-thumbnail -o "%(playlist_index)s-%(title)s.%(ext)s" URL


yt-dlp -f "bestaudio[ext=m4a],bestaudio[ext=webm]" -x --audio-format mp3 --audio-quality 0 -o "%(playlist)s/%(playlist_index)03d %(title)s.%(ext)s" URL


yt-dlp -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' -S vcodec:h264 --windows-filenames --restrict-filenames --write-auto-subs --sub-lang "en.*" --embed-subs --add-metadata --add-chapters --no-playlist -N 4 -ci --verbose --remux-video "mp4/mkv" URL


Download MIT class

yt-dlp -f "bestaudio[ext=m4a],bestaudio[ext=webm]" -x --audio-format mp3 --audio-quality 0 -o "%(playlist)s/%(titles)s.%(ext)s" "https://www.youtube.com/watch?v=wWnfJ0-xXRE&list=PLyQSN7X0ro203puVhQsmCj9qhlFQ-As8e"

Friday, January 29, 2021

20210129 mac mini m1 laptop

mac mini把电源模块改成电池可行吗? - 知乎
https://www.zhihu.com/question/432675947/answer/1683427375

版权属于知乎和原作者

先放图,可行.
12月份拿到机器之后没多久就手痒将原装电源拆下来,改成type c供电.主要是给PD诱骗器画了个固定件然后3d打印出来.用诱骗器直接向PD电源诈骗20v,然后再降压到12v供给主板.


后来觉得这么大个机箱,主板才这么点大小,干脆塞一组电池进去算了,当个UPS不香吗

然后就换了个电源管理板子,再塞了4颗三星50e进去,刚好能塞满了整个机箱.

给电池画了支架,能刚好扣在风扇的固定柱上
因为赶着要用,电池组在最后装的时候手上没有高温胶带,就随便找了卷胶布包的像个粽子一样,反正能用就不管美观了,不炸就行23333.
风扇装上去之后是这个样子的.
能用就行.jpg塞进去的电池能量在70Wh左右,Mac mini满载功耗加上屏幕和ssd我测了一下在40w左右,理论上能满载续航一个半小时.当然了我平时把这组电池当UPS用,电池电压会调成单节4v停充,避免长时间满电搞坏电池.缺点嘛,没法在系统里面看电量,外部断电的时候也没有报警装置,用起来的时候还是有点怕怕的,只是我应对的都是短时间断电就没所谓了.另外折腾成这个样子保修估计悬了.


Parts:
* 诱骗器PD23.0转DC100W直流20V触发转接USBC笔记本T12供电改Type-C

* LM5118模块 自动升降压模块 大功率电源模块 高效率电源模块

* 三星 21700 50G 50E 低内阻锂电池 充电宝手电筒适用 拆机

* 铅蓄锂电池充电24V19V12v9V5V10A移动电源直流UPS不间断电源模块



改装DIY升级苹果 MAC mini Macbook 线性电源 专用滤波模组接口板

Mod a Mac Mini for DC Power
Battery is NP-L7S

2018 Mac Mini power supply wiring

Connector