What are the default DifferenceListener & matchTracker used by Diff of XMLUnit? - xmlunit

Default ElementQualifier is ElementNameQualifier, but what are the default DifferenceListener & MatchTracker?

Diff itself implements DifferenceListener and uses itself as default, there is no default MatchTracker at all.

Related

How to maintain only a small set of non-default kernel configs?

I would like to be able to maintain only a small set of kernel configs and use defaults for the rest of configs.
For a minimalistic example: I would like to maintain only the config value. Like this:
CONFIG_ILLEGAL_POINTER_VALUE=0xdebb000000000000
And use this to build kernels v3.x, v4.x, and v5.x.
Because I care only about this kernel config value, it is fine for all others to be default values.
How do I do that?
You can add all the config options you want to override in a simple Bash script that exports them as environment variables before running make. For options that you want to disable (i.e. set from y to n) you will need to directly modify the .config file as simply exporting them as =n will not work.
#!/bin/bash
make defconfig
# Options you want to modify
export CONFIG_FOO=123
export CONFIG_BAR=456
# Options which you want to disable
sed -ie '/CONFIG_BAZ=y/ s/=y/=n/' .config
make all -j
Beware though that you should check for config dependencies (with make menuconfig or make gconfig) to see whether the config options you are dealing with also depend on others or have others as dependencies. In such case you also want to include those in your Bash script as needed.

How to remove the "username#host" from powershell prompt?

