Function that has two arguments and I can create a file into - f#

How can I define two functions in a given file system using f#script? A function that will have two arguments and will create a file into the root directory of the given file system. The first argument will be the name of the file and the second argument should be the file system.

Related

Fluent-bit Variables in Key configuration

I'm creating a custom Fluent-Bit image and I want a "generic" configuration file that can work on multiple cases, i.e.: it should work with a forward input sometimes and with tail input some other times.
I thought about using environment variables so to only have one input but it seems we cannot set variables in the key part only on the value side (see following code).
When I set the corresponding environment variables in a docker-entrypoint file with corresponding conditions
export INPUT_PATH="/myLogPath"
export INPUT_PATH_TYPE="path"
export INPUT_NAME="tail"
[INPUT]
Name ${INPUT_NAME}
${INPUT_PATH_TYPE} ${INPUT_PATH}
This is the error message I got
[error] [config] tail: unknown configuration property '${INPUT_PATH_TYPE}'. The following properties are allowed: path, exclude_path, key, read_from_head, refresh_interval, watcher_interval, rotate_wait, docker_mode, docker_mode_flush, docker_mode_parser, path_key, ignore_older, buffer_chunk_size, buffer_max_size, skip_long_lines, exit_on_eof, parser, tag_regex, db, db.sync, db.locking, multiline, multiline_flush, parser_firstline, and parser_.
I'm looking for a way to make it dynamic so either to have a single file with dynamic configuration or multiple files which can be included dynamically (#Include requires a static filepath from what I've seen).
EDIT: the only option I see is to have multiple input files (for each use case) and call it dynamically when starting fluent-bit in the docker-entrypoint file
I use a docker-entrypoint and split the input, filters to different files and then depending of the environment variables in the entrypoint I create a symbolic link to the corresponding file

Error in Octave while trying to call function: Undefined near line 1 column 1

When I am trying to call a function it gives me an error. However, I checked my destination path which is correct where my ".m" file is save.
Destination path: C:\Users\Soumaditya\Desktop\ML
File name: warmUpExerciseenter image description here
You are probably mistyping something.
At the matlab or octave terminal, from the directory where you expect your .m file to be, type the command what.
This will show you what is actually there which is relevant to matlab / octave.
Another possibility is that you named your function file one thing, but the name of the function inside the file has named it something else (though, in this case, octave at least would probably have thrown a warning...)
Also make sure that your filename doesn't actually have any weird spaces in the name. A file 'myfunction.m ' is not the same as 'myfunction.m' or ' myfunction.m'
You will need to move all the scripts to the default directory for Octave files on your system, move to your home directory on the Ubuntu system.

Can I control HSA config generated by AMDGPU backend?

I am using llvm clang to offline compile my opencl code into assembly. My target is amdgpu--amdhsa. The assembly file generated by clang has config of "enable_sgpr_dispatch_ptr = 1". Can I do something to turn that off in the generated assembly file? Also, it seems that the order of kernel arguments is in the reverse order of AMDCL2 convention. i.e. user argument is placed at the first place while hidden arguments like "HiddenGlobalOffsetX" are placed after user arguments. Can I change the order of the arguments so that the first argument will be hidden arguments before user arguments?

Require custom C module in Lua by path

