Analyze Windows Side-by-Side (WinSxS)

$PathFromCBSLog = '\??\C:\WINDOWS\SysWOW64\\srmlib.dll'
$FileUnicodePath = $PathFromCBSLog.Replace('\??', '\\?')
$FileName = [System.IO.Path]::GetFileName($FileUnicodePath)
$ActualFileHash = Get-FileHash -Path $FileUnicodePath | Select-Object -ExpandProperty Hash
$ExpectedFileHash = '7b163daf659c1198e3a8c9acb7b2e7324e4c764599997bdea4286987f4533738'

$WinSxSFiles = [System.IO.Directory]::EnumerateFiles("$($env:windir)\WinSxS", $FileName, 'AllDirectories') | ForEach-Object { [System.IO.FileI

Tribonacci

/**
 * @param {number} n
 * @return {number}
 */
var tribonacci = function(n) {
    // Initialize an array with the base cases.
    let trib = [0, 1, 1];

    // If n is less than 3, return the nth number in the base cases.
    if (n < 3) {
        return trib[n];
    }

    // Calculate the nth Tribonacci number.
    for (let i = 3; i <= n; i++) {
        // The current Tribonacci number is the sum of the previous three numbers.
        trib[i] = trib[i - 1] + trib[i - 2] + trib[i - 3];
    }

SQL Fast Row Counts

SELECT s.name AS [Schema], t.name AS [Table], i.rowcnt AS [Rows]
FROM sysindexes AS i
  INNER JOIN sysobjects AS o ON i.id = o.id
  INNER JOIN sys.tables AS t ON t.object_id = o.id
  INNER JOIN sys.schemas AS s ON s.schema_id = t.schema_id
WHERE i.indid < 2  AND OBJECTPROPERTY(o.id, 'IsMSShipped') = 0
ORDER BY s.name, t.name

mac 使用外接式硬碟 ntfs 格式

mac 使用外接式硬碟 ntfs 格式
## 當外接式硬碟格式是 ntfs 時,mac 要怎麼寫資料到 ntfs 格式的硬碟內?

#### 安裝支援 ntfs 套件
```
brew install --cask macfuse
brew install ntfs-3g-mac
```
裝完之後,查看硬碟資訊

diskutil list
```
/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *2.0 TB     disk2
   1:               Windows_NTFS macFUSE Volume 0 (nt... 2.0 TB     disk2s1
```
#### 掛載它,需要 root 權限


```
sudo /usr/local/bin/ntfs-3g /dev/disk2s1 /Volumes/NT

Responsive classes

$positions: (
    static: 'static',
    relative: 'relative',
    absolute: 'absolute',
    fixed: 'fixed',
    stick: 'sticky'
);

$grid-breakpoints: (
  xs: 0,
  sm: 576px,
  md: 768px,
  lg: 992px,
  xl: 1200px,
  xxl: 1400px
);

@each $name, $position in $positions {
  @each $modifier, $breakpoint in $grid-breakpoints {
    @media screen and (min-width: #{$breakpoint}) {
        .position-#{$modifier}-#{$name} {
            position: #{$name} !important;
        }
    

Show Message Box

Documentação: [Command modifier reference](https://docs.dopus.com/doku.php?id=reference:command_reference:command_modifier_reference) Displays a confirmation dialog. If the user clicks the cancel button, the function is aborted at this point. The template for this modifier is: @confirm:\<message\>|\<positive text\>|\<negative text\> \<message\> is the text shown in the dialog, \<positive text\> is the text shown on the "OK" button, and \<negative text\> is the text shown on the "Cancel" button. These three strings are all optional - if not provided, default strings will be used. If you provide \<positive text\> but not \<negative text\> then the dialog will have an "OK" button but no "Cancel" button at all. You can include line-breaks in the message text using the special code \n (and if you need to include a literal \n sequence in the text you must escape the \ character, as in \\n). | | | | ---------------------------------- |:------------------------------------------------------:| | @confirm:Really copy files? | uses default text for the OK and Cancel buttons | | @confirm:Really proceed?&vert;Oui&vert;Non! | specifies custom text for the two buttons | | @confirm:All finished&vert;Acknowledged | custom text for the OK button; no Cancel button at all |
// OK
cmd.RunCommand("@confirm:O diretório / arquivo contido no clipboard não existe.|OK");

// Yes No
cmd.RunCommand("@confirm:Deseja continuar?|Yes|No");

// OK Cancel
cmd.RunCommand("@confirm:Os arquivos serão renomeados");
cmd.RunCommand("@confirm:Os arquivos serão renomeados|OK|Cancel");

Show Dialog with Inputbox

Documentação: [DOpus.Dlg](https://docs.dopus.com/doku.php?id=reference:scripting_reference:scripting_objects:dialog).GetString - usei para solicitar um novo nome de arquivo para o usuário. Displays a text entry dialog allowing the user to enter a string. The optional parameters are: - **message** - specify message string in the dialog - **default** - specify default string value - **max** - specify maximum string length - **buttons** - specify button labels (in the same format as the buttons property described above) - **title** - specify dialog window title - **window** - specify parent window for the dialog (a Lister or a Tab). If not specified, the Dialog object's window property will be used. - **result** - for scripting languages that support ByRef parameters, this can specify a variable to receive the string the user enters. The return value is the entered string, or an empty value if the dialog was cancelled. The index of the button selected by the user will be available via the result property once this method returns. The left-most button is index 1, the next button is index 2, and so on. If a dialog has more than one button then by definition the last (right-most) button is the "cancel" button and so this will return index 0. Onde usei: **_CLIPBOARD_Paste_Smart**
var strFile_name = DOpus.Dlg.GetString("Informe o nome do arquivo:", "", "0", "&OK|&Cancel", "Novo arquivo");

Get clipboard content

Documentação - [DOpus](https://docs.dopus.com/doku.php?id=reference:scripting_reference:scripting_objects:dopus).GetClipFormat Returns a string indicating the native format of the clipboard contents. Optional flags: **c** Differentiate between cut and copied files Possible return values: - **files** Files, if flags omitted or doesn't include c - **files_copy** Files via Copy (Ctrl-C), if flags includes c - **files_cut** Files via Cut (Ctrl-X), if flags includes c - **image** Bitmap data - **text** Text data - **\<empty string\>** Empty clipboard, or any other type of data
// Check if the clipboard contains text
if (DOpus.GetClipFormat() == 'text') {
    // Save the clipboard text in a variable called ClipboardData
    var ClipboardData = DOpus.GetClip();
    //DOpus.Output(ClipboardData);
}

ChatGPT - System Prompts

Visit this link for further reference: https://github.com/mustvlad/ChatGPT-System-Prompts
# Imports and Settings
```python
import os

from dotenv import load_dotenv
from openai import OpenAI


load_dotenv()
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
```

# Define Convenience Functions for Completion and Printing
```python
def complete(user_prompt, system_prompt):
  completion = client.chat.completions.create(
    model="gpt-3.5-turbo",
    messages=[
      {"role": "system", "content": system_prompt},
      {"role": "user", "content": user_prompt}
    ]
  )

def print_respo

Test if a string is a valid URL

[Regex101](https://regex101.com) - site excelente que explica o que o regex faz e se a sua string bate ou não.
function isURL(str) {
	// Regular expression to match a URL
	// Os caracteres ^ e $ fazem com que o regex retorne true apenas se a string inteira for uma URL, ou seja, não pode ter textos antes nem depois da URL.
	var regex = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;

	// Test if the string matches the URL format
	return regex.test(str);
}

Test if a string is a valid file / folder path

function isWindowsPath(str) {
	// Regular expression to match a Windows path
	// Os caracteres ^ e $ fazem com que o regex retorne true apenas se a string inteira for um Path, ou seja, não pode ter textos antes nem depois do Path.
	var regex = /^[a-zA-Z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$/;

	// Test if the string matches the Windows path format
	return regex.test(str);
}

Focus a file

Documentação: - [Select](https://docs.dopus.com/doku.php?id=reference:command_reference:internal_commands:select) Onde usei: **_CLIPBOARD_Paste_Smart** O Focus é o último arquivo (item) que o usuário clicou. Só pode haver 1 arquivo (item) com Focus. O arquivo (item) com Focus não necessariamente tem que estar como selecionado. Focus e Selected são coisas independentes. Se não colocar o argumento SETFOCUS, o directory opus irá selecionar o arquivo, mas manterá o Focus no arquivo (item) que tinha o Focus antes de executar o Select.
// Clear file selection
cmd.deselect = true; // Ensure the command deselects files
cmd.RunCommand('Select NONE');

// Select a file
// Set the item focus to the selected file
cmd.RunCommand('Select arquivo.txt SETFOCUS');

create nested json from html

$('#saveNewTasklist').on("click", function () {
    const nestedQuery = '.nested-sortable';
    const identifier = 'taskId';
    const root = document.getElementById('tasks');
    function serialize(tasks) {
        var serialized = [];
        var children = [].slice.call(tasks.children); // children == document property
        /**
         * [].slice.call() == Array.prototype.slice.call()
         * 
         * call slice() as if it was a function of NodeList using call(). What slic

JS plugin aka jQuery

class Test {
    constructor(el, options) {
        this.el = el;
        const defaultOptions = {
            onHover: (element, e) => {
                console.log(':)))', element, e);
            },
        };

        this.options = { ...defaultOptions, ...options };
        this.mouseOverHandler = this.handleMouseOver.bind(this); // Vytvoření odkazu na metodu handleMouseOver
    }

    init() {
        this.el.addEventListener('mouseover', this.mouseOverHandler); // Přidání po

jQuery $.data in vanilla js

/* 1 */
var item = document.getElementById("hi");
console.log(item);

item.data = {getType: function(){return this.TYPE},TYPE:"winner"};

var out = item.data.getType();
console.log("out", out);

var two = document.getElementById("hi")
console.log("should say 'winner': ", two.data.getType());



/* 2 */
window.$ = {
    data: function(obj, key, val) {
        if(!obj) {
            return this._data;
        } else if(!key) {
            if(!(obj in this._data)) {
                return {};
     

ODOO QWEB DEBUG

1 : Install IPDB (or PDB)

          pip3 install ipdb
          * WHEN RUNNING ODOO IN DOCKER CONTAINER, PUT THIS LINE TO DOCKER COMPOSE FILE UNDER ODOO CONTAINER DEFINITION
            command: --dev=qweb

2 : Add below code where you want to debug in xml

          t-debug="ipdb" or t-debug="pdb"

3. ATTACH TO RUNNING DCCKER CONTAINER BY FIRST GETTING CONTAINER ID WITH docker ps, THEN ATTACH docker attach container_id

4. RUN THE CODE WHERE XML FILE IS EXECUTED AND EXECUTION WILL PAUSE AT POS