satoshi-2000/llms-suitable huggingface dataset:
Question: WinDbg | Application memory full dump - Show file path of file handle

I created a memory dump of an application with procdump -ma abc.exe.
The application access various files.
I run !handle 0 f FILE and get over 100 file handles.
When I get a specific handle address, I run the following command !handle 000000000000161c f which results in:
0:000> !handle 000000000000161c f
Handle 000000000000161c
  Type          File
  Attributes    0
  GrantedAccess 0x12019f:
         ReadControl,Synch
         Read/List,Write/Add,Append/SubDir/CreatePipe,ReadEA,WriteEA,ReadAttr,WriteAttr
  HandleCount   2
  PointerCount  65479
  No object specific information available

Is there a chance to retrieve the actual file path? Something like that: How get file path by handle in windbg? seems to work only in kernel mode debugging.


Answer:
For post-mortem debugging (crash dump analysis), there's no way, except if you have a kernel dump (I can't tell you how to do that then). Windows will close handles of a process that terminated.
!handle combined with !handleex
There is handleex on Github.
Combine !handle and !handleex to get nice information.
.foreach /pS 1 /ps 1 (file {!handle 0 4 FILE}) { .echo Handle file; !handleex file; .echo }

Example output
0:007> .foreach /pS 1 /ps 1 (file {!handle 0 4 FILE}) { .echo Handle file; !handleex file; .echo }
Handle 4c
Object Type: File
Handle Name: \Device\HarddiskVolume3\Users\T

Handle 8c
Object Type: File
Handle Name: \Device\HarddiskVolume3\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.1110_none_60b5254171f9507e

Handle b4
Object Type: File
Handle Name: \Device\HarddiskVolume3\Windows\System32\en-US\notepad.exe.mui

...

!handle combined with SysInternals Handle
You can combine the !handle WinDbg command and the SysInternals Handle tool.
Example notepad debugging session:
:018> !handle 0 1 FILE
Handle 4c
  Type          File
Handle 8c
  Type          File
Handle b8
  Type          File
Handle 134
  Type          File
...

Combined with the information from the console:
C:\...>handle -p notepad.exe | findstr 8C:
   8C: File          C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.1110_none_60b5254171f9507e

C:\...>handle -p notepad.exe | findstr B8:
   B8: File          C:\Windows\System32\en-US\notepad.exe.mui

Automating it doesn't really work well:
0:007> .printf "%d\n",$tpid
2168
0:007> .foreach /pS 1 /ps 1 (file {!handle 0 4 FILE}) { .shell C:\handle.exe -p 2168 | findstr file: }

The process seems to be too slow and require too much user input.
Question: How to get SKTypeface.FromFamilyName to return a font for Japanese, Korean, Chinese (Android + iOS, Xamarin.Forms)

I'm using a library that uses SKTypeface.FromFamilyName internally to render font on the screen. However, as I found out if the text to display is japanese, korean or chinese, it just prints squares. I tried to add a custom font to my project but I was not able to make SKTypeface.FromFamilyName return anything but NULL with custom fonts. As I have no access to change SKTypeface.FromFamilyName to something else ( at least as far as I know because it's in a private method of a static class - https://github.com/Mapsui/Mapsui/blob/5008d3ab8b0453c27cb487fe6ad3fac87435abbe/Mapsui.Rendering.Skia/LabelRenderer.cs#L277 ), is there any way I can make it return any font for each language (or one per language) that works with these?


Answer:
Alright, I found a solution for this. This seems to work for me:
string fontFamily;
switch (Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName.ToLower())
{
    case "ja":
        fontFamily = SKFontManager.Default.MatchCharacter('あ').FamilyName;
        break;

    case "ko":
        fontFamily = SKFontManager.Default.MatchCharacter('매').FamilyName;
        break;

    case "zh":
        fontFamily = Thread.CurrentThread.CurrentUICulture.IetfLanguageTag.ToLower() switch
            {
                "zh-cn" => SKFontManager.Default.MatchCharacter('实').FamilyName,
                "zh-tw" => SKFontManager.Default.MatchCharacter('實').FamilyName,
                _ => null
            };
        break;

    default:
        fontFamily = null;
        break;
}
Question: Excel 2016 - compare two columns for match

