Currently I have this 4 bit CPU as shown in the schematic diagram below.

What I wish to achieve:

• Add one more output register to make the CPU output a total of 8 bits
• Show alphabet using the 8 bits output

My current trial:

• Cout of the first IC connected to Cin of the second IC
• Cascaded in a synchronous fashion

What I unsure/don’t understand:

• Should I connect the A~D pins of the second register to ALU?
• The LOAD-bar pin is connected to LO-bar of the ALU. Should I add one more LO-bar to the ALU and connect it to the LOAD-bar of the second register?

How do I correctly set up an “If” statement?

I have the following list of variables:

z=1; a={{A,B,C,D},{A,A,E,W},{B,B,B,B},{S,R,B,T,D},{M,M,M,M}} 

What I’m trying to do is set up a statement that reads something like:

If position[1], position[2], position[3], and position[4] are all the same variable, print “Quadruplet”, if it’s not true, print “False”

I want to do that for each list within the construct of list “a”. I have tried the following code, but am struggling to understand where I’m going wrong.

Table[  If[   (a[[z, l]][[1]] == a[[z, l]][[2]] == a[[z, l]][[2]] ==      a[[z, l]][[3]] == a[[z, l]][[4]]),   Print["Quadruplet"],   Print["False"]   ], {l, 1, Length[a]}] 

I’m not sure I’m using the syntax of part correctly. For example I thought that [a[z,l]][[1]] would read as: “In list “a” for position [1] of each “sublist”….” but it doesn’t work as I intended it to.

Accent marks/symbols not displaying correctly in MySQL database

Anytime there’s an accent mark (é or ‘) or symbol (&) in my database it displays as HTML code. The table CHARACTER SET is UTF-8 Unicode and the COLLATION is utf8mb4_general_ci, which should display those characters correctly. Any ideas why this is happening?

(MySQL version 5.7)

Current data

company| firstname| lastname ---------------------------------- A&amp;T  | Patrick    | O&#039;Brien 

Expected

company| firstname| lastname ---------------------------------- A&T      | Patrick    | O'Brien 

Text Rendering using FreeType library not working correctly

Currently I am implementing text rendering into my game engine using the FreeType library by following the tutorial found here: https://learnopengl.com/In-Practice/2D-Game/Render-text. My current implementation is not working correctly, you can see the result of my implementation in the following Images (note that I am rendering the text “Test test”, and you can see 8 distinct cubic shapes one for each letter with a space in between the words, with the last 4 cubic shapes being smaller and shaped differently compared to the capitalized version of the word, so it looks like it is at least close to rendering the string “Test test”):

Firstly, there are some obvious issues, to start with you can see the “text” is drawn in a projection perspective rather than orthographic, this is on purpose however because my system already draws with projection perspective and if the text was stuck flat to my screen in a 2D manner I fail to see how the perspective it is drawn in would change anything.

That leads to the next problem, the “text” is not stuck to my screen in a 2D manner (like HUD elements in a game), it appears to be floating in 3D space, although if I look at the “Text” from exactly side on it will vanish, so it does not appear to have any depth (z axis), only a position on the x and y axis. Also if I go past the side on point and look from behind the “text” vanishes.

And finally the most obvious issue, the glyphs clearly are not rendered correctly, as you cant see the actual shape of the letters, instead just the cubic space containing the letter.

My implementation is as follows: (disclaimer: My engine is to big to explain every little thing that is going on so this question is showing minimal code and only relevant code to this issue, described in quite a high level manner)

In my engine the scene is created using a scene graph of GameObject‘s each with GameComponent‘s, therefore I create a TextRendererObject and add to it a TextRenderer component and add it to the scene in the following code:

Entity *textRendererObject = new Entity(...); TextRenderer  *Text; Text = new TextRenderer(50, 50); Text->Load("font/arial.ttf", 240); textRendererObject->AddComponent(Text); AddToScene(textRendererObject); 

The TextRenderer constructor, a struct that the .h file defines (used in load function) and the load function are as follows respectively:

