syntax – Powershell : Update Registry value for RDPFileContent by making change in server port to XXX from XXX

Requirement: to update registry value i.e. server port for one of the property : RDPFileContent using powershell.

Attempt Taken: Tried fetching entire value first of RDPFileContent using get-childitem method and redirected the content to text file and replaced only server port value using replace parameter. But, while setting it back using set-item property, we are not able to set back in proper format by extracting it from updated text file.

Please help us here .

Thanks in advance,

Best way of making an internal Python-based REST microservice

I have a small academic project that I use in my research. It consists out of a few databases and multiple computational microservices which should access the DBs. It all runs within separate containers.

I want to make another container with a REST python service that’s used by a few other microservices within this project. The purpose of it is fairly simple. It’s a collection of SQL queries and data transformation logic, which I simply want to have within the same place. Maybe have a few instances of this service for scalability in the University’s cluster.

No authentication for this specific microservice is required as it’s always going to be within a secure network. Other microservices (containers) will act as public interfaces for the computational experiments I run.

Currently, I made a prototype of this microservice with Flask + gunicorn. But somehow I’m not sure if this would the optimal solution for such a task. Is this combination actually suitable for production?

I also looked into Django but it seems to be rather heavyweightght for a purpose of making a REST service. Or am I wrong here?

Are there any other alternatives but Flask and Django? Or maybe there’s a better way of using Flask, rather than just making a few threads of the service with gunicorn?

Making unique NID-based identifiers for titles using Bootstrap collapse fields in Drupal 8 Views

I created a view where I’m displaying only one content type, with four titles from content pages, one subtitle, and the content ID (nid) included in the fields for my view. I hid all these fields, and now I’m trying to create a Bootstrap collapse layout in the custom text field.

What is the best way that I can make each title show based on the NID of each content page? Basically, I need the user to be able to click each title, and make something unique show up in each of the 4 titles… For instance, the subtitle field only shows up underneath one particular content title. But so far, when I click ANY title, the subtitle field shows up (it shows up underneath the title that I want it too, but I definitely don’t want it to show up when I click an unrelated title).

I tried creating unique identifiers, as you can see below, but no dice. Any advice is greatly appreciated!

   <p>
     <a class="btn btn-link" data-toggle="collapse" data-target="#collapse-NID" href="#collapse-NID" role="button" aria-expanded="false" aria-controls="collapse-NID">
    {{ title }}
  </a>
</p>
<div class="collapse-NID" id="collapse-NID">
  <div class="card card-body">
     {{ field_file }}
  </div>
</div>


<p>
  <a class="btn btn-link" data-toggle="collapse" data-target="#collapse1-NID" href="#collapse1-NID" role="button" aria-expanded="false" aria-controls="collapse1-NID">
    {{ title }}
  </a>
</p>
<div class="collapse1-NID" id="collapse1-NID">
  <div class="card card-body">
    {{ field_file }}
    {{ field_subtitle }}
    {{ field_file }}
  </div>
</div>

dnd 5e – Advise of Making a lvl 20 multiclass character that targets the mind for 5e

I will be making a level 20 character for a one shot that will have alot of roleplay and combat. I want to be a bard plus something else. Either a lore or whisper bard and then either an Aberrant Mind Sorcerer or a Great Old One Warlock. I want to have at least 17 lvls of bard so at a key moment I can use true polymorph and turn into an aboleth. With all that in Mind, pun intended, what is the most optimized combo of 17 lvls of bard (lore or whisper) and 3 lvls of Aberrant Mind Sorcerer or a Great Old One Warlock?

Thank you in Advance.

text based – How do I fix the indentation error in this python game I’m making?

I am making a little game where you enter a boolean and the computer learns which Boolean it is:

import math
import random
endgame = False
global percentavg
global percentavgnum
percentavg = 0
percentavgnum = 0
def oneround():
    Q1max = 1
    Q1min = -2
    guess = False
    answer = 0
    while guess == False:
        useranswer = input("True or False?")
        if useranswer == "True" or useranswer == "true":
            answer = True
            guess = True
        elif useranswer == "False" or useranswer == "false":
            answer = False
            guess = True
        
    corrects = 0
    incorrects = 0 
    howmanytimes = int(input("how many times do you want the computer to guess? (If you want to end the game, type in letters instead of a number.) "))
    for x in range(0,howmanytimes):
        choice = random.randint(Q1min,Q1max)
        if choice >= 0:
            guess = True
        else:
            guess = False
        if guess == answer:
            corrects += 1
            if guess == True:
                Q1max += 1
            else:
                Q1min -= 1
        else:
            incorrects += 1
            if guess == False:
                Q1max += 1
            else:
                Q1min -= 1
    percent = (corrects/howmanytimes)*100
    percentavg += percent
    percentavgnum += 1
    print ("The computer learned to guess correctly",(str(math.floor(percent))+"%"),"of the time.")
while endgame == False:
    try:
        oneround()
    except ValueError:
        endgame = True
