dnd 5e: Which pattern would be best for a sorcerer who kicked a pact to get revenge?

I'm not going to play System / Mechanics here. I believe that all users and / or covenants would be available. But here are my thoughts:

Good song!

I heard Fae's influences on music, so ArchFey (PHB) would work. They are known for their offers and contracts, so a pact of revenge seems to fit.

Demon (PHB): demons and demons would embrace revenge as a motive. If you accelerate your soul's path to hell, they will surely register you!

Celestials (XGE) do not seem to fit, for me. YMMV

Great old man (PHB) is too Alien. They care little about the morals of mortals.

Hexblade (XGE) is always a good choice! Covenant of the Leaf, and stab your way to victory! Lots of space to fit your story.

Eternal (SCAG): Definitely something to work here. Not even death can stop your thirst! ("I will have my revenge, in this life, or next!")

"The Covenant Embraced, the road helpless" It seems to imply a level of reluctance, or at least ignorance. Did you know what Ganga you were entering? Fey are like that!

(PHB) = Book of hands of the players. (XGE) = Xanathars Guide for everything. (SCAG) = Guide of the adventurers of the coast of the sword.

c # – Am I using the Factory pattern in my code and how can I test it?

In my application I have an interface "IEmailNotification" that represents an email and the concrete implementations have nothing to do with MailMessage class to be able to send it through SmtpClient I used an adapter to allow communication between SmtpClient & IEmailNotification is possible and the job of this adapter is simply to delegate the call Send to SmtpClient but after converting from EmailNotification to MailMessage using an abstract factory that actually only copies the values ​​of an object to the new created MailMessage object.

The first question is:
my factory method takes a parameter of type IEmailNotification, does it violate the main job of a factory that only creates objects?

public override MailMessage CreateMailMessage (IEmailNotification emailNotification)
{
var mailMessage = new MailMessage ();

mailMessage.From = new MailAddress (emailNotification.From);
mailMessage.To.Add (_redirectToEmail);
mailMessage.Subject = emailNotification.Subject;
mailMessage.Body = emailNotification.Body;
mailMessage.IsBodyHtml = emailNotification.IsBodyHtml;

if (emailNotification.To.ToLower (). Contains ("shopfehler"))
mailMessage.Bcc.Add (new email address (_backupBccEmail));

if (! string.IsNullOrEmpty (emailNotification.ReplyToList))
mailMessage.ReplyToList.Add (emailNotification.ReplyToList);

if (emailNotification.AttachmentsPaths.Count> 0)
{
foreach (var route in emailNotification.AttachmentsPaths)
{
mailMessage.Attachments.Add (new attachment (path));
}
}

return the mail message;
}

The second question is:
when I tried to test the logic of this method Failed because it uses an external resource in the line to add new attachments where it can not find the related paths on the hard drive, what do you think about it?

thanks in advance

Object-oriented: C ++ pattern for configurable compile-time functionality

Due to resource constraints (embedded), I want to make some functionalities that a class provides optional. The decision to include this optional functionality must be made at compile time.

For example, I have a memory allocator based on a simple group, which has optional statistics support. The statistics support must be available for the x86 and ARM debug compilations, but not for the ARM release builds.

The following code is an extract of the current implementation, based on C, that shows the type of interaction between the group itself and a conditionally included statistic member structure:

structure fmpool {
// ...
#ifdef FMPOOL_SUPPORT_STATISTICS
fmpool_statistics stats;
#determinate if
// ...
}

int fmpool_alloc (fmpool * pool, void ** alloc_block, size_t alloc_size)
{

// make the assignment

#ifdef FMPOOL_SUPPORT_STATISTICS
selected_pool-> stats.blocks_used ++;
if (selected_pool-> stats.blocks_used> selected_pool-> stats.blocks_used_peak)
{
selected_pool-> stats.blocks_used_peak = selected_pool-> stats.blocks_used;
}
debug_log_pool_info (selected_pool);
#determinate if

// ...
}

I am not sure which pattern best fits this use case, but I would like to clear the code of the allocator by removing the statistics code from the allocator itself.

Also, the code is terribly full of #ifdefs, so it is desirable to reduce the interaction between the dispatcher code and the allocator statistics code as much as possible.

pattern matching – Use of PatternSequence and __ / Repeat[]

I'm trying to scrape is Wikipedia page (& # 39; Deaths in 2019-July & # 39 ;, I'm writing this on the 14th.). I am failing miserably and I am beginning to think that it is due to a misconception on my part in the use of patterns.

Namely, the use of __ vs .. Y Sequence of patterns.

Please help.

I usually to import