I have two columns where I want to highlight differences 
I want to see if the letter in Column A exists in Column B - it should be case-sensitive, because there are C and c in column A
If there is a match I want the row preferably turn green - otherwise a OK / NOT OK in column C
Thank you in advance


Answer:
Copy this Sub to the Worksheet code pane. For this open the Developer tab and click Visual Basic. In the left pane select the worksheet where your datas are, and doubleclick it. Insert the code.
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Column = 1 And InStr(1, Target.Offset(0, 1).Value, Target.Value) > 0 Then
Target.EntireRow.Interior.Color = vbGreen
Else
Target.EntireRow.Interior.ColorIndex = xlColorIndexNone
End If
If Target.Column = 2 Then
If InStr(1, Target.Value, Target.Offset(0, -1)) > 0 Then
Target.EntireRow.Interior.Color = vbGreen
Else
Target.EntireRow.Interior.ColorIndex = xlColorIndexNone
End If
End If
End Sub


If the content change in column A or B the respective row color will change.
Question: A more organic way to resolve and return a resolved promise from a JavaScript/Node function than using Promise.resolve?

For instance, I'm writing a Mongoose utility method, and I'm wanting to return a value after the async methods resolve. This is a highly simplified example.
const testConnect = () => {
    let msg;
    mongoose.connect(mongoServer.getUri())
        .then(() => {
            msg ="Connection success!";
        })
        .catch((err) => {
            msg = "Connection failure! Error: " + err;
        });
    return Promise.resolve(msg);
};

My test buildup utilizes this method in a matter like this.
beforeAll(() => {
    iMDT.testConnect()
        .then((result) => {
            console.log(result);
        })
        .catch((err) => {
            console.log(err);
        });
});

Is there a simpler, more organic way to return that value as a resolved promise - without using the prototype Promise? It feels kludgy to me.


Answer:
What you're attempting to do won't work because your asynchronous operation is non-blocking so you will do return Promise.resolve(msg); before there's even a value in msg.  It's almost always a warning sign when you're assigning higher scoped variables inside of a .then() or .catch() handler and then trying to use those variables at the top scope.  That won't work because of timing issues (attempting to use the variable before its value is set).
Instead, you can just return the promise directly.  The general advice is to use the promises you already have and not create new ones unnecessarily.  Return the one you already have like this:
const testConnect = () => {
    return mongoose.connect(mongoServer.getUri()).then(() => {
        // set the final resolved value
        return "Connection success!";
    }).catch((err) => {
        // set the final rejected reason object
        throw new Error("Connection failure! Error:"  + err.message, { cause: err });
    });
};

Note, how the failure code path returns a rejected promise that contains a human readable message and also contains the original error object as the cause.  This is the usual way to use promises, not to hide the rejection by returning a different resolved value.  This allows the caller to more easily know if the operation succeeded or failed without having to compare to specific resolved values.
And, this is also what your beforeAll() code block is expecting.  It is expecting a rejected promise if the operation fails which is not what your first code block was doing.
Question: Behavior of `git push --force` when no upstream branch exists

What's the behavior of git push --force when no upstream branch exists?
Will I get something like fatal: The current branch branch_name has no upstream branch, as would happen with a normal push, or would the upstream branch be "forcefully" created?


Answer:
--force does not change the behaviour of git push without an upstream set (when no push.default and push.autoSetupRemote config is set) empirically with git 2.40.0.
$ git checkout -b dev/test
Switched to a new branch 'dev/test'
$ git push
fatal: The current branch dev/test has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin dev/test

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.

$ git push --force
fatal: The current branch dev/test has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin dev/test

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.
Question: Python List formatting with small bracket

I need to add small bracket at the start and end of a Python list (Python 3)
My list is
list1 = ['1','2','3']
List needed is [('1','2','3')]
I know the solution may be simple, but I am not getting it.
Thanks in advance
Tried fstring and join


