email – SPF: Sender Policy Framework (Too many included lookups)

Issue: I don’t understand SPF well enough to know where to post this question

Goal: Figure out how to include more than 10 valid senders to my SPF record

I currently have a warning on my SPF record that it violates RFC 7208 because it requires too many lookups. Unfortunately the number I’ve added is the number I need (I actually only have 6 senders on there) but that turns into 12.

I can’t control what other domains do, if they are redirecting the domain they provide me for SPF also they can always change their domain again and turn my current 12 lookups to 15 for all I know.

We also aren’t allowed have multiple SPF records on a given domain, so whats the answer? What if….I actually needed 12 senders? Is SPF broken for bigger organizations that require lots of senders, or am I missing the solution?

What are the best SEO framework / plugins for a WordPress Site: Genesis, Yoast Plugin, etc ?

What are the best SEO framework / plugins for a WordPress Site: Genesis, Yoast Plugin, etc ?

entity framework – Al insertar datos en una tabla me inserta otra y me da duplicado C# EF 6 Code First

en esta oportunidad los molesto para ver si me pueden ayudar.
Estoy haciendo un desarrollo en C# Entitiy framework 6 Code First, tengo un modelo Empresa y otro Sobre,
donde una empresa puede tener muchos sobres. Lo que me pasa es que al querer insertar un sobre obtengo un error que no se pueden insertar elementos duplicados en la tabla Empresa cuando lo que yo estoy haciendo es insertar un sobre. Les dejo el código a ver si me pueen ayudar.

Modelo Sobre

public class Sobre
{
    public long id { get; set; }
    (Required)
    (MaxLength(100))
    public string fechaEmision { get; set; }
    (Required)
    public Empresa empresa { get; set; }
    (Required)
    (Index(IsUnique = true))
    public long numeroSobre { get; set; }
    (Required)
    public string nombreArchivo { get; set; }
    (Required)
    public bool enviadoDGI { get; set; }
    (MaxLength(100))
    public string fechaEnviadoDGI { get; set; }
    public string respuestaDGI { get; set; }
    public byte() archivo { get; set; }
}

Modelo empresa

public class Empresa
{
    public long Id { get; set; }
    (Required)
    (MaxLength(100))
    public string NombreComercial { get; set; }
    (Required)
    (MaxLength(12))
    (Index(IsUnique = true))
    public string Rut { get; set; }
    (Required)
    (MaxLength(100))
    public string RazonSocial { get; set; }
    (Required)
    (MaxLength(50))
    public string Telefono { get; set; }
    public string ResolucionIva { get; set; }
    public List<Sucursal> Sucursales { get; set; }
    public List<Sobre> sobres { get; set; }
}

Inserción

file = null;
                sobre1.archivo = file;
                datosEmpresa datosEmpresa = new datosEmpresa();
                Empresa empresa = new Empresa();
                oReply reply1 = new oReply();
                reply1 = datosEmpresa.BuscarEmpresaPorRut("2123132123131");

                empresa = (Empresa)reply1.Data;
                sobre1.empresa =empresa;
                sobre1.enviadoDGI = false;


                sobre1.fechaEmision = DateTime.Now.ToString();
                sobre1.nombreArchivo = "fefefefefgafheagfh";
                sobre1.numeroSobre = 27;
                sobre1.respuestaDGI = "mal";
                



                db.Sobres.Add(sobre1);
                db.SaveChanges();

Exception

An error occurred while updating the entries. See the inner exception for details.

InnerException = {“No se puede insertar una fila de clave duplicada en el objeto ‘dbo.Empresas’ con índice único ‘IX_Rut’. El valor de la clave duplicada es (2123132123131).rnSe terminó la instrucción.”}

Les agradezco si me pueden dar una mano ya que estoy trancado
Graciaaaaaaaasssssssss

sharepoint online – Comparing images typescript react sharpoint framework

I am having a problem trying to compare two images with each other. One image is saved locally in my project and the second picture is on the internet (url).
I tried putting the image into “variable” and compare it with the second image that would be also stored into “variable”.