The[[, "XML"] to import the page. I usually pattn0 (see below) to identify the positions pos0 = Position

The[[, pattn0] Y pos1 = MapAt[# + 1 &, pos0, {All, -1}].

pos Y pos1 They are used to identify the positions of the desired entries.

I'm using src = Apply[Part

The[Part[[Part[, ##]&, Riffle[pos0, pos1], one] in all attempts to match patterns as the source on which I try to extract (or compare) the parts I want.

(I provide a link to the src used, at the end of the question)

Fragment of the desired entries.

I'm going to report a couple of random entries below that interest me:

XMLElement["h3", {}, {
   XMLElement["span", {"class" -> "mw-headline", "id" -> "14"}, {"14"}]
  }
],

XMLElement["ul", {}, {

   XMLElement["li", {}, {
      XMLElement["a", {"href" -> "/wiki/Hussain_Muhammad_Ershad", "title" -> "Hussain Muhammad Ershad"}, {"Hussain Muhammad Ershad"}], ", 89, head of the Bangladesh army and politician",
XMLElement["a", {"href" -> "/wiki/President_of_Bangladesh", "title" -> "President of Bangladesh"}, {"President"}]"(1983 [Dash]1990).
XMLElement["sup", {"id" -> "cite_ref-1", "class" -> "reference", {XMLElement["a", {"href" -> "#cite_note-1"}, {"[1]"}]}]}
],

XMLElement["li", {}, {
      XMLElement["a", {"href" -> "/wiki/Lavenia_Padarath", "title" -> "Lavenia     Padarath"}, {"Lavenia Padarath"}], ", 74, Fijian politician.",
XMLElement["sup", {"id" -> "cite_ref-2", "class" -> "reference"}, {XMLElement["a", {"href" -> "#cite_note-2"}, {"[2]"}]}]}
]}
]

Patterns I-I'm trying to-use

I am using the following patterns to match the entries that interest me:

pattn0 = XMLElement["h3", _, {
   XMLElement["span", {"class" -> "mw-headline", "id" -> id_}, {idnm_}]
  }
]

(pattn0 matches the numbers of days reported in the header of each day)

Y

pattn1 = XMLElement["a", {"href" -> href_, Longest[othr___], "title" -> tit_, last___}, {nm_}];
pattn2 = PatternSequence[pattn1, Longest[cmnt___]];
  • pattn2 is used to match against entries like XMLElement["a", {__}, {_}] what are the data entries that interest me (mostly)
  • In pattn2 I'm using Longer[othr___] because there are some entries where, between "href" Y "Title", there intervenes some other minor entry XMLElement[__]).
  • As well, latest___ It is there to match the remaining entries that could have been lost.
  • By last, Longer[cmnts___] is used to match the entries (usually, as far as I can tell, only one) after XMLElement["a", __].

pattn3 Y pattn4 Match against the reference entries:

pattn3 = XMLElement["a", {"href" -> href2_}, {refn_}];
pattn4 = XMLElement["sup", {"id" -> id_, "class" -> "reference", {pattn3}];

(pattn4 it is used to match against XMLElement["sup", {__, {__}] What are the entries related to the references and their links?)

pattn5 combines all the patterns in one (unfortunately it does not work):

pattn5 = PatternSequence[pattn0, x : XMLElement["ul", _, {XMLElement["li", _, {pattn2 .., pattn4}] ..}]];

Things that work

  • Retrieving day numbers
    Evaluating Cases[src, pattn0 :> idnm] jobs! and returns the numbers of the day

    {14,13,12,11,10,9,8,7,6,5,4,3,2,1}
    

    as expected.

  • Retrieving footnotes / references
    Both of them pattn3 Y pattn4 work. Here, evaluating Cases[src, pattn4, Infinity] Works (first five results):

    {
    XMLElement[sup,{id->cite_ref-1,class->reference},{XMLElement[a,{href->#cite_note-1},{[1]}]}],
    XMLElement[sup,{id->cite_ref-2,class->reference},{XMLElement[a,{href->#cite_note-2},{[2]}]}],
    XMLElement[sup,{id->cite_ref-3,class->reference},{XMLElement[a,{href->#cite_note-3},{[3]}]}],
    XMLElement[sup,{id->cite_ref-4,class->reference},{XMLElement[a,{href->#cite_note-4},{[4]}]}],
    XMLElement[sup,{id->cite_ref-5,class->reference},{XMLElement[a,{href->#cite_note-5},{[5]}]}], ...}
    

Things that work partially

  • pattn2

    In using pattn2 I get partially matched results; namely, the part related to Longer[cmnt___] it does not match, ever! Essentially what works seems to be the part related to pattn1.

    Cases[src, pattn2, Infinity]
    

    evaluate the partially correct result (only the first five entries shown here to avoid clutter)

    {
    XMLElement[a,{href->/wiki/Hussain_Muhammad_Ershad,title->Hussain Muhammad Ershad},{Hussain Muhammad Ershad}],
    XMLElement[a,{href->/wiki/Chief_of_Army_Staff_(Bangladesh),title->Chief of Army Staff (Bangladesh)},{Chief of Army Staff}],
    XMLElement[a,{href->/wiki/President_of_Bangladesh,title->President of Bangladesh},{President}],
    XMLElement[a,{href->/wiki/Nereo_Laroni,title->Nereo Laroni},{Nereo Laroni}],
    XMLElement[a,{href->/wiki/Mayor_of_Venice,title->Mayor of Venice},{Mayor of Venice}], ...}
    

Things that should have worked but not!

Suggestions, Nudges, tips on how to get a decent match

They are all welcome.

Thank you!


Appendix

I provide the src used throughout the question (pastebin). run Decompress in the chain to retrieve the XML elements.

linux: change the first pattern of characters in a file name without changing that same pattern in another part of the file name

On a Linux server I have a directory full of files with digits for names. Some of the files start with two zeros like 00305005. I'm writing a bash shell script and one of the steps is to rename all the files that start with 00 so they start with @ 0. The file I mentioned earlier would be @ 0305005 .

The problem I have is that when I try to change the name of the files, I end up changing all the instances of 00 in the file name to @ 0 like this: @ 0305 @ 05. I have been using the following code and I do not know how to fix it :

for f in 00 *; do mv "$ f" "$ {f // 00 / @ 0}"; fact

Is this factory pattern or strategy pattern? c / c ++, and proposing an alternative solution.

The idea is that when we want to create an object of some kind, we will only use a creator robot and we will enumerate from the interface. I would like to understand what template design I used because sometimes it looks like a factory and sometimes like a strategy.

Should I use define or not? I will also be happy to receive new ideas to implement.

InterfaceRobot.h

    InterfaceRobot class
{
public:
InterfaceRobot ();
RobType enumeration {Y = 0, C = 1, D = 2, F = 3};

virtual void open () = 0;
virtual empty close () = 0;
};

#endif // INTERFACEROBOT_H

RobotCreator.h

RobotCreator class: public user interface
{
public:
RobotCreator (InterfaceRobot :: RobType _robType);
open vacuum ();
void close ();
~ RobotCreator ();

private:
InterfaceRobot * Robot; / ** pointer to InterfaceRobot ** /
};

RobotCreator.cpp

RobotCreator :: RobotCreator (InterfaceRobot :: RobType _robType)
{
switch (_robType)
{
InterfaceRobot case :: C:
this-> Robot = new c ();
break;
InterfaceRobot :: Y case:
this-> Robot = new and ();
break;
InterfaceRobot case :: D:
this-> Robot = new D ();
break;
InterfaceRobot :: F case:
this-> Robot = new F ();
break;
}
}

void RobotCreator :: open ()
{
this-> Robot-> open ();
}

void RobotCreator :: close ()
{
this-> Robot-> close ();
}

RobotCreator :: ~ RobotCreator ()
{
cout << "d & # 39; tor of RobotCreator" << endl;
    if (this->Robot! = NULL)
{
delete[]  this-> dlRobot;
this-> Robot = NULL;
}
}

use in main:

int main ()
{

RobotCreator rob (InterfaceRobot :: Y);
rob.open ();
rob.close ();

RobotCreator rob2 (InterfaceRobot :: C);
rob2.open ();
rob2.close ();
}

What is this strange noise pattern in my images?

So recently this strange noise pattern started to appear in my photos. I am using the Canon Eos 1100D beginner level camera. That noise appears mainly in the photos that have a lot of contrast (natural) in them, with the dark areas. When I shoot more quality is more and more visible. It also creates that red tone at the top of the image. The amount of ISO does not matter. Only if it has a lot of contrast. I managed to trace the window where it started to show and there is only an interval of a few hours between the last normal photo and the first one that appeared and my camera was just sitting that time. It can appear in the form as above but also in square form.

Algorithms – What is the pattern / rule underlying this question?

I can not find a concise algorithm for the following coding problem:

Given the assignment a = 1, b = 2, … z = 26 and a coded message, count the number of ways in which it can be decoded. For example, the message & # 39; 111 & # 39; would give 3, since it could be decoded as & # 39; aaa & # 39 ;, & # 39; ka & # 39; and & # 39; ak & # 39; It can be assumed that the messages are decodable. For example, & # 39; 001 & # 39; it's not allowed.

I have recognized that any number <= 26 It can be represented in 2 ways. I tried to observe what happens when I add a number like two, which can then form another 2-digit number with the following (for example, 22 – 2 combinations 222 – 3, 2222 – 5, 22222 – 8). But I can not seem to find a robust pattern.

This was a coding interview question that should last 30 minutes, so I'm ashamed of not being able to see the latent rule.

How to deny a range of IP addresses that follow a pattern in ufw?

I want to block all incoming patron ip's 192.168. *. * (This is an example). I tried ufw deny from 192.168. *. * to someone But give this error.

ERROR: Wrong source address

How can I block a range of IP addresses that follow a specific pattern?

date – Format pattern for dates

I am trying to generate a date with a format like the following:

new SimpleDateFormat ("??????") -> "" 2019-07-02T10: 54: 55.440Z "

But right now the closest approach I've had to this format is the following:

new SimpleDateFormat ("YYYY-MM-DD'T'hh: mm: ss.sssZ") -> "2019-07-183T12: 34: 12.012 + 0200"

I have based on the UTC standard page but I have not been able to replicate the format of the first statement.