Answer:
Here's one way to print a list in that formatting with a combination of an f-string and str.join:
>>> list1 = ['1','2','3']
>>> print(f"[({','.join(repr(i) for i in list1)})]")
[('1','2','3')]

Note that repr(i) adds quotes around the strings so that they print as '1' instead of 1.
Note also that this is converting the list into a particular string, not adding anything to the list.  If you wanted to add the literal strings ( and ) to list1 you could do:
>>> list1.insert(0, '(')
>>> list1.append(')')
>>> list1
['(', '1', '2', '3', ')']

But parentheses themselves aren't objects that you can add to a list.  If you want to construct an object that will render with parens, that's a tuple:
>>> list1 = ['1','2','3']
>>> [tuple(list1)]
[('1', '2', '3')]
Question: How to show a list of all my todos across all the files of my project?

I am an Emacs newbie transitioning from Neovim.
I want something that will show me a list of all of my todos across all the files of the project.
I've tried the following packages:

hl-todo
fixmee

Both of them can highlight todos, and show a list of all the todos in the current buffer.
But, what I need is a list of todos across all the files of the project and not just the current buffer. They do provide such functionality, but it is very clunky and impossible to bind to just a single key (they require choosing a path where to search and pressing enter).
The question: how can I show a list of all my todos across all the files in my project?


Answer:
I'm not sure about todo modes, but using the rg (ripgrep) package, it is easy to add custom commands.  For example, to define a command that searches for 'TODO' or 'FIXME' in the current project,
(rg-define-search my-rg-todo
  :query "(TODO|FIXME)"
  :format regexp
  :dir project
  :files current)

There are a lot of other similar solutions, like builtin rgrep, ag or another ripgrep/ag library.
Question: How can I open a Markdown file in preview mode by default in VS Code?

I'm trying to configure a GitPod or GitHub Codespace so that the README.md gets automatically opened in preview mode at boot time.
I managed to open the file as:
code README.md

but that opens the editor, I'd like to open it in preview only mode.


Answer:
If you google "github vscode issues markdown open preview by default", you will probably find this issue ticket pretty high up in the search results: Option to automatically open markdown in preview
#54776. Quoting Matt Bernier from their comment there:

To change this, you can configure the default editor for .md files (or whatever other markdown file extension you wish). Here's an example setting:
"workbench.editorAssociations": {
    "*.md": "vscode.markdown.preview.editor"
}

Use the [View: Reopen Editor With...] command to switch back to the standard text editor.


There's also another related issue ticket about opening the Markdown preview to the side by default: Automatically Activate Markdown Preview #2766. If you're interested in that one too, give it a thumbs up to show support, and subscribe to it to get notified of discussion and progress, but please avoid noisy comments like "+1" or "bump".
Question: Is there a way to represent a range of indexes in a lua table for a dissector?

Trying to build a dissector in lua where in the ProtoField for one of the values, I map it to a table so that when passed some uint it can get said string from the list of outputs. The current issue is that I have some indexes of 1, 2, and 3, but I also need a range of numbers that correspond to one output string, and its too many to hardcode it all in. I thought about just adding some check that will add said index whenever it doesn't exist, but that would result in alot of wasted time and wanted to ensure there wasn't a better way.
Tried mapping it to a function and setting a default value with a metatable.


Answer:
Generically, a table can contain tables as indices. These tables could each be used to represent a range of indices.
A cursory example (note that overlapping ranges are not stable):
local range_mt = {}
range_mt.__index = range_mt

function range_mt:contains(value)
    return self.lower <= value and value <= self.upper
end

local function range(lower, upper)
    return setmetatable({
        lower = lower,
        upper = upper
    }, range_mt)
end

local map = setmetatable({
    [1] = 'hello',
    [2] = 'world',
    [3] = 'goodbye',
    ranges = {
        [range(10, 20)] = 'foo',
        [range(51, 99)] = 'bar'
    }
}, {
    __index = function (self, value)
        for r, str in pairs(self.ranges) do
            if r:contains(value) then
                return str
            end
        end

        return "DEFAULT"
    end
})