let temp_img = fetch(url,{method: "GET", headers: {}}).then(response => {
     result = response;
});
let local_img = new File(path,"local_img");

if( temp_img == local_img)
....

I always get the same result that images are not identical (but they are). What am I doing wrong?

User Registration Not Working In Heroku (Python Flask Framework)

I am trying to register a user in my blogging application. It works fine in local server. But when I deployed it to Heroku, it gives me 500 status code error.

Problem: Status Code 500 while trying to register a user in Heroku.

The code are as follows:

models.py

class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key = True)
    username = db.Column(db.String(64), index = True, unique = True)
    firstname = db.Column(db.String(50))
    middlename = db.Column(db.String(50))
    lastname = db.Column(db.String(50))
    dob = db.Column(db.DateTime)
    email = db.Column(db.String(120), index = True, unique = True)
    password_hash = db.Column(db.String(128))

    def __repr__(self):
        return "<User {}>".format(self.username)

    def set_password(self, password):
        self.password_hash = generate_password_hash(password)

forms.py

class RegistrationForm(FlaskForm):
    username = StringField("Username", validators = (DataRequired(message = "Username is required.")), render_kw = {"placeholder": "Username"})
    firstname = StringField("First Name", validators = (DataRequired(message = "First Name is required.")), render_kw = {"placeholder": "First Name"})
    middlename = StringField("Middle Name", render_kw = {"placeholder": "Middle Name"})
    lastname = StringField("Last Name", validators = (DataRequired(message = "Last Name is required.")), render_kw = {"placeholder": "Last Name"})
    dob = DateField("Date Of Birth", validators = (DataRequired(message = "Date Of Birth is required.")), format = "%Y-%m-%d")
    email = StringField("Email", validators = (DataRequired(message = "Email Address is required.")), render_kw = {"placeholder": "Email Address"})
    password = PasswordField("Password", validators = (DataRequired(message = "Password is required.")), render_kw = {"placeholder": "Password"})
    confirm_password = PasswordField("Repeat Password", validators = (DataRequired(message = "Password Confirmation is required."), EqualTo("password")), render_kw = {"placeholder": "Confirm Password"})
    submit = SubmitField("Register")

    def validate_username(self, username):
        user = User.query.filter_by(username = username.data).first()
        if user is not None:
            raise ValidationError("Username Already Exists! Please Use A Different Username.")
    
    def validate_email(self, email):
        user = User.query.filter_by(email = email.data).first()
        if user is not None:
            raise ValidationError("Email Address Already Exists! Please Use A Different Email Address.")

routes.py

@app.route("/register", methods = ("GET", "POST"))
def register():

    if current_user.is_authenticated:
        return redirect(url_for("dashboard"))

    form = RegistrationForm()

    if form.validate_on_submit():
        user = User(username = form.username.data, email = form.email.data, firstname = form.firstname.data, middlename = form.middlename.data, lastname = form.lastname.data, dob = form.dob.data.strftime("%Y-%m-%d"))
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        flash("Congratulations! You are now a registered user.", "success")
        return redirect(url_for("login"))

    return render_template("register.html", title = "User Registration", form = form)

register.html

