How to get the full source code of an Action in Red? - red

As I can see read is not native
>> native? :read
== false
but when I tried to get the source code with
write-clipboard mold :read
I only got header of read
make action! [[
"Reads from a file, URL, or other port"
source [file! url!]
/part {Partial read a given number of units (source relative)}
length [number!]
/seek "Read from a specific position (source relative)"
index [number!]
/binary "Preserves contents exactly"
/lines "Convert to block of strings"
/info
/as {Read with the specified encoding, default is 'UTF-8}
encoding [word!]
]]
Can I get the rest body somehow ?

The source code of native! and action! values is written in Red/System and part of the low-level runtime library code. They are not implemented in Red itself for sake of performance or because they require access to low-level features not available at Red level. Natives source code have a single entry point which you can find in the runtime/natives.reds file. For actions, it is more complex as they delegate their implementation to each datatype. Actions are basically methods for the datatype classes.

Related

How to add a custom library using add_block?

I created a custom library. This library contains only one subsytem block named RADAR. I am trying to use add_block and add this subsytem. Without any error the simulink file opens but the block does not appear.
This is how I load my library.
load_system('libdeneme');
And these are some of the code lines I tried.
add_block('simulink/libdeneme/RADAR','autoCreateDeneme')
add_block('simulink/libdeneme/RADAR','autoCreateDeneme')
add_block('libdeneme/RADAR','autoCreateDeneme')
add_block('libdeneme/RADAR',)
The source needs to be the library name then the name of the block in the library. Your first 2 lines don't work because your library is not the simulink library. But the source name in your last 2 attempts look right.
The destination needs to be the name of the model followed by the name to give the new block. Neither of your examples follow that format. (Surely the last example you give throws an error as it is invalid MATLAB syntax?)
You want something like
add_block('libdeneme/RADAR','nameOfModelToCopyTo/nameToGiveBlockInModel');

Change configuration options for specific files only

I'm working on a small part of a huge project. I need to change some Doxygen configuration options only for specific files. For example, there is such configuration option DOT_GRAPH_MAX_NODES and its default value is 50. I need to increase its value to 100 but only for some source files (for all other source files it should be 50). What is the the best way to achieve it?
I'm a newbie in Doxygen and I tried to #include my configuration file on a top of .cpp or try to set a new value to an option there as well but it did not help (but did not cause any warnings or errors):
/// #include MyDoxyfile
// or
/// DOT_GRAPH_MAX_NODES = 10000
I appreciate any help.
In doxygen the DOT_GRAPH_MAX_NODES is a global setting and cannot be altered. This contrary to some graphs that can be shown / hidden:
• if CALL_GRAPH is set to YES, a graphical call graph is drawn for
each function showing the functions that the function directly or
indirectly calls (see also section \callgraph and section
\hidecallgraph).
• if CALLER_GRAPH is set to YES, a graphical caller
graph is drawn for each function showing the functions that the
function is directly or indirectly called by (see also section
\callergraph and section \hidecallergraph).
and in the upcoming 1.8.15 version a similar mechanism is implemented for
REFERENCED_BY_RELATION, commands: showrefby and hiderefby
REFERENCES_RELATION, commands: showrefs and hiderefs

Ignore or bypass errors phpcs

How to bypass or ignore specific errors/warnings in vscode?, I am using phpcs.
What you are looking for is to ignore the warning and/or errors, that are notified by the phpcs in the console of the vscode.
For Warnings
Use the following config in your settings.json
"phpcs.showWarnings": false,
this will remove all the warnings displayed in the output console.
For Errors
You should go trough the DOCS for complete details but to remove the errors related to the Doc block and the formatting standards you can set the
"phpcs.errorSeverity": 6,
Although it is mostly used for testing or code reviews to check for total warnings and errors by setting different values for both, but for development i dont do that and keep it to the default value that is 5 but you can get rid of those errors above in your image.
The vscode-phpcs refers to the GitHub project squizlabs/PHP_CodeSniffer, which integrates PHP_CodeSniffer into VSCode.
Its readme mentions the setting phpcs.ignorePatterns:
An array of glob patterns to skip files and folders that match when linting your documents.
{
"phpcs.ignorePatterns": [
"*/ignored-file.php",
"*/ignored-dir/*"
]
}
That refers to PHP CodeSniffer --ignore option.
That is not what you want exactly, since it ignores all errors on a given set of file.
But you could use PHP CodeSniffer syntax to ignore errors:
Ignoring Parts of a File
Some parts of your code may be unable to conform to your coding standard. For example, you might have to break your standard to integrate with an external library or web service.
To stop PHP_CodeSniffer generating errors for this code, you can wrap it in special comments. PHP_CodeSniffer will then hide all errors and warnings that are generated for these lines of code.
$xmlPackage = new XMLPackage;
// phpcs:disable
$xmlPackage['error_code'] = get_default_error_code_value();
$xmlPackage->send();
// phpcs:enable
Again, not exactly what you want, since you have to specify that on a file-by-file basis
You can disable multiple error message codes, sniff, categories, or standards by using a comma separated list.
You can also selectively re-enable just the ones you want.
The following example disables the entire PEAR coding standard, and all the Squiz array sniffs, before selectively re-enabling a specific sniff. It then re-enables all checking rules at the end.
// phpcs:disable PEAR,Squiz.Arrays
$foo = [1,2,3];
bar($foo,true);
// phpcs:enable PEAR.Functions.FunctionCallSignature
bar($foo,false);
// phpcs:enable

minifilter driver | tracking changes in files

What I'm trying to achieve is to intercept every write to a file and track the changes within the file. I want to track how much different the file content before and after the write.
So far in my minifilter driver I registered to IRP_MJ_WRITE callbacks and can now intercept writes to file. However I'm still not sure how can I obtain the content of the file before [preoperation] and the content after [postoperation].
The parameters that I have within the callback functions are:
PCFLT_RELATED_OBJECTS, PFLT_CALLBACK_DATA and I could not find anything related to the content of the file itself within these.
These are the operations that could change data in a file:
Modifying the file: IRP_MJ_WRITE, IRP_MJ_SET_INFORMATION ( specifically the FileEndOfFileInformation and FileValidDataLengthInformation information classes), IRP_MJ_FILE_SYSTEM_CONTROL ( specifically FSCTL_OFFLOAD_WRITE, FSCTL_WRITE_RAW_ENCRYPTED and FSCTL_SET_ZERO_DATA fsctl codes).
As for the content of the file itself that you just need to read it yourself.
If you mean the buffers as they are being written for example, check this out to find out more about the parameters of IRP_MJ_WRITE in the callback data. Esentially the buffer is at Data->Iopb->Parameters.Write.WriteBuffer/MdlAddress
Make sure you handle that memory correctly otherwise it will result a BSODs.
Good luck.

Problems with GitHub rendering my README.rst incorrectly..?

I've got a GitHub repo/branch where I'm attempting to update the README.rst, but it's not formatting the way I expect when it comes to the bullet lists I'm including.
Everything seems ok except for my Usage section, in which I have the following:
*****
Usage
*****
- Open the template file that corresponds to the API call you'd like to make.
* Example: If we want to make a call to the RefundTransaction API we open up /templates/RefundTransaction.php
- You may leave the file here, or save this file to the location on your web server where you'd like this call to be made.
* I like to save the files to a separate location and keep the ones included with the library as empty templates.
* Note that you can also copy/paste the template code into your own file(s).
- Each template file includes PHP arrays for every parameter available to that particular API. Simply fill in the array parameters with your own dynamic (or static) data. This data may come from:
* Session Variables
* General Variables
* Database Recordsets
* Static Values
* Etc.
- When you run the file you will get a $PayPalResult array that consists of all the response parameters from PayPal, original request parameters sent to PayPal, and raw request/response info for troubleshooting.
* You may refer to the `PayPal API Reference Guide <https://developer.paypal.com/webapps/developer/docs/classic/api/>`_ for details about what response parameters you can expect to get back from any successful API request.
+ Example: When working with RefundTransaction, I can see that PayPal will return a REFUNDTRANSACTIONID, FEEREFUNDAMT, etc. As such, I know that those values will be included in $PayPalResult['REFUNDTRANSACTIONID'] and $PayPalResult['FEEREFUNDAMT'] respectively.
- If errors occur they will be available in $PayPalResult['ERRORS']
You may refer to this `overview video <http://www.angelleye.com/overview-of-php-class-library-for-paypal/>`_ of how to use the library,
and there are also samples provided in the /samples directory as well as blank templates ready to use under /templates.
You may `contact me directly <http://www.angelleye.com/contact-us/>`_ if you need additional help getting started. I offer 30 min of free training for using this library,
which is generally plenty to get you up-and-running.
For some reason, though, when you look at that on GitHub the first line of the bullet lists is coming up bold and italics and I have no idea why. Also, the sub-list where it shows Session Variables, General Variables, etc. is supposed to be all the same sub-list. I'm not sure why it's dropping into another sub when it sees General Variables.
Any information on what I've done wrong here would be greatly appreciated. Thanks!
Switch from .rst to .md and then use '#' for your headings.
## Usage
- Open the template file that corresponds to the API call you'd like to make.
* Example