for _, value in ipairs { 9, 6, 1, 2, 16, 4, 15, 66, 51, 3, 94 } do
    print(value, '->', map[value])
end

9   ->  DEFAULT
6   ->  DEFAULT
1   ->  hello
2   ->  world
16  ->  foo
4   ->  DEFAULT
15  ->  foo
66  ->  bar
51  ->  bar
3   ->  goodbye
94  ->  bar
Question: Sequelize - Is it possible to search all columns of a table with Op.or operator?

In a project with NodeJS and ExpressJS, using Sequelize, I'm attempting to implement server-side pagination and searching
const products = await Product.findAll({
      where: {
        [Op.and]: [
          {
            status: {
              [Op.ne]: -1
            },
          },{
            [Op.or]:[
              {
                name:{
                  [Op.substring]:searchString
                }
              },{
                category:{
                  [Op.substring]:searchString
                },
              }
            ]
          }
        ]
      },
      limit: rows,
      offset: offset
    });

Now this allows me to search in the name and category columns, but Product's table has like 10 columns, Client's table has like 15 columns, is there a way to get something like
WHERE any-column LIKE "%searchString%"
where:{
    [Op.or]:[
        {any-column}:{
            [Op.substring]:searchString
        }
    ]
}

Or is my only option to add each column manually?


Answer:
If all columns are string type, you can use CONCAT_WS function to search in a whole combined string.
const searchCols = ['name', 'description', 'category'].map(sequelize.col);

await Product.findAll({
    where: {
        status: {
            [Op.ne]: -1
        },
        [Op.where]: Sequelize.where(Sequelize.fn('CONCAT_WS', ' ', ...searchCols), 
                                    Op.like,
                                    `%${searchString}%`)
    }
})
Question: Does RailwayCLI ignore files defined in .gitignore?

The command railway up takes your current local project and uploads it directly to railway without having to link a Github repo to your railway project.
Does RailwayCLI take into account .gitignore file like Git does? if not what is the proper way to ignore files (not upload them) when using the command.
I couldn't find anything relevant mentioned in their docs.


Answer:
No, RailwayCLI does not take into account the .gitignore file. If you want to ignore certain files when using the railway up command, you can use the --ignore-files flag. For example, to ignore all files with the .txt extension, you would use the following command:
railway up --ignore-files .txt

Update:
The -ignore-files flag uses the same globbing patterns as .gitignore. So you can use the * character to match any number of characters, and the ? character to match any single character.
For example, the following command will ignore all files that start with the word "app" and have any extension:
railway up --ignore-files app*

This command will ignore all files that have the .txt or .json extensions:
railway up --ignore-files .txt,.json