<form action="" method="POST">
    {{ form.hidden_tag() }}
    <div class="form-group">
        <input type="text" class="form-control" name="username" placeholder="Username">
        {% for error in form.username.errors %}
            <span style="color: red;">{{ error }}</span>
        {% endfor %}
    </div>
    <div class="form-group">
        <input type="text" class="form-control" name="firstname" placeholder="First Name">
        {% for error in form.firstname.errors %}
            <span style="color: red;">{{ error }}</span>
        {% endfor %}
    </div>
    <div class="form-group">
        <input type="text" class="form-control" name="middlename" placeholder="Middle Name">
        {% for error in form.middlename.errors %}
            <span style="color: red;">{{ error }}</span>
        {% endfor %}
    </div>
    <div class="form-group">
        <input type="text" class="form-control" name="lastname" placeholder="Last Name">
        {% for error in form.lastname.errors %}
            <span style="color: red;">{{ error }}</span>
        {% endfor %}
    </div>
    <div class="form-group">
        <div class="input-group">
            <label for="dob" class="col-form-label">Date Of Birth</label>&emsp;
            <input class="col-md-9 datepicker" id="dob" name="dob" type="date">
        </div>
        {% for error in form.dob.errors %}
            <span style="color: red;">{{ error }}</span>
        {% endfor %}
    </div>
    <div class="form-group">
        <input type="text" class="form-control" name="email" placeholder="Email Address">
        {% for error in form.email.errors %}
            <span style="color: red;">{{ error }}</span>
        {% endfor %}
    </div>
    <div class="form-group">
        <input type="password" class="form-control" name="password" placeholder="Password">
        {% for error in form.password.errors %}
            <span style="color: red;">{{ error }}</span>
        {% endfor %}
    </div>
    <div class="form-group">
        <input type="password" class="form-control" name="confirm_password" placeholder="Confirm Password">
        {% for error in form.confirm_password.errors %}
            <span style="color: red;">{{ error }}</span>
        {% endfor %}
    </div>
    <div class="form-group">
        {{ form.submit(class="btn btn-block btn-outline-info") }}
    </div>
</form>

Heroku Application Log

2020-06-30T14:30:31.934555+00:00 app(web.1): Message: 'Exception on /register (POST)'
2020-06-30T14:30:31.934555+00:00 app(web.1): Arguments: ()
2020-06-30T14:30:31.943840+00:00 app(web.1): 10.43.184.146 - - (30/Jun/2020:14:30:31 +0000) "POST /register HTTP/1.1" 500 4924 "https://memoryblog.herokuapp.com/register" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36"
2020-06-30T14:30:31.951860+00:00 heroku(router): at=info method=POST path="/register" host=memoryblog.herokuapp.com request_id=31cb3cc1-c089-4b54-a35f-1a43050ef91a fwd="27.140.254.125" dyno=web.1 connect=1ms service=1558ms status=500 bytes=5290 protocol=https

Can anyone help me to solve this problem?

python – Hex boardgame with fast random rollouts (OpenAI gym framework)

I implemented the boardgame Hex using the OpenAI gym framework with the aim of building a bot/AI player that can learn through self-play and expert iteration (details Note: not my paper; I am merely reproducing it).

The initial agent uses Monte-Carlo tree search (MCTS), and I will compare myself against it to evaluate the strength of different bots. MCTS involves simulating the game with random moves (called a rollout) and this is done A LOT (>1,000 games played per move in the actual game), so this rollout speed matters to me. Indeed, when I profile my code, the bottleneck is said rollout, and, more specifically, the test if the game has ended.

Currently, I check if the game is finished using the following mechanism (I’m sure there is a name for it, but I don’t know it):

  1. Pad the board with 1 extra row/column and place stones on the west/east side (player white/blue) or north/south side (player black/red) (cached at the start of the game)
  2. Find all the connected regions for the current player (cached from previous turn)
  3. Place stone on board
  4. check neighborhood of stone and (a) start new region if unconnected, (b) add to the region with lowest region index
  5. if multiple regions are in the neighborhood, merge them with the region that has the lowest index

I assign index 1 to the stones in the north/west (black/white) padding, and can then efficiently test if the game is over by checking the south-east corner. If it has region index 1, it is connected to the opposite side and the game has finished.

The full code of the game is available on GitHub together with a MWE that performs a random rollout. It’s not a big repo (maybe 500 lines). The critical function is this one

    def flood_fill(self, position):
        regions = self.regions(self.active_player)

        current_position = (position(0) + 1, position(1) + 1)
        low_x = current_position(1) - 1
        high_x = current_position(1) + 2
        low_y = current_position(0) - 1
        high_y = current_position(0) + 2
        neighbourhood = regions(low_y:high_y, low_x:high_x).copy()
        neighbourhood(0, 0) = 0
        neighbourhood(2, 2) = 0
        adjacent_regions = sorted(set(neighbourhood.flatten().tolist()))
        adjacent_regions.pop(0)

        if len(adjacent_regions) == 0:
            regions(tuple(current_position)) = self.region_counter(self.active_player)
            self.region_counter(self.active_player) += 1
        else:
            new_region_label = adjacent_regions.pop(0)
            regions(tuple(current_position)) = new_region_label
            for label in adjacent_regions:
                regions(regions == label) = new_region_label