I am using Windows Terminal(Preview) with shells like 1.PowerShell, 2.WSL in my Windows 10 machine. I installed the latest version of oh-my-posh and posh-git to customize the terminal. My current theme is Agnoster which gives a colorful custom prompt. But I want to get rid of the "username#host" from my prompt.
Eg:
Current => username#host D:\folder-name>
Needed => D:\folder-name>
I tried few things with $GitPromptSettings variable and also in GitPrompt.ps1 file which is inside the posh-git folder but with no use.
Also, since i have oh-my-posh and posh-git, does both have prompt customization properties or it is only from posh-git?
Any help is appreciated.
remove the segment which type is session from ~\Documents\WindowsPowerShell\Modules\oh-my-posh\3.101.23\themes\<themename>.omp.json
You have to set $DefaultUser before importing modules.
Example:
$global:DefaultUser = [System.Environment]::UserName
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox
In Oh My Posh 3, the method for hiding the username#host part has changed because the whole theme configuration has changed.
The username#host portion of the powerline comes from the "session" segment. The configuration options for session can be found here: https://ohmyposh.dev/docs/session
Interesting options are:
display_user: boolean - display the user name or not - defaults to true
display_host: boolean - display the host name or not - defaults to true
default_user_name: string - name of the default user - defaults to empty
display_default: boolean - display the segment or not when the user matches default_user_name - defaults to true
And the note on environment variables:
POSH_SESSION_DEFAULT_USER - used to override the hardcoded default_user_name property
Solution
Based on this, I made the following changes:
For the theme, I added the display_default: false property to the "session" segment:
{
"type": "session",
// ....
"properties": {
"display_default": false
}
}```
In my powershell profile, I set the new environment variable to my own username:
$env:POSH_SESSION_DEFAULT_USER = [System.Environment]::UserName
This makes the user#host part of the prompt disappear as long as I'm using my default username.
You may check {theme's name}.psm1 in the Themes/ directory to understand how it works.
The key is the following code.
e.g. Paradox.psm1
$user = $sl.CurrentUser
....
if (Test-NotDefaultUser($user)) {
$prompt += Write-Prompt -Object "$user#$computer " -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
if $DefaultUser is same to $user or is different $null, your powershell does not show $user#$computer.

How to override fish_prompt, keeping the styles from the applied theme?

I installed fish shell, installed few themes. Applied the theme "agnoster", all good is pretty but I want fish_prompt to override the original one and keep the styles in order to show me full path properly. Currently the full path is a shortcut such as Desktop/Abba turns to ~D/Abba and I want to remove the D and will it be ~Desktop/Abba. How can I override function fish_prompt properly so that I am able to call the original previous function from the theme to keep up the styles?
The agnoster theme uses fish's prompt_pwd function to display the pwd.
That shortens each path component to $fish_prompt_pwd_dir_length characters. Set that variable to 0 to inhibit shortening entirely.
Alternatively, you can change the prompt_pwd function however you want it, e.g. via funced prompt_pwd (and funcsave prompt_pwd once you're happy with the result).
I've had a similar issue, but the chosen answer didn't work for me.
In my case, I've had to source all theme files manually before overriding the fish_prompt function.
For example
source $OMF_PATH/init.fish # assure omf is loaded before run the following code
# Read current theme
test -f $OMF_CONFIG/theme
and read -l theme < $OMF_CONFIG/theme
or set -l theme default
set -l theme_functions_path {$OMF_CONFIG,$OMF_PATH}/themes*/$theme/functions/
for conf in $theme_functions_path/*.fish
source $conf
end
function fish_prompt
# prompt_theme_foo
# prompt_theme_bar
end
More details on: https://stackoverflow.com/a/72098697/2180456

Accessing ~/.ssh/config aliases from bash and python

I use ~/.ssh/config to manage hosts that I need to interact with frequently. Sometimes I would like to access the aliases from that file in scripts that do not use ssh directly, ie if I have a .ssh/config with
Host host1
User user1
Hostname server1.somewhere.net
I would like to be able to say something like sshcfg['host1'].Hostname to get server1.somewhere.net in scripting languages, particularly Python and something sensible in Bash.
I would prefer to do this with standard tools/libraries if possible. I would also prefer the tools to autodetect the the current configuration from the environment rather than have to be explicitly pointed at a configuration file. I do not know if there is a way to have alternate configs in ssh but if there is I would like a way to autodetect the currently active one. Otherwise just defaulting to "~/.ssh/config" would do.
It is possible to specify an alternative configuration file on the command line, but ~/.ssh/config is always the default. For an alternative configuration file use the -F configfile option.
You can either try parsing the original config file, or have a file that is better suited for manipulation and generate an alternative configuration file or part of the default configuration file from that.
Using Paramiko
Paramiko is a pure-Python (3.6+) implementation of the SSHv2 protocol, providing both client and server functionality.
You may not need every feature Paramiko is providing, but based on their documentation, this module could do just what you need: paramiko.config.SSHConfig
Representation of config information as stored in the format used by OpenSSH. Queries can be made via lookup. The format is described in OpenSSH’s ssh_config man page. This class is provided primarily as a convenience to posix users (since the OpenSSH format is a de-facto standard on posix) but should work fine on Windows too.
You can define a non-standard config-file,the same way you would specify an alternate ssh-config file to ssh command line, as mentioned in a previous answer:
config = SSHConfig.from_file(open("some-path.config"))
# Or more directly:
config = SSHConfig.from_path("some-path.config")
# Or if you have arbitrary ssh_config text from some other source:
config = SSHConfig.from_text("Host foo\n\tUser bar")
You can then retrieve whichever configuration you need like so
For example with a configuration file like this:
Host foo.example.com
PasswordAuthentication no
Compression yes
ServerAliveInterval 60
You could access different settings using:
my_config = SSHConfig()
my_config.parse(open('~/.ssh/config'))
conf = my_config.lookup('foo.example.com')
assert conf['passwordauthentication'] == 'no'
assert conf.as_bool('passwordauthentication') is False
assert conf['compression'] == 'yes'
assert conf.as_bool('compression') is True
assert conf['serveraliveinterval'] == '60'
assert conf.as_int('serveraliveinterval') == 60
In case you only need available hostnames, you can list all available ones, and then get information about their configuration using that context (More info here)
get_hostnames()
Return the set of literal hostnames defined in the SSH config (both explicit hostnames and wildcard entries).
This might not be compliant with your request for a standard library, though the project seems to be actively maintained and widely used as well

How to change default text editor for all kind of text-based files, no matter what extension is?

I know Finder has built-in option to change default application but this is only for that extension. I want to make available my editor (MacVim) for all kind of text files. Such as .html, .xml, ... .gitignore etc., even unknown extensions like.this.
I have tried duti but looks like not working anymore.
I also tried:
$ defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=org.vim.MacVim;}'
$ defaults read com.apple.LaunchServices
{
LSHandlers = (
{
LSHandlerContentType = "public.plain-text";
LSHandlerRoleAll = "org.vim.MacVim";
}
);
}
and with different UTIs like public.text, public.utf8-plain-text. No luck.
Any help appreciated. I don't want to see TextEdit anymore...
Well, this answer on Ask Different mentions your method to be outdated. It also points to another answer that is supposed to work on newer macOS versions (those that came after Mavericks).
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add \
'{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=org.vim.MacVim;}'
Notice the difference between com.apple.LaunchServices LSHandlers -array-add in your code and com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add in the offered solution.
EDIT
I forgot to mention that a restart is needed (linked answer does mention this though).
Also, please note (see this answer's comments) that the OP apparently needed to export all defaults with defaults read com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers > defualts.txt, change all apps to org.vim.MacVim via a text-editor, before re-importing them via defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers "$(cat defualts.txt)"

Resources