This command will ignore all files in the ./test directory and its subdirectories:
railway up --ignore-files ./test/*

You can also use the -ignore-files option to ignore specific files, even if they have extensions that are not listed in the .gitignore file. For example, the following command will ignore the file app.txt, even though the .txt extension is not listed in the .gitignore file:
railway up --ignore-files app.txt
Question: How to replace a string defined by starting and ending index by another string in R?

string <- "this is a funny cat"

I want to replace the first 15 characters of string with 'orange`. The desired output is
'orange cat'

However, using substr gives me
substr(string, 1, 15) <- "orange"
> string
[1] "oranges a funny cat"

which is not the desired output.


Answer:
The output of substr should be the pattern of sub.
string <- "this is a funny cat"

sub(substr(string, 1, 15), "orange", string)
[1] "orange cat"

Or directly replace the first 15 characters in sub.
sub("^.{15}", "orange", string)
[1] "orange cat"
Question: How can I stop codelenses from breaking up indent guides in VS Code?

I have this visual annoyance when I am using VS Code. Whenever a method or class is declared, the "reference" counting is causing the vertical lines that connects the curly braces to break.
It is very annoying, I tried finding the settings in user preference but could not find anything. Could someone help me?
I find the "reference" count is alright, but how can I keep the vertical curly braces pair lines from breaking. I don't have this problem in Visual Studio.



Answer:
This is a known issue and as far as I know, there's not much you can do about it for now except wait for it to get handled. If you google "github vscode issues codelens indent guide", you should easily find Indent Guides Have Breaks Where CodeLens UI is Rendered #9604. There, you'll see that one of the maintainers, @alexdima commented:

Code lenses are implemented as view zones (same mechanism as embedded editors when you find all references or as the diff editor). In some of the view zones (such as code lens) it makes sense to render the indent guides inside view zones, while in others (such as the embedded editors or the diff editor) it does not, therefore marking this as both a feature request and a bug.

You can give that issue ticket a thumbs up reaction to show support for it getting prioritized (there's a big backlog), and subscribe to it to get notified about discussions and updates. But please don't make noisy comments like "me too" / "+1" / "bump".
Question: How to find different between two times with sql

I have a table contain reference time and a user check-in time. Both data is different in type.
Sample data

dtime = 2023-06-02 08:23:21
work_time = 08:00-18:00

And my code is...
SELECT substring(dtime,-8,5) AS chkin, 
SUBSTRING(work_time, 1, 5) AS wt1, 
TIMESTAMPDIFF(MINUTE, substring(dtime,-8,5), SUBSTRING(work_time, 1, 5)) AS min_diff 
FROM ta_db 
WHERE id = 13181;

As a result...

chkin = 08:23
wt1 = 08:00

Now, I want to know how many minutes different from chkin and wt with TIMESTAMPDIFF.
So I did this...
TIMESTAMPDIFF(MINUTE, substring(dtime,-8,5), SUBSTRING(work_time, 1, 5)) AS min_diff 

But it returns NULL. Please be advised.


Answer:
Try this:
SET @dtime = '2023-06-02 08:28:21';
SET @work_time = '08:00-18:00';

SELECT substring(@dtime,-8,5) AS chkin, 
SUBSTRING(@work_time, 1, 5) AS wt1, 
TIMESTAMPDIFF(MINUTE, @dtime, CONCAT(SUBSTRING(@dtime, 1,10), ' ', SUBSTRING(@work_time, 1, 5))) AS min_diff
Question: How to validate and submit a modal dialog, and, when succesful, execute some Javascript

The following order of events should happen in my Oracle APEX app:

User clicks Submit button in a modal dialog.
The configured validations are executed (mostly package functions).
If validation is OK, the page is submitted (a package function is called).
If no validation error or exception during submit happened, Javascript is executed. This Javascript needs access to the item values entered by the user, so it must not be executed after a page reload.
Modal dialog is closed.

I tried many ways to accomplish this, but all failed. The obvious solution would be two dynamic actions on the button click, but I learned that the order of the actions is not guaranteed, and the Javascript is executed even after an error in the validation or submit.
Now I think I have to do it with Javascript in a single dynamic action (button click on the modal dialog) like this:
// Validate and submit.
apex.page.submit( {
    validate: true,
} );

// Other JS code on successful submit, which is accessing page items.
... $v("myItem") ...

// Close modal dialog.
apex.navigation.dialog.close(true);

How can I check if apex.page.submit was successful?
And will the javascript be able to access item values entered by the user?
By the way, I don't want to put this Javascript on the parent page, because there will be multiple such modal dialogs, and I prefer to keep their respective logic separate, and not turn the parent page into a "God object".
Thank you in advance.


Answer:
This isn't an answer to your question, because I believe what you want is simply not possible. To understand why, you need to check how APEX processes work.

A number of processes run in a pre-rendering phase. These are server-side processes (computations, pl/sql processes, form initialization, etc).
The dom is rendered based on the components. These components (optionally) take data from the pre-rendering process. In this phase client-side actions can be executed (dynamic actions, custom javascript)
Once a page is submitted, the "processing" starts. The form data entered in the previous phase it sent to the server. From this point onward everything is server-side: validations, page processing, branches, etc).

Now... javascript is client side only. and only in phase 2 can client-side code be executed. Once a page is submitted, the client can no longer be accessed. So "execute javascript" after "server side validations" is simply not possible in APEX. javascript can be executed onload OR when the page is rendered via an event OR before page submit. That's it in the current version of apex (23.1).