with the most expensive line being adjacent_regions = sorted(set(neighbourhood.flatten().tolist())). I’m wondering if this can be implemented in a nicer way, either by using a different algorithm or vectorizing the code more, more intelligent caching, …

Of course, I’m also happy with any other comment on the code.

Disclaimer: I found a basic hex implementation in an old commit in the OpenAI gym repo, which I used as a base to work off. Most of the code has changed, but some of it (e.g., the render function) I did not write myself.

c# – Encrypting Data with interception of SQL instructions generated by Entity Framework

WPF Application, C#, MS SQL Server, Entity Framework 6. I need to encrypt all data from user input, and do it apart from business logic. I’ve come to interception of SQL Queries generated by transferring LINQ expressions to SQL, and changing data from them to encrypted, in order to store only encrypted data. I’d like to know if it even possible, and how… And how to decrypt them back and show user only plaintext. I can’t change this method – i.e. i MUST intercept queries. Yet another thing – i must use methods from System.Security.Cryptography.
I have read https://docs.microsoft.com/en-us/ef/ef6/fundamentals/logging-and-interception this article – we use EF version of 4.1, this will not work. I had even checked through source code of EF6 on Github to check if i can override SaveChanges() method

dnd 5e – How can I fit infiltration-style encounters or quests into the combat framework of D&D 5e?

So, most answers here already cover the general ideas, but I will go over them as well.

The idea of the adventuring day as stated is to try and fairly balance the different classes, some which depend on short rests, some which depend on long rests. As noted in this question, changing the adventuring day to a shorter version, which is what you are planning to do, changes the balance of the game in favor of classes with bursty, recover-on-long-rest resources. A Wizard now may use all of its spells against the enemies in the first two encounters, because these are all the encounters.

If you try to balance that, for example, by making the encounters significantly stronger, that will make the encounter problematic for classes that don’t have that many resources to begin with, because they are supposed to recover them at their short rest.

This creates a huge imbalance within the classes, making some classes greatly stronger than others, which is usually perceived as a problem.

I do not know any way of solving this issue in a general setting. If you remove short rests, you are making classes that depend on short rests weaker, just like if you put a giant anti-magic field in the campaign you make classes that depend on magic weaker.

However, in your case, the lack of short rests is not due to an actually shorter adventuring day, rather due to the (lack of) plausibility of taking a rest after the enemies have been warned.

In that case, instead of depleting the resources through combat (i.e., enemies that actually see the PCs and would call for other enemies), you can slowly take away their resources while not making them perceived by the enemy forces yet, thus, allowing for a short rest.

So, this is the first general advice:

Deplete their resources and Do allow Short Rests

In this sense, SeriousBri’s answer is probably better than what I can advice you, but note that it is generally hard to take away resources such as Action Surges, Spell Slots and others with traps and other non-combat stuff. The only way I found that worked in my groups was through puzzles that required some specific resource to be spent. I have used a “Damage check door” which required the characters to deal some target amount of damage in a single round in order to open it (forcing them to spend resources as it was virtually impossible to deal that amount of damage without spending some stuff), runes that would only activate if someone cast a Fireball on them, and other ways to consume resources (that I obviously knew they had because I designed them after knowing what the party was :P).

In your case, it is quite hard to do thematically, since they are invading an enemy fortress, and having that fortress to have something “tailored” for the characters to overcome sounds awkward. But maybe one of the main enemies is a beast shapeshifter, and he has a locked vault that can only be opened by… a Bear! – essentially forcing your Druid to spend one of his transformations on it. This idea is a little far fetched and the example is quite silly, I admit, but I hope it is good enough for you to see the idea – and I am sure you are able to think on something along these lines that makes sense in your setting and that your players will appreciate (personally I would love to be the Druid and have a challenge that has to be overcome by me transforming in some animal).

