nf | minimal programming language , designed as an interactive | Interpreter library
kandi X-RAY | nf Summary
kandi X-RAY | nf Summary
A minimal programming language, originally designed as an interactive environment for my os/64. Inspired by Forth, but not compatible. Easily portable to different platforms, including DOS and bare-bones x86. Main characteristics: imperative, stack-based, interpreted, compiled to bytecode.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of nf
nf Key Features
nf Examples and Code Snippets
def enqueue_tpu_embedding_sparse_batch(sample_indices,
embedding_indices,
aggregation_weights,
device_ordinal,
Community Discussions
Trending Discussions on nf
QUESTION
In C++20, we got the capability to sleep on atomic variables, waiting for their value to change.
We do so by using the std::atomic::wait
method.
Unfortunately, while wait
has been standardized, wait_for
and wait_until
are not. Meaning that we cannot sleep on an atomic variable with a timeout.
Sleeping on an atomic variable is anyway implemented behind the scenes with WaitOnAddress on Windows and the futex system call on Linux.
Working around the above problem (no way to sleep on an atomic variable with a timeout), I could pass the memory address of an std::atomic
to WaitOnAddress
on Windows and it will (kinda) work with no UB, as the function gets void*
as a parameter, and it's valid to cast std::atomic
to void*
On Linux, it is unclear whether it's ok to mix std::atomic
with futex
. futex
gets either a uint32_t*
or a int32_t*
(depending which manual you read), and casting std::atomic
to u/int*
is UB. On the other hand, the manual says
The uaddr argument points to the futex word. On all platforms, futexes are four-byte integers that must be aligned on a four- byte boundary. The operation to perform on the futex is specified in the futex_op argument; val is a value whose meaning and purpose depends on futex_op.
Hinting that alignas(4) std::atomic
should work, and it doesn't matter which integer type is it is as long as the type has the size of 4 bytes and the alignment of 4.
Also, I have seen many places where this trick of combining atomics and futexes is implemented, including boost and TBB.
So what is the best way to sleep on an atomic variable with a timeout in a non UB way? Do we have to implement our own atomic class with OS primitives to achieve it correctly?
(Solutions like mixing atomics and condition variables exist, but sub-optimal)
...ANSWER
Answered 2021-Jun-15 at 20:48You shouldn't necessarily have to implement a full custom atomic
API, it should actually be safe to simply pull out a pointer to the underlying data from the atomic
and pass it to the system.
Since std::atomic
does not offer some equivalent of native_handle
like other synchronization primitives offer, you're going to be stuck doing some implementation-specific hacks to try to get it to interface with the native API.
For the most part, it's reasonably safe to assume that first member of these types in implementations will be the same as the T
type -- at least for integral values [1]. This is an assurance that will make it possible to extract out this value.
... and casting
std::atomic
tou/int*
is UB
This isn't actually the case.
std::atomic
is guaranteed by the standard to be Standard-Layout Type. One helpful but often esoteric properties of standard layout types is that it is safe to reinterpret_cast
a T
to a value or reference of the first sub-object (e.g. the first member of the std::atomic
).
As long as we can guarantee that the std::atomic
contains only the u/int
as a member (or at least, as its first member), then it's completely safe to extract out the type in this manner:
QUESTION
the content of a.txt
...ANSWER
Answered 2021-Jun-14 at 04:43Because your $i
is only visible to bash
, not awk
. You need to pass it into your awk script as:
QUESTION
I have a microcontroller which I communicate with my windows pc, through FT232RL. On the computer side, I am making a C-library to send and receive data, using windows API.
I have managed to:
- Receive data (or multiple receives),
- Transmit data (or multiple transmits),
- First transmit (or multiple transmits) and then receive data (or multiple receives)
But I have not managed to:
- Transmit Data and then receive.
If I receive anything, and then try to transmit, I get error. So, I guess when I receive data, there is a change in configuration of the HANDLE hComm
, which I cannot find.
So the question is, what changes to my HANDLE hComm
configuration when I receive data, which does not allow me to transmit after that?
Here is my code/functions and the main() that give me the error. If I run this, I get this "error 6" -screenshot of the error down below-:
...ANSWER
Answered 2021-Jun-14 at 01:17According to MSDN:Sample, Maybe you need to set a pin's signal state to indicate the data has been sent/received in your microcontroller program. More details reside in your serial communication transmission of data standard. And you should write code according to the result of WaitCommEvent(hCom, &dwEvtMask, &o);
like the linked sample.
QUESTION
So I'm trying to learn to build NF token, and I cloned a repo. It's supposed to work with truffle. The thing is I have an error with the compiler, and I don't really understand. Indeed what I know is that the solidity compiler have problems with different versions, hence working with truffle CLI that works better with different versions projects.
So I tried to change to "pragma solidity >0.5.8 <0.6.0;", I did sudo truffle compile, and still have the error.
The error message I got is:
my typo `Source file requires different compiler version (current compiler is 0.7.4+commit.3f05b770.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version
I know that I need to find a good version of solidity and truffle, but I believe that my versions are okay :
Truffle v5.0.5 (core: 5.0.5) Solidity v0.5.0 (solc-js) Node v14.16.0
ANSWER
Answered 2021-Mar-16 at 11:01Change the compiler version in the truffle-config.js file to match the one your are using in your smart contract
QUESTION
I’m developing a .NET
program which suppose to be communicate with other existing program in same machine using Shared Memory (Memory Mapped Files), The existing program itself include a native dll
and .NET
wrapper / bridge dll
which I could consume to communicate with the other program.
The thing is the other program is very buggy and the source codes of the program and dll
are long gone, so my goal is to recreate the other program. I could decompile .NET
dll
but it just straight P/Invoke
the native dll
.
Fortunately, I able to view the memory mapped file with System.IO.MemoryMappedFiles.MemoryMappedFile
but that’s all I got, I have no idea in which offset the dll
read the data from memory mapped file when I call certain functions from it (Most of the time the dll
only doing read and no write)
I also tried to hook CreateFileMapping
, OpenFileMapping
and MapViewOfFile
in C++ program and call certain functions inside the native dll
but those hooked function only called once in during initialization and did not trigger when invoke function in dll
that suppose to read data from memory mapped file. If I dare to guess, the dll
must be has pointer to the memory mapped file.
So my question, is it possible to put breakpoint or detect when any process attempt to read / write of certain region of memory mapped file? For an instance, I'd like to know whether there's read process or pointer pointing at offset 0xdeadbeef
in my memory mapped file. I'm open to alternative, so let me know if you had any better idea
ANSWER
Answered 2021-Jun-09 at 17:45I'm not familiar with Memory Mapped File but if the two process share same memory, I believe it has same physical address, if this is true then you could probably use Cheat Engine with kernel mode.
Just keep in mind that it can cause system instability or crash so make sure to save all your works before proceeding. You can follow this steps:
- First open one of the program, make sure that "shared memory" is created before proceeding into the next step.
- Open Cheat Engine, make sure to enable kernel mode for
OpenProcess
in Settings -> Extra and enable kernel debugger in Settings -> Debugger Options (otherwise you won't be able to observe the instructions that access the memory) - Open the process in Cheat Engine, select the program that you launched in the first step
- Now scan the memory inside cheat engine, since you mentioned that you able to view the memory, take out some chunk of bytes that you wish to monitor, change value type to array of byte and scan for those bytes
- Scan result will appear in the left pane, you might found multiple result, there's only one correct address most of the time and the rest is accidentally match with the value you scan for, right click and select Browse this memory region, make sure that surrounding data match with what you expect
- Back to main window, double click the correct ones and it will appear on the bottom pane, right click it and select "DBVM Find out what writes or access this address", a dialog will appear (or your system might crash), the most important part is ensure that the physical address there instead appearing at textbox
- Select access type, you could watch only writes or both read and writes and hit "Start watch" button
- Every time any process make an attempt to access or write into that memory region, new instruction will appear in the list.
In my opinion, this topic is close to reverse engineering. Since you're open to suggestion, here's my other two cents: if you had a plan to re-create the existing program which emit the data via shared memory and you're developing the client too, why not remake both of them from scratch so you don't have to deal with this?
QUESTION
(new in javascript)
I am asked to remove a country (China) from the dropdown menu of the plugin intl-tel-input
the code below displays the dropdown menu and it looks that it calls the utils.js file to retain the countries
...ANSWER
Answered 2021-Jun-11 at 12:14If you take a look at the intl-tel-input
documentation regarding Initialisation Options. There is an option called excludeCountries
.
We can modify your initialisation code to include this option to exclude China:
QUESTION
Both CreateFileMappingA and CreateFileA returns HANDLE type, but CreateFileMappingA returns NULL on error, and CreateFileA returns INVALID_HANDLE_VALUE instead.
I'm wondering why the API is designed like that, why won't those APIs both use NULL or INVALID_HANDLE_VALUE?
...ANSWER
Answered 2021-Jun-10 at 21:16As explained by Raymond Chen in Why are HANDLE return values so inconsistent?:
Why are the return values so inconsistent?
The reasons, as you may suspect, are historical.
The values were chosen to be compatible with 16-bit Windows
QUESTION
I have a DB::table query that I make a join with. In case the join is not possible, I want to set the value of the attribute that I'm looking for with my join to 0 for the order. With my current query, entries that have no join are ignored.
...ANSWER
Answered 2021-Jun-10 at 01:58SELECT A.id,IFNULL(B.field_that_might_be_matched,0)
FROM table_a A
LEFT JOIN
table_b B
ON
A.id = B.table_a_id
ORDER BY 2
QUESTION
we have file like the following
more file
...
ANSWER
Answered 2021-Jun-09 at 09:41Like this?:
QUESTION
I'm trying to add a delimiter to the following text format (actual file has many more fields).
What I see is the length of each field is given by the length of each underscores blocks ------------
that are below each header.
Input:
...ANSWER
Answered 2021-Jun-08 at 07:19You may use this awk that will with any version of awk
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install nf
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page