How to make the flow lines in mermaid flowchart to exact 90 degrees? - flowchart

I'm using Mermaid to create a simple flow diagram as shown below. I'd like to make the connecting lines to exact 90 degree but couldn't able to find documentation anywhere .
Is it possible to make it exact 90 degrees ?
flowchart TD
B["fa:fa-twitter for peace"]
B-->C[fa:fa-ban forbidden]
B-->D(fa:fa-spinner);
B-->E(A fa:fa-camera-retro perhaps?);
Actual Flow :
Expected Flow :

Prepend with the following init pragma. More options are available here: https://mermaid-js.github.io/mermaid/#/flowchart?id=styling-line-curves
%%{ init: { 'flowchart': { 'curve': 'stepAfter' } } }%%
See example below. Feel free to tweak it to your liking.
%%{ init: { 'flowchart': { 'curve': 'stepAfter' } } }%%
flowchart TD
A["A"] --- T1( )
T1---B[B]
T1---C[C]
T1---D[D]

There's been an open issue on the Github repo about this for a couple of months, now. It doesn't look like it's possible at the moment.

Related

Hide/fold/dim arbitrary lines of code by regex (e.g. to hide logging)

There is a lot of logging in my C++ project. The logging is done via a log stream and the log lines have the following format:
APP_LOG_XXX() << ... ;
Those log lines blend with the rest of the code and make it harder to be read.
I want to somehow make these log lines appear in dimmed colors, or even better to hide/fold by a hotkey or click. There are a lot of log lines already, so wrapping them up in #pragma region would take much time (or would require writing a separate script). I wonder if there is an easier way.
(There is a very similar question on SO, but it's about Visual Studio, not Visual Studio Code).
You can use extension Highlight.
Set the color to a version close to your theme background color
Add to your settings.json
"highlight.regexes": {
"(APP_LOG_XXX\\(\\) <<[^;]+;)": {
"regexFlags": "mg",
"decorations": [
{ "color": "#f0f0f0" }
]
}
}
Or you can use the opacity decoration property instead. The following configuration will dim the text while preserving its current syntax highlighting:
"highlight.regexes": {
"(APP_LOG_XXX\\(\\) <<[^;]+;)": {
"regexFlags": "mg",
"decorations": [
{ "opacity": "0.4" }
]
}
}

Custom submodules in pytorch / libtorch C++

Full disclosure, I asked this same question on the PyTorch forums about a few days ago and got no reply, so this is technically a repost, but I believe it's still a good question, because I've been unable to find an answer anywhere online. Here goes:
Can you show an example of using register_module with a custom module?
The only examples I’ve found online are registering linear layers or convolutional layers as the submodules.
I tried to write my own module and register it with another module and I couldn’t get it to work.
My IDE is telling me no instance of overloaded function "MyModel::register_module" matches the argument list -- argument types are: (const char [14], TreeEmbedding)
(TreeEmbedding is the name of another struct I made which extends torch::nn::Module.)
Am I missing something? An example of this would be very helpful.
Edit: Additional context follows below.
I have a header file "model.h" which contains the following:
struct TreeEmbedding : torch::nn::Module {
TreeEmbedding();
torch::Tensor forward(Graph tree);
};
struct MyModel : torch::nn::Module{
size_t embeddingSize;
TreeEmbedding treeEmbedding;
MyModel(size_t embeddingSize=10);
torch::Tensor forward(std::vector<Graph> clauses, std::vector<Graph> contexts);
};
I also have a cpp file "model.cpp" which contains the following:
MyModel::MyModel(size_t embeddingSize) :
embeddingSize(embeddingSize)
{
treeEmbedding = register_module("treeEmbedding", TreeEmbedding{});
}
This setup still has the same error as above. The code in the documentation does work (using built-in components like linear layers), but using a custom module does not. After tracking down torch::nn::Linear, it looks as though that is a ModuleHolder (Whatever that is...)
Thanks,
Jack
I will accept a better answer if anyone can provide more details, but just in case anyone's wondering, I thought I would put up the little information I was able to find:
register_module takes in a string as its first argument and its second argument can either be a ModuleHolder (I don't know what this is...) or alternatively it can be a shared_ptr to your module. So here's my example:
treeEmbedding = register_module<TreeEmbedding>("treeEmbedding", make_shared<TreeEmbedding>());
This seemed to work for me so far.

Chart.js Version 1 differences and can they be achieved in version 2?

I apologise if this is the wrong place but the chart.js git suggested this as the only place to get support.
I recently used version 1 of chart.js for a project and I picked this library over others because of the simpler/easier user experience. As an example the line graph, if you hover over an x axis it will highlight the closest points to your hover. In version 2 you have to hover over the actual point. It's a similar situation on the other graph types both in chart.js and other libraries like highcharts.js.
My question is simple, can we replicate the usability of version 1 in version 2 or have we lost this aspect completely?
Glancing at the documentation it doesn't appear to be possible.
If the answer is no, may I suggest that one of two things happen, either it's developed for version 2 or b version 1 is kept around.
You can replicate the v1.x functionality by extending the line chart type and setting the tooltip mode to label, like so
Chart.defaults.myLine = Chart.helpers.clone(Chart.defaults.line);
Chart.controllers.myLine = Chart.controllers.line.extend({
updateElement: function (point) {
var result = Chart.controllers.line.prototype.updateElement.apply(this, arguments);
point.inRange = function (mouseX, mouseY) {
var vm = this._view;
// ignore the y coordinate
return vm ? (Math.abs(mouseX - vm.x) < (vm.hitRadius + vm.radius)) : false;
};
return result;
}
});
and then
...
type: 'myLine',
...
options: {
tooltips: {
mode: 'label'
}
}
};
Fiddle - http://jsfiddle.net/gyqmbL2q/

-Holographic Displays API- How to remove holograms near a player

I am making a plugin. That when a command is typed. It removes the nearest Holograms to the sender/player. Now, the things I have tried are to remove the Invisible armor stands in a radius of 10 blocks. I also tried to see if there is a method to get the nearest holograms, but I had no luck. If there is any way to point to what I need to do, that would be helpful. I am not asking for code, just for what I need to look under, say a specific class etc.
Thanks, seb.
Trying to remove armor stands:
for(Entity en : player.getNearbyEntities(10, 10, 10)) {
if(en instanceof ArmorStand) {
en.remove();
}
}
My Question: Where should I look to find a way to remove nearby Holograms to the player? If you can provide code, not needed though.
//Loop through all existing holograms registered to your plugin
for (Hologram hologram : HologramsAPI.getHolograms(plugin)) {
Location playerLoc = player.getLocation();
Location hologramLoc = hologram.getLocation();
//Check if the distance between the locations are less than 10
//and deletes the hologram if true
if (playerLoc.distance(hologramLoc) < 10) {
hologram.delete();
}
}
This Holographic Displays API has a hologram delete method.
https://github.com/filoghost/HolographicDisplays/wiki

Yesod Julius Interpolation of Messages

I've been using Yesod's messages system to help keep my language consistent. For example, I have a message named MsgBrand, which gets interpolated into Hamlet files with no problem. However, I am now using a JavaScript library which needs this kind of information.
var tour = Tour.new();
tour.addSteps([
{ element: "#some-id",
title: "Some Title",
content: "_{MsgTourStepFoo}"
}
]);
However, _{MsgTourStepFoo} is appearing in the rendered JavaScript code verbatim. In other words, there is no interpolation. Is this normal or am I missing something?
This is normal. We could have a i18n-variant of Julius, but have avoided it so far simply because it seems like it would be more confusion than it's worth. Instead, you can use getMessageRender to get the message rendering function and then call it from Julius, something like:
Haskell:
messageRender <- getMessageRender
Julius:
content: "#{messageRender MsgTourStepFoo}"