Very important note: If you follow this idea, make sure you give enough clues for your characters so they understand what must be done and not waste more resources than you expected. In the Fireball example, it would be quite bad if they first tried Burning Hands, Scorching Ray and Chromatic Orb – Fire before actually trying a Fireball – that would lead to way more resources spent than I planned and would make the following encounters nearly impossible.

The thing is: Your party consists of two rogues and a moon druid. Rogues are, in fact, remarkable for being almost a resourceless class. The only resource they care about is HP, essentially. They do not get spell slots (not the Thief or the Assassin at least), extra consumable dice, or any kind of feature recovered on-reset. That makes it considerably easier for you to balance out.

The Druid, as well, only has one relevant short rest resource: their beast transformations. With a one-hour-long transformation, that should not be a problem in terms of resource, either, and most likely they are going to be transformed for most of the combats at this level in any adventure.

So, from my point of view, the only resource you should worry about is their HP. This is the easiest resource to take a little bit away.

Make it a little bit harder

Unless your enemies already deal high damage, you can slightly increase the damage of the enemies – not enough to make it a whole CR higher, but enough to be noticeable in that they may leave the two-encounters-in-a-row in a very bad shape, maybe even dropping one of the Rogues’ HP to zero (make no mistake: he should not die).

Alternatively, you can set traps – traps that deal damage are, well, the easiest and most common ones, compared to traps that force a spell slot to be spent – so they arrive at the encounters missing a few HP.

As a final alternative, I have found out that giving surprise to the enemies is a huge advantage for them and will make the combats considerably harder, without effectively increasing any damage dice, modifier or HP of the monsters/NPCs. Instead of rushing towards your party when they notice the invasion, they may handle it a little bit better and wait for a moment where they will have the upper hand. The guards will not immediately ask for help, though, as they want the glory of defeating the invaders for themselves, and will only ask for help when they notice the invaders are stronger than they initially thought. (Surely surprising your party is not that easy, but it is a possibility for balancing it).

Give them ways of recovering resources and make them go through a “normal” adventuring day

What is more interesting about the particular party setup you have is that you can give them ways of recovering their most important resource – HP – that are not short rests. Give the Druid a Cure Wounds scroll. Give them a few Potions of Healing. Then you can actually make them go through a few more encounters, and almost look like a “normal” adventuring day, but without short rests between the encounters. Give them enough potions and 1 minute to actually drink them and your party can even go through 4-6 encounters in a row, which is something most parties would have a problem even if they had a significant number of potions, because they have other important resources, like Ki Points or Action Surges or Warlock Spell Slots.

Ultimately, if, due to the nature of your party (two rogues and a druid), they can effectively invade in a very stealthy way and go through only one encounter, for example, these extra resources (potions and scrolls) you gave them become a reward for handling the challenge in a more efficient way, otherwise, they just spent what they were supposed to spend and no harms done.

planning – What’s a good framework for a hackathon-style game development session?

I have a couple of buddies (3-4) that like programming. We thought it’d be fun to get together for a weekend and see what we can cobble together in that time. None of us have much experience with game development, but most of us study CS or something related to it.

What would be a good framework (or whatever it’s called) to quickly build something in a weekend? It doesn’t need to be fancy at all, but should preferably still involve mostly programming. Most of us have worked with a bunch of different languages, so we don’t have much of a preference in that regard.

development process – How to choose the proper backend framework for my webapp

As said in the title I’m searching an help choosing the best framework for my webapp.

My application is an editor that helps user “editing” a 20-30MB multidimensional array.

It is easy to do that, the problem is everytime the user do a single edit the array must be synced with the server without sending 20MB of json text each time.

For example:

I developed something in past using blazor and the result was really “MEH”. So, I decided to start from scratch, choose a good framework and learn all I should learn.

So, here we come to the final question. There are a lot of frameworks and I really don’t know where to start, what to choose. As a newbie I’m totally lost and I don’t want to waste time learning something that doesn’t really fit for my project.