print ("The computer guessed correctly",(str(math.floor(percentavg/percentavgnum))+"%"),"of the time")

But I keep getting this error:

Traceback (most recent call last):
  File "main.py", line 49, in <module>
    oneround()
  File "main.py", line 44, in oneround
    percentavg += percent
UnboundLocalError: local variable 'percentavg' referenced before assignment

Does anyone know What I am doing wrong?

Making the controller clean and readable in (Ruby on Rails)

I have this rails controller which works fine but a lot of business logic is confined in the controller which I believe is not a good practice.

class MoviesController < ApplicationController
  before_action :set_movie, only: ( :edit, :update, :destroy )
  rescue_from ActiveRecord::RecordNotFound, with: :render_404


  def index
    year = params(:year).split('-') unless params(:year).nil?
    starting_year = year(0) unless year.nil? || year.empty?
    ending_year = year(year.length - 1) unless year.nil? || year.empty?
    genre = params(:genre)(0) unless params(:genre).nil?
    language = params(:language)(0) unless params(:language).nil?
    quality = params(:quality)(0) unless params(:quality).nil?
    rating = params(:rating_bound)(0) unless params(:rating_bound).nil?
    order_by = params(:orders_filter)(0) unless params(:orders_filter).nil?
    @movies = Movie.search_title(params(:title)).search_language(language).search_on_starting_year(starting_year).search_on_ending_year(ending_year).search_video_quality(quality).search_genre(
      genre
    ).search_rating(rating).order_on_filter(order_by).includes(:profile_photo)
  end


  def show
    @movie = Movie.includes(
      :profile_photo, :created_by, movie_roles: (:actor), feedback: (:user) 
    ).left_outer_joins(:likes, :ratings).select(
      'movies.*, CAST(AVG(ratings.value) AS DECIMAL(10,1)) AS rating, count(likes.likeable_id) * 6 as total_likes'
    ).find params(:id)
    @reviews = @movie.feedback.select { |item| item.type == 'Review' }
    @comments = @movie.feedback.select { |item| item.type == 'Comment' }
    @directors = @movie.movie_roles.select { |role| role.role_played == 'director' }
    @actors = @movie.movie_roles.select { |role| role.role_played == 'actor' }
  end

 
  def new
    @movie = Movie.new
    @movie.build_profile_photo
  end


  def edit
  end

  def render_404
    render file: "#{Rails.root}/public/404", status: :not_found
  end

  # POST /movies
  # POST /movies.json
  def create
    parameters = movie_params
    @movie = Movie.new(parameters) 
    @movie.created_by = current_user

    if @movie.save
      redirect_to @movie, notice: 'Movie was successfully created.'
    else
      render :new, notice: 'Not Saved!'
    end
 end


  def update
    respond_to do |format|
      if @movie.update(movie_params)
        format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }
        format.json { render :show, status: :ok, location: @movie }
      else
        format.html { render :edit }
        format.json { render json: @movie.errors, status: :unprocessable_entity }
      end
    end
  end


  def destroy
    @movie.destroy
    respond_to do |format|
      format.html { redirect_to movies_url, notice: 'Movie was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
  # Use callbacks to share common setup or constraints between actions.
  def set_movie
    @movie = Movie.find(params(:id))
  end

  # Only allow a list of trusted parameters through.
  def movie_params
    params.fetch(:movie, {}).permit(:name, :release_date, :video_quality, :synopsis, :genres, :language)
    params.fetch(:movie, {}).permit(:name, :release_date, :video_quality, :synopsis, :genres, :language, profile_photo_attributes: (:path))     
  end
end

I need to shrink the controller size and make the code look much clear and readable!

unity – My shader is making objects black constantly

I am procedurally generating a world. I want to apply a shader to each mesh, before i try textures i’m attempting to get it to work with colours.

So i have a struct which stores data about a type of terrain, including a list of colours (This struct is sytem.Serializable) & a material which has my shader attached to it.

I then have a monobehaviour which has 4 of these structs as public so the user can edit them. I have a public static class which contains 4 static versions of this struct and in the OnValidate function of my monobehaviour i set my static versions of the terrain data to equal the values on the monobehaviour.

So i now should have 4 static structs each with their own array of colours and material which is using my custom shader. I then do the following code directly after instantiating the mesh:

 protected void SetMeshMaterial()
 {
        //m_TerrainData is set to the values of one of the 4 static structs in the constructor of this class
        m_TerrainData.UpdateMaterial();

        m_Obj.GetComponent<MeshRenderer>().sharedMaterial = m_TerrainData.terrainMaterial;
 }

Update Material:

public void UpdateMaterial()
{
    Color() cols = regions.Select(r => r.colour).ToArray();
    float() heights = regions.Select(r => r.heightValue).ToArray();
    float minHeight = heightCurve.Evaluate(0);
    float maxHeight = heightCurve.Evaluate(1);

    terrainMaterial.SetInt("_NumOfColours", regions.Count);
    terrainMaterial.SetColorArray("_Colours", cols);
    terrainMaterial.SetFloatArray("_Heights", heights);
    terrainMaterial.SetFloat("_MinHeight", minHeight);
    terrainMaterial.SetFloat("_MaxHeight", maxHeight);
}

and my shader (Note this shader is just a placeholder I am using to get colours to display at the moment, it is not the final code):

Shader "Custom/ColourShader"
{
    Properties
    {
        _Scale("Texture Scale",float) = 1
        _TriplanarBlendSharpness("Blend Sharpness",float) = 1
    }
    SubShader
    {
        Tags { "RenderType" = "Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Standard fullforwardshadows
        #pragma target 3.0

        const static int maxNumOfColours = 8;

        //Variables that must be set in material inspector
        float _Scale;
        float _TriplanarBlendSharpness;

        // Variables that must be set programatically
        int _NumOfColours;
        float3 _Colours(maxNumOfColours);
        float _Heights(maxNumOfColours);
        float _MinHeight;
        float _MaxHeight;


        struct Input
        {
            float3 worldPos;
            float3 worldNormal;
        };

        float InverseLerp(float a, float b, float t)
        {
            return (t - a) / (b - a);
        }



        void surf(Input IN, inout SurfaceOutputStandard o)
        {
            
            float height = InverseLerp(_MinHeight, _MaxHeight, IN.worldPos.y); //Get height between 1 & 0 
            
            
            if (height > 0 && height <= 0.25)
            {
                o.Albedo = _Colours(0);
            }
            else if (height > 0.25 && height <= 0.5)
            {
                o.Albedo = _Colours(1);
            }
            else if (height > 0.5 && height <= 0.75)
            {
                o.Albedo = _Colours(2);
            }
            else
            {
                o.Albedo = _Colours(3);
            }
        }

        ENDCG
    }
    FallBack "Diffuse"
}

None of the colours have a default value of black. Shaders really aren’t my strong point so i have no clue what is going wrong here.

EDIT: changed title to better reflect problem

MacBook Air making a weird noise

I have a MacBook Air and recently it’s been making a cracking noise , it mostly happens when I flip my laptop or when I tilt it , it’s not my speakers and it doesn’t sound like a loose screw.

architecture – Utility AI system making decisions on targeting and more

So I am making my own Utility AI system based on the Dave Mark Infinite Axis Utility System:

However, some questions during my development come up:

First, let me introduce you to my basic structure:

Actions

All actions have a list of potential considerations

    public abstract class BaseAction : ScriptableObject {
    public List<BaseConsideration> InputAxises;
    public EnumActionState ActionState;
    public abstract void Act(BaseAiContext ctx);
    public abstract float GetScore(BaseAiContext ctx);
    public abstract void Update(BaseAiContext cts);
    public abstract bool IsDone(BaseAiContext ctx);
}

Then it has a state that tells me when an action is done.

Then I have a simple AIContext that has a list of potential actions my Agent can take. it then scores all actions and then selects the highest scored

Decisions

    public abstract class BaseConsideration : ScriptableObject, IConsideration
{
    (SerializeField)
    public EnumEvaluator EvaluatorType;
    public string NameId { get; }
    public float Weight { get; set; }
    public bool IsInverted { get; set; }
    public string DataKey { get; set; }

    public float Xa;
    public float Xb;
    public float Ya;
    public float Yb;
    public float K;
    
    public abstract float Consider(BaseAiContext context);
    public abstract float Consider(float x);

}

ofc the consider function uses an evaluator (Linear, sigmoid etc) to find the best match.

Now, this is where things begin to get a little bit fuzzy for me.

let’s say that I have a melee guy who has an action “Attack Enemy” then I have a sensor that tells the Context which targets he has available then I make the following structure:

(Action) Melee Attack

  • (Decision) is there a target within melee distance

Then back in my action, I choose the closest target. and attack it

Is this how it is supposed to be? or should considerations be able to select targets for the AI context? Have I done something wrong in my architecture or?

Update boiled down

I think the main problem i have is what defines an action and how deep do they go?

Here are two examples of an actions:

  • Select a target
  • Melee Attack

The first (Select a target) would be to select from a list and then complete

While the second might do the following steps:

  1. Select a target
  2. Go to target if far away
  3. Attack with a sword

Also, what is the job of the consideration should the consideration be able to set values of the AI Context or should it only return a score based on the Graph model?

Android Chrome browser is making a duplicate of every photo downloaded to my external SD card

Every time I download a photo (.jpg, .gif or .png file) with the Chrome browser (stable version) to my external SD card, it gets duplicated and stored also in “/storage/emulated/0/Pictures” folder (internal storage). The duplicate always has different file name. How can I disable this and why is this happening ?

This doesn’t happen when I download a photo with Opera Mini or MS Edge browser to my SD card for example. It only happens to pictures downloaded with Google Chrome when the download location is set to “SD card”.

My SD card is formated as portable storage on my HTC 10 (Android Oreo).