TextRenderer::TextRenderer(GLuint width, GLuint height) :     TextShader("text")//creates text shader (text.glsl) {    GLuint VAO, VBO;      SetIsTextRenderer(true);      glGenVertexArrays(1, &this->VAO);     glGenBuffers(1, &this->VBO);     glBindVertexArray(this->VAO);     glBindBuffer(GL_ARRAY_BUFFER, this->VBO);     glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 6 * 4, NULL, GL_DYNAMIC_DRAW);     glEnableVertexAttribArray(0);     glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), 0);     glBindBuffer(GL_ARRAY_BUFFER, 0);     glBindVertexArray(0); } 
/// Holds all state information relevant to a character as loaded using FreeType struct Character {     GLuint TextureID;   // ID handle of the glyph texture     glm::ivec2 Size;    // Size of glyph     glm::ivec2 Bearing; // Offset from baseline to left/top of glyph     GLuint Advance;     // Horizontal offset to advance to next glyph }; //... std::map<GLchar, Character> Characters; 
void TextRenderer::Load(std::string font, GLuint fontSize) {     // First clear the previously loaded Characters     this->Characters.clear();     // Then initialize and load the FreeType library     FT_Library ft;     if (FT_Init_FreeType(&ft)) // All functions return a value different than 0 whenever an error occurred         printf("ERROR::FREETYPE: Could not init FreeType Library");//std::cout << "ERROR::FREETYPE: Could not init FreeType Library" << std::endl;     // Load font as face     FT_Face face;     if (FT_New_Face(ft, font.c_str(), 0, &face))         printf("ERROR::FREETYPE: Failed to load font");//std::cout << "ERROR::FREETYPE: Failed to load font" << std::endl;     // Set size to load glyphs as     FT_Set_Pixel_Sizes(face, 0, fontSize);     // Disable byte-alignment restriction     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);     // Then for the first 128 ASCII characters, pre-load/compile their characters and store them     for (GLubyte c = 0; c < 128; c++)       {         // Load character glyph          if (FT_Load_Char(face, c, FT_LOAD_RENDER))         {             printf("ERROR::FREETYTPE: Failed to load Glyph");//std::cout << "ERROR::FREETYTPE: Failed to load Glyph" << std::endl;             continue;         }         // Generate texture         GLuint texture;         glGenTextures(1, &texture);         glBindTexture(GL_TEXTURE_2D, texture);         glTexImage2D(             GL_TEXTURE_2D,             0,             GL_RED,             face->glyph->bitmap.width,             face->glyph->bitmap.rows,             0,             GL_RED,             GL_UNSIGNED_BYTE,             face->glyph->bitmap.buffer         );         // Set texture options         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);          // Now store character for later use         Character character = {             texture,             glm::ivec2(face->glyph->bitmap.width, face->glyph->bitmap.rows),             glm::ivec2(face->glyph->bitmap_left, face->glyph->bitmap_top),             face->glyph->advance.x         };         Characters.insert(std::pair<GLchar, Character>(c, character));     }     glBindTexture(GL_TEXTURE_2D, 0);     // Destroy FreeType once we're finished     FT_Done_Face(face);     FT_Done_FreeType(ft); } 

The shader (text.glsl) that is created when the Textrenderer object is created is as follows:

#include "common.glh"  varying vec2 texCoord0; varying vec3 worldPos0;  #if defined(VS_BUILD) attribute vec3 position; attribute vec2 texCoord;  uniform mat4 T_model; uniform mat4 T_MVP;  void main() {     gl_Position = T_MVP * vec4(position.xy, 0.0, 1.0);     texCoord0 = texCoord;     worldPos0 = (T_model * vec4(position.xy, 0.0, 1.0)).xyz; }   #elif defined(FS_BUILD)  uniform sampler2D H_text; uniform vec3 H_textColor;  DeclareFragOutput(0, vec4); void main() {         vec4 sampled = vec4(1.0, 1.0, 1.0, texture2D(H_text, texCoord0).r);     vec4 color = vec4(H_textColor, 1.0) * sampled;     SetFragOutput(0, sampled * color); }   #endif 

Following this set-up of the textRenderObject game object, its Text game component and the text.glsl shader, every frame the following render function is called:

void TextRenderer::RenderTextRenderer(...) {     this->TextShader.Bind();//"text.glsl" created earlier     this->TextShader.UpdateUniformsTextRenderer(...);     RenderText("TEST test", 100, 100, 1);//responsible for drawing  } 

UpdateUniformsTextRenderer(...) is responsible for setting the values of the uniforms in text.glsl and is as follows:

void Shader::UpdateUniformsTextRenderer(Transform* transform, const RenderingEngine& renderingEngine, const Camera& camera) {     Matrix4f worldMatrix = transform->GetTransformation();     Matrix4f projectedMatrix = camera.GetViewProjection() * worldMatrix;     for (unsigned int i = 0; i < m_shaderData->GetUniformNames().size(); i++)     {         std::string uniformName = m_shaderData->GetUniformNames()[i];         std::string uniformType = m_shaderData->GetUniformTypes()[i];           if (uniformName.substr(0, 2) == "T_")         {             if (uniformName == "T_MVP")                 SetUniformMatrix4f(uniformName, projectedMatrix);             else if (uniformName == "T_model")                 SetUniformMatrix4f(uniformName, worldMatrix);             else                 throw "Invalid Transform Uniform: " + uniformName;         }         else if (uniformName.substr(0, 2) == "H_") {             if (uniformName == "H_text") {//Texture used to draw text                 int samplerSlot = renderingEngine.GetSamplerSlot(uniformName);                 SetUniformi(uniformName, samplerSlot);             }             else if (uniformName == "H_textColor")                 SetUniformVector3f(uniformName, Vector3f(1, 0, 0));//red         }     } } 

And finally the function RenderText that actually draws the text is as follows:

void TextRenderer::RenderText(std::string text, GLfloat x, GLfloat y, GLfloat scale) {     glActiveTexture(GL_TEXTURE0);     glBindVertexArray(this->VAO);      // Iterate through all characters     std::string::const_iterator c;     for (c = text.begin(); c != text.end(); c++)     {         Character ch = Characters[*c];          GLfloat xpos = x + ch.Bearing.x * scale;         GLfloat ypos = y + (this->Characters['H'].Bearing.y - ch.Bearing.y) * scale;          GLfloat w = ch.Size.x * scale;         GLfloat h = ch.Size.y * scale;         // Update VBO for each character         GLfloat vertices[6][4] = {             { xpos,     ypos + h,   0.0, 1.0 },             { xpos + w, ypos,       1.0, 0.0 },             { xpos,     ypos,       0.0, 0.0 },              { xpos,     ypos + h,   0.0, 1.0 },             { xpos + w, ypos + h,   1.0, 1.0 },             { xpos + w, ypos,       1.0, 0.0 }         };         // Render glyph texture over quad         glBindTexture(GL_TEXTURE_2D, ch.TextureID);         // Update content of VBO memory         glBindBuffer(GL_ARRAY_BUFFER, this->VBO);         glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices); // Be sure to use glBufferSubData and not glBufferData          glBindBuffer(GL_ARRAY_BUFFER, 0);         // Render quad         glDrawArrays(GL_TRIANGLES, 0, 6);         // Now advance cursors for next glyph         x += (ch.Advance >> 6) * scale; // Bitshift by 6 to get value in pixels (1/64th times 2^6 = 64)     }     glBindVertexArray(0);     glBindTexture(GL_TEXTURE_2D, 0); } 

And that’s my implementation, can anyone see where I have gone wrong? Any feedback is much appreciated.

How to correctly interpret index usages from EXPLAIN of mysql?

I’ve exported the results of an EXPLAIN run on a query. What I find confusing is that there’s the key column listing out one of the indexes from the list of possible_keys(not shown in picture) however only the top row makes mention of Using index explicitely in the Extra column.

1. What does this mean in the 2nd row, is it not using the index listed in the key column?
2. How should I interpret what the contents of the key column is about and how it is used?
enter code here

a. Should I interpret this as that index is used in the where stage of this query?

Why cron jobs didn’t be set correctly by Ansible playbook?

I created this playbook to set crontab:

- name: Set PATH to crontab   cron:     name: PATH     env: yes     user: barman     job: /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/var/lib/barman/.local/bin:/var/lib/barman/bin:/usr/pgsql-10/bin/  - name: Automatically run backup for App1   cron:     name: "Run Backup for App1"     minute: "0"     hour: "3"     user: barman     job: "barman cron && barman backup app1"  - name: Automatically run backup for App2   cron:     name: "Run Backup for App2"     minute: "0"     hour: "4"     user: barman     job: "barman cron && barman backup app2" 

But I only found this under /etc/cron.d/barman file:

# m h  dom mon dow   user     command   * *    *   *   *   barman   [ -x /usr/bin/barman ] && /usr/bin/barman -q cron 

It seems didn’t set task correctly.

Am I correctly understanding how the Smite spells work?

As I understand the smite spells (searing smite, for example), they are pretty bad (at least at level 1-2).

You have to use your action to cast them (so no attack this turn if you are not a warrior), keep your concentration until your next turn, and wait until you touch an enemy with your attack roll to deal a not really good amount of damage (but ok, sometimes it has another effect). And then you don’t have the smite any more.

So for me it’s a “true strike but you have more than 1 round to use it, and sometimes it’s just slightly better than that” level of power (which is pretty bad).

Am I correctly understanding how the smite spells work? Or did I miss something?

How do I correctly use %p and %f in postgresql.conf to make the Write Ahead Log?

I am attempting to modify postgresql.conf (Postgre SQL 10.0 under Ubuntu 18.04 VPS) to setup the Write Ahead Log (WAL).

AIUI, the commands should be:

wal_level = replica             # minimal, replica, or logical archive_mode = on               # enables archiving; off, on, or always                                 # (change requires restart) archive_command = 'cp %p /var/lib/postgresql/10/main/pg_wal/%f'           archive_timeout = 600           # force a logfile segment switch after this                                 # number of seconds; 0 disables 

AIUI, %p references the database file (to be archived) and %f references the filename that will contain the copy of said database file.

In this case: I am saying to copy every 5 minutes the database file to the /pg_wal directory.

However, this is clearly not correct as the error log files shows:

cp: 'pg_wal/000000010000000000000002' and '/var/lib/postgresql/10/main/pg_wal/000000010000000000000002' are the same file 2020-02-16 21:01:05.857 UTC [20707] LOG:  archive command failed with exit code 1 2020-02-16 21:01:05.857 UTC [20707] DETAIL:  The failed archive command was: cp pg_wal/000000010000000000000002 /var/lib/postgresql/10/main/pg_wal/000000010000000000000002 

So I am not sure how %p and/or %f are supposed to be used. If someone could present the syntax, I would be most grateful.

Why does this latex code not display correctly in text cells

When I copy this latex code to a text cell of MMA, the typesetting is not correct. There are many line breaks in the result:

$$\begin{array}{*{20}{l}} {-1 < x < 1}\ {\mathop{{ \left( {1+x} \right) }}\nolimits^{{m}}=1+mx+\frac{{m{ \left( {m-1} \right) }}}{{2!}}\mathop{{x}}\nolimits^{{2}}+ \cdots +\frac{{m{ \left( {m-1} \right) } \cdots { \left( {m-n+1} \right) }}}{{n!}}\mathop{{x}}\nolimits^{{n}}+ \cdots }\ {\sqrt{{1+x}}=1+\frac{{1}}{{2}}x-\frac{{1}}{{2 \cdot 4}}\mathop{{x}}\nolimits^{{2}}+\frac{{1 \cdot 3}}{{2 \cdot 4 \cdot 6}}\mathop{{x}}\nolimits^{{3}}-\frac{{1 \cdot 3 \cdot 5}}{{2 \cdot 4 \cdot 6 \cdot 8}}\mathop{{x}}\nolimits^{{4}}+ \cdots }\ {\frac{{1}}{{\sqrt{{1+x}}}}=1-\frac{{1}}{{2}}x+\frac{{1 \cdot 3}}{{2 \cdot 4}}\mathop{{x}}\nolimits^{{2}}-\frac{{1 \cdot 3 \cdot 5}}{{2 \cdot 4 \cdot 6}}\mathop{{x}}\nolimits^{{3}}+\frac{{1 \cdot 3 \cdot 5 \cdot 7}}{{2 \cdot 4 \cdot 6 \cdot 8}}\mathop{{x}}\nolimits^{{4}}- \cdots } \end{array}$$ 

Location directive is not working correctly nginx

I am trying to open the location of my index.php file for example:

The root folder is:

/path/to/my/root/folder
Code (markup):

The the url a user will use to get to this root folder is:

https://sub.mydomain.net/server/client
Code (markup):

Every time I use this location declaration I get a 404 or forbidden message

location /server/client/ {           alias /path/to/my/root/folder;           try_files $uri$  uri/ /index.php$uri$  is_args\$  args;        }
Code (markup):

I just cannot…

Location directive is not working correctly nginx