Unable to resolve lmjoin in the winapi::um [duplicate] - winapi

I'm trying to use rand::SmallRng. The documentation says
This PRNG is feature-gated: to use, you must enable the crate feature small_rng.
I've been searching and can't figure out how to enable "crate features". The phrase isn't even used anywhere in the Rust docs. This is the best I could come up with:
[features]
default = ["small_rng"]
But I get:
Feature default includes small_rng which is neither a dependency nor another feature
Are the docs wrong, or is there something I'm missing?

Specify the dependencies in Cargo.toml like so:
[dependencies]
rand = { version = "0.7.2", features = ["small_rng"] }
Alternatively:
[dependencies.rand]
version = "0.7.2"
features = ["small_rng"]
Both work.

Related

The trait `rand_core::CryptoRng` is not implemented for `OsRng`

I've been trying to implement the example given in the following doc: https://docs.rs/ed25519-dalek/1.0.1/ed25519_dalek/
My code is simply:
extern crate rand;
extern crate ed25519_dalek;
use rand::rngs::OsRng;
use ed25519_dalek::Keypair;
fn main() {
let mut csprng = OsRng{};
let keypair: Keypair = Keypair::generate(&mut csprng);
}
But when I try to run I get an error saying that the CryptoRng trait is not implemented in OsRng
11 | let keypair: Keypair = Keypair::generate(&mut csprng);
| ^^^^^^^^^^^ the trait `rand_core::CryptoRng` is not implemented for `OsRng`
However, CryptoRng is simply a marker trait, and I saw that it indeed has an empty impl for OsRng...
So what could be the issue here?
Usually when you get these confusing messages saying "trait bound not met" when it's clearly met, or "wrong type" when it's clearly the right type, you should always check package versions. As of right now (ed25519-dalek v1.0.1), it depends on rand 0.7.0 (you can also find this on crates.io). You're using a newer version of rand, with a "newer" version of the trait, and it's looking for the 0.7.0 trait while you supply the 0.8.0 trait.
The solution? Either downgrade rand to 0.7.0 or use dependency renaming to have 2 versions of rand, and use the old version for ec25519-dalek.

Setting path to custom .irbrc using IRB.conf

I want to invoke irb dynamically from my Ruby program, but have it not to load the default ~/.irbrc, but a file ./custom_irbrc instead. I can do it like this:
require 'irb'
ENV['IRBRC'] = './custom_irbrc'
IRB.setup(nil)
# My configurations follow here
IRB.conf[...]=...
IRB.start
I wonder whether I can set my custom irbrc also via .conf instead of polluting the environment. I didn't find a really comprehensive description of the possible conf-settings, but from what I found, I tried as educated guess:
IRB.conf[:IRB_RC] = './custom_irbrc'
IRB.conf[:RC] = './custom_irbrc'
but neither one seems to have any effect.
The desired effect can be achieved, although by using an undocumented feature, and there is no guarantee that it will be available in future Ruby versions too:
IRB.conf[:RC_NAME_GENERATOR] = proc { './custom_irbrc' }
This has to be done before IRB.setup is called.

Get the method name of the callee in v8

Since nodejs >= 10 FunctionCallbackInfo::Callee has been deprecated (https://github.com/nodejs/nan/blob/master/CHANGELOG.md). I need to update a c++ code that uses v8, where the method name being called was used. How to get that now?
It is recommemded to use info.Data() instead. But I don't follow how to get the methods name from that. I guess it goes something like this:
void GetData(IN const Nan::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Function> data = v8::Local<v8::Function>::Cast(info.Data());
....
}
How do I get the methods name from data? From the documentation, looks like it cannot be done any longer (https://github.com/nodejs/nan/blob/master/doc/methods.md):
Note: FunctionCallbackInfo::Callee is removed in Node.js after 10.0.0 because it is was deprecated in V8. Consider using info.Data() to pass any information you need.
So, if no extra information is supplied, there is no way to get the name of the callee?
This did the trick:
v8::Local<v8::Function> out;
out = v8::Local<v8::Function>::Cast(info.Data());
v8::String::Utf8Value callee(out->GetName()->ToString());

Declare custom rule type as Vulnerability in SonarQube 6.3

I am using sonarQube 6.3 and when adding new custom rules for Php or Javascript, they are by default declared as Code smell. I would like to declare them as Vulnerability or bug.
Here is an example of a rule declaration
#Rule(key = "Rule1",
priority = Priority.MAJOR,
name = "Rule 1 sould be used.",
tags = {"suspicious" })
Is there a way to do it?
There is a way to set the rule type using some special tags.
Tag "bug" means type "bug"
Tag "security" means type "vulnerability"
So try for example:
tags = {"suspicious", "bug"}
NB: This is documented in API Javadoc (but hard to find I admit)

FHIR.net Property added to Practitioner

We're currently using FHIR.net library(STU3). The FHIR Server from which we are receiving information has added a practitionerRole property to the Practitioner. Thus when Reading a Practitioner, we get the following Exception:
Encountered unknown member 'practitionerRole' while de-serializing (at path 'line 1, pos 2') in Hl7.Fhir.Rest.HttpToEntryExtensions.parseResource(String bodyText, String contentType, ParserSettings settings, Boolean throwOnFormatException)
The only solution I could think of is to add a practitionerRole property in the Model\Generated\Practitioner.cs class that would go like that:
[FhirElement("practitionerRole", InSummary = true, Order = 115)]
[Cardinality(Min = 0, Max = -1)]
[DataMember]
public List<Hl7.Fhir.Model.PractitionerRole> PractitionerRole
{
get { if (_PractitionerRole == null) _PractitionerRole = new List<Hl7.Fhir.Model.PractitionerRole>(); return _PractitionerRole; }
set { _PractitionerRole = value; OnPropertyChanged("PractitionerRole"); }
}
private List<Hl7.Fhir.Model.PractitionerRole> _PractitionerRole;
Is there any other solution than that? If so, which one?
Thank you in advance
It sounds like you're talking to a DSTU2 server. You'll need some sort of a conversion layer between your system and theirs.
As stated by FHIR employees in https://sea-region.github.com/standardhealth/shr_spec/issues/187 , DSTU2 and STU3 are two different versions of FHIR standard. If you check their last commits (https://www.nuget.org/packages?q=Fhir) as in August 2019, you will see they are maintaining both standards. That is probably due to the hospitals using STU3 version and do not want to adapt to the new version of FHIR, which is DSTU2.
The problem arises when you want to reach a class, let's say Patient, that coexists in two versions. Compiler can not decide which "Patient" class you refer to.
Normally, you could specialize using imports or predescription such as :
Hl7.Fhir.Model.Patient p = new Hl7.Fhir.Model.Patient();
BUT, Patient classes in both versions are described as Hl7.Fhir.Model.Patient. Their namespace is "Hl7.Fhir.Model" and their class name is "Patient".
Normally, you could workaround using keyword:
extern alias
BUT, since model classes in FHIR are read only, you can not use both versions in same project.
You need to uninstall unwanted FHIR version and install wanted version. To do these in Visual Studio,
go to Solution Manager> right click on "Manage Nuget Packages" > Search "Fhir" > uninstall unwanted FHIR version > install wanted version
You can also follow the unanswered question below:
C# T4 Template equivalent for "extern alias"

Resources