This is a problem that plagued me for quite a while.
After I wrote and compiled my custom functions into a shared library, require('mylib') would only work when the shared library was directly in the same directory as the script I called it from.
Any efforts to try require('/path/to/mylib') or similar absolute paths failed. Furthermore, "backtracking" through a relative path (i.e. using .. failed as well.
So how can one specify the bin directory, or wherever the shared library is output to?
Well according to the Lua documentation on the require call (using Lua 5.2 here), there are a few places the loader looks for these loadable modules.
It seems that require() uses what are called "searchers" (docs linked to in above) to determine where to find these modules. There are four searchers in total. From the docs:
The first searcher simply looks for a loader in the package.preload
table.
The second searcher looks for a loader as a Lua library, using the
path stored at package.path. The search is done as described in
function package.searchpath.
The third searcher looks for a loader as a C library, using the path
given by the variable package.cpath. Again, the search is done as
described in function package.searchpath. For instance, if the C path
is the string "./?.so;./?.dll;/usr/local/?/init.so" the searcher for module foo will try to open the files ./foo.so, ./foo.dll, and
/usr/local/foo/init.so, in that order. Once it finds a C library, this
searcher first uses a dynamic link facility to link the application
with the library. Then it tries to find a C function inside the
library to be used as the loader. The name of this C function is the
string "luaopen_" concatenated with a copy of the module name where
each dot is replaced by an underscore. Moreover, if the module name
has a hyphen, its prefix up to (and including) the first hyphen is
removed. For instance, if the module name is a.v1-b.c, the function
name will be luaopen_b_c.
The fourth searcher tries an all-in-one loader. It searches the C path
for a library for the root name of the given module. For instance,
when requiring a.b.c, it will search for a C library for a. If found,
it looks into it for an open function for the submodule; in our
example, that would be luaopen_a_b_c. With this facility, a package
can pack several C submodules into one single library, with each
submodule keeping its original open function.
The searcher of use to us is the third one: it is used for any shared libraries (.dll or .so) which is generally how our custom C modules are built.
Using the template string (the one with the question marks), the searcher will look in each of the specified paths, substituting the argument of require() in place of the question mark. In order to specify the path for this third searcher, one must set (or append to) package.cpath and then call require().
So perhaps you have a directory structure as
- ROOT
|-lua
|-bin
where lua contains script.lua and bin contains mylib.so
To load mylib.so, you just need these two lines of code in script.lua:
package.cpath = '/ROOT/bin/?.so;' .. package.cpath
libfuncs = require('mylib')
NOTE: Notice the semicolon. If you append (as opposed to the prepending above), make sure to lead with the semicolon on your added path. It is not there buy default. Otherwise your new path will be merged to the current default cpath, which is just ./?.so.
If you whant just configure your system to use some path to store
libraries there then best way just use LUA_PATH and LUA_CPATH env variables.
e.g.LUA_CPATH=/path/to/?.so. Or for specific Lua version like LUA_CPATH_5_3=/path/to/?.so.
But if you have full path to some library and whant just load this particular library from this directory you can use package.loadlib function.
local function loadlib(path, name)
local sep = string.sub(package.config, 1, 1)
local file = path .. sep .. name .. ((sep == '/') and '.so' or '.dll')
local func = 'luaopen_' .. name
local loader, msg = package.loadlib(file, func)
assert(loader, msg)
return assert(loader())
end
local mylib = loadlib([[/path/to]], 'mylib')

Is there a way to `dlopen` only specified (absolute) path on iOS?

When I checked the man-page for dlopen on iOS it says:
When path contains a slash (i.e. a full path or a partial path) dlopen()
searches the following the following until it finds a compatible Mach-O
file: $DYLD_LIBRARY_PATH (with leaf name from path ), current working
directory (for partial paths), $DYLD_FALLBACK_LIBRARY_PATH (with leaf
name from path ).
but according to POSIX (Open Group):
The file argument is used to construct a pathname to the object file. If file contains a slash character, the file argument is used as the pathname for the file. Otherwise, file is used in an implementation-defined manner to yield a pathname.
So if you follow POSIX you could use dlopen("/path/to/lib", 0) to open precisely that file, but according to the iOS documentation it would search for a Mach-O file named lib in $DYLD_LIBRARY_PATH, current directory and finally $DYLD_FALLBACK_LIBRARY_PATH.
If I really want to open just /path/to/lib under iOS and not any (possibly malign) lib found in the search path, what could I do?
(If I understand it correctly POSIX allows you to use a relative path too. Would that imply that it's a path relative to the current working directory then?)

Resources