Stacker game with three blocks

I am pretty new to C# and so i would like to ask you, how i could improve my code. I am currently coding a Visual Studio C# Console Game where you have to stack blocks. Currently you can only Stack 3 blocks because my code is getting really long and i am really losing my orientation.

The voids “Reihe1()”, “Reihe2()” and “Reihe3()” are for the different rows. Is there any way i can improve my code? To completly understand my game pls just try it in Visual Studio.

I hope that you can help me. And please keep in mind, that i am a beginner!

Here is the code:

//(c) DomeGamer14  using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Threading; using static System.Console; using System.IO;  namespace Test1 {     class Program     {         public static string[] field = new string[70];         public static int counter = 0;          static void Main(string[] args)         {             for (int i = 0; i < field.Length; i++)             {                 field[i] = "O";                 Write(field[i]);                 if (i == 6 || i == 13 || i == 20 || i == 27 || i == 34 || i == 41 || i == 48 || i == 55 || i == 62 || i == 69)                 {                     WriteLine();                 }             }             ReadLine();              Reihe1();             ReadKey();             Clear();             Reihe2();             ReadKey();             ReadKey();             Clear();             Reihe3();             ReadKey();             ReadKey();         }          static void Show()         {             for (int i = 0; i < field.Length; i++)             {                 Write(field[i]);                 if (i == 6 || i == 13 || i == 20 || i == 27 || i == 34 || i == 41 || i == 48 || i == 55 || i == 62 || i == 69)                 {                     WriteLine();                 }             }         }          static void Reihe1()         {             do             {                 Clear();                 field[63] = "X";                 field[64] = "X";                 field[65] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[63] = "O";                 field[66] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[64] = "O";                 field[67] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[65] = "O";                 field[68] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[66] = "O";                 field[69] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[69] = "O";                 field[66] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[68] = "O";                 field[65] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[67] = "O";                 field[64] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[66] = "O";                 field[63] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;             } while (true);         }          static void Reihe2()         {              do             {                 Clear();                 field[56] = "X";                 field[57] = "X";                 field[58] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[56] = "O";                 field[59] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[57] = "O";                 field[60] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[58] = "O";                 field[61] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[59] = "O";                 field[62] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[62] = "O";                 field[59] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[61] = "O";                 field[58] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[60] = "O";                 field[57] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;                 Thread.Sleep(200);                 Clear();                 field[59] = "O";                 field[56] = "X";                 Show();                 if (Console.KeyAvailable == true)                     break;             } while (true);               for (int i = 0; i < 63; i++)             {                 if (field[i] == "X" && field[i + 7] != "X")                 {                     Thread.Sleep(2000);                     field[i] = "O";                     Clear();                     Show();                     counter += 1;                     if (counter == 3)                     {                         Clear();                         WriteLine("Game Over!");                         WriteLine("Press a Key to end the program!");                         ReadKey();                         ReadKey();                         Environment.Exit(0);                     }                 }             }         }          static void Reihe3()         {             if (counter == 2)             {                 do                 {                     Clear();                     field[49] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[49] = "O";                     field[50] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[50] = "O";                     field[51] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[51] = "O";                     field[52] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[52] = "O";                     field[53] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[53] = "O";                     field[54] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[54] = "O";                     field[55] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[55] = "O";                     field[54] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[54] = "O";                     field[53] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[53] = "O";                     field[52] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[52] = "O";                     field[51] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[51] = "O";                     field[50] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[50] = "O";                     field[49] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                 } while (true);                 counter = 0;                  for (int i = 0; i < 63; i++)                 {                     if (field[i] == "X" && field[i + 7] != "X")                     {                         Thread.Sleep(2000);                         field[i] = "O";                         Clear();                         Show();                         counter += 1;                         if (counter == 3)                         {                             Clear();                             WriteLine("Game Over!");                             WriteLine("Press a Key to end the program!");                             ReadKey();                             ReadKey();                             Environment.Exit(0);                         }                     }                 }             }             else if (counter == 1)             {                 do                 {                     Clear();                     field[49] = "X";                     field[50] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[49] = "O";                     field[51] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[50] = "O";                     field[52] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[51] = "O";                     field[53] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[52] = "O";                     field[54] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[53] = "O";                     field[55] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[55] = "O";                     field[53] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[54] = "O";                     field[52] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[53] = "O";                     field[51] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[52] = "O";                     field[50] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[51] = "O";                     field[49] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                  } while (true);                  counter = 0;                  for (int i = 0; i < 63; i++)                 {                     if (field[i] == "X" && field[i + 7] != "X")                     {                         Thread.Sleep(2000);                         field[i] = "O";                         Clear();                         Show();                         counter += 1;                         if (counter == 3)                         {                             Clear();                             WriteLine("Game Over!");                             WriteLine("Press a Key to end the program!");                             ReadKey();                             ReadKey();                             Environment.Exit(0);                         }                     }                 }             }             else             {                 do                 {                     Clear();                     field[49] = "X";                     field[50] = "X";                     field[51] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[49] = "O";                     field[52] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[50] = "O";                     field[53] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[51] = "O";                     field[54] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[52] = "O";                     field[55] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[55] = "O";                     field[52] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[54] = "O";                     field[51] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[53] = "O";                     field[50] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                     Thread.Sleep(200);                     Clear();                     field[52] = "O";                     field[49] = "X";                     Show();                     if (Console.KeyAvailable == true)                         break;                   } while (true);                  counter = 0;                  for (int i = 0; i < 63; i++)                 {                     if (field[i] == "X" && field[i + 7] != "X")                     {                         Thread.Sleep(2000);                         field[i] = "O";                         Clear();                         Show();                         counter += 1;                         if (counter == 3)                         {                             Clear();                             WriteLine("Game Over!");                             WriteLine("Press a Key to end the program!");                             ReadKey();                             ReadKey();                             Environment.Exit(0);                         }                     }                 }             }         }     } } ``` 

nvidia-smi shows only system time and then blocks system

I am installing nvidia drivers on Ubuntu 18.04. I completed the process successfully once, and was able to run nvidia-smi to see my graphics card usage.

However, after reinstalling my operating system and the drivers, every time I run nvidia-smi it prints the system time and date and then prints nothing else. My system becomes unresponsive to all inputs, and I have to reboot.

I am not sure how to debug this issue. I have tried:

  • Nouveau is disabled and I have run update-initramfs
  • I have attempted to install other versions (410.xx and 418.xx)
  • I have tried reinstalling the OS and doing a fresh driver install. The issue persists.
  • I have installed using the scripts available on NVIDIA’s website as well as through apt-get by adding the graphics ppa repositories.

How should I try to get nvidia-smi running successfully?

Why do we need to chain the blocks (creating blockchain) in a permissioned blockchain?

The main question is:

What does “chaining block” mean in a permissioned blockchain? OR in any blockchain network in which creating a new block does NOT need consuming resources/energy ? (even in the case of proof-of-stake)

Does “chaining blocks” (creating blockchain) WITHOUT consuming resources (in the case of PoW, this resource is electricity) make sense? where, re-calculating all hash values does NOT have any considerable cost and it takes few seconds.

In other words, Why do we need to chain the blocks (creating blockchain) in a permissioned blockchain network (such as Hyperledger whose consensus mechanism is PBFT)?

What does really mean chaining blocks without consuming resource/energy? where re-calculating all hash values and as a result replacing all blocks can be done EASILY and RAPIDLY.

The thing can make transactions history immutable in Bitcoin, is a PoW with enough difficulty and not only using blockchain data structure. Otherwise, only chaining blocks based on ex. a PBFT consensus (or even based on proof-of-stake) can be interpreted as a fallacy.

What is the role of blockchain (chained blocks) in a permissioned network? where if one is able to change one block, then he could change the whole of chain as well, by re-calculating all previous hash values, since there is NO difficulty to calculate hashes.

Note: I tried to bring up my question in several different forms to be more clear. In the case, you think some additional explanation is need, please let me know.

d3 brush blocks mouseover event

I have a stream graph that has mouseover events on the paths, I have tried adding a brush to this however because the brush’s g element is in front of the paths the mouseover stops firing.

I have found some solutions whereby the brush is put behind the paths and then the event is re-dispatched to the brush on mouseover of a path, but I need my brush displayed in front of my paths so this solution will not work for me.

I have also tried setting pointer-events to none on the brush g element but d3 seems to override this setting.

Does anyone know how I get the two to work in unison?

Below example can also be seen on codesandbox.

import * as d3 from "d3";  const width = 500; const height = 500;  let numberOfDataPoints = 100; const numberOfLayers = 5;  let data = [];  for (let i = 0; i < numberOfDataPoints; i++) {   let point = [];   for (let j = 0; j < numberOfLayers; j++) {     point.push(Math.floor(Math.random() * Math.floor(120)));   }    data.push(point); }  const x = d3   .scaleLinear()   .domain([0, numberOfDataPoints - 1])   .range([0, width]); const y = d3.scaleLinear().range([height, 0]); const z = d3.interpolateCool;  const area = d3   .area()   .x((d, i) => x(i))   .y0(d => y(d[0]))   .y1(d => y(d[1]));  const stack = d3   .stack()   .keys(d3.range(numberOfLayers))   .offset(d3.stackOffsetWiggle)   .order(d3.stackOrderNone);  let layers = stack(data); y.domain([   d3.min(layers, l => d3.min(l, d => d[0])),   d3.max(layers, l => d3.max(l, d => d[1])), ]);  function update() {   let path = d3     .select("svg")     .selectAll("path")     .data(layers);    path     .enter()     .append("path")     .attr("fill", () => z(Math.random()))     .merge(path)     .attr("d", d => {       return area(d);     })     .style("fill-opacity", 0.2)     .attr("pointer-events", "all")     .on("mouseover", d => {       d3.select(d3.event.target).style("fill-opacity", 1);     })     .on("mouseout", d => {       d3.select(d3.event.target).style("fill-opacity", 0.2);     }); }  update();  let brush = d3   .brushX()   .extent([[0, 0], [width, height]])   .on("end", brushEnd);  d3.select("svg")   .append("g")   .attr("class", "brush")   .attr("pointer-events", "none")   .style("pointer-events", "none")   .call(brush);  function brushEnd() {   console.log("brush end"); } 

How to show contextual filter / quick edit links for blocks – D8

I’m building a Drupal 8 template/theme from scratch, and it is not showing the contextual editing options for my blocks when I view a site page. I.E., the little circles that are clicked to see options like “edit view,” “configure block,” etc.

I cloned the block.html.twig from the Bartik theme, so it has the attributes token that I thought was enough, like this:

<div{{ attributes.addClass(classes) }}>  {{ title_prefix }}  {% if label %}    <h2{{ title_attributes }}>{{ label }}</h2>  {% endif %}  {{ title_suffix }}  {% block content %}    <div{{ content_attributes.addClass('content') }}>      {{ content }}    </div>  {% endblock %}  </div> 

I can confirm the Contextual links module is active.

I have global access, so it shouldn’t be a permissions issue.

Is there something more I need to do for this feature to be added in?

App that blocks sound notifications of SPECIFIED APPS at SPECIFIED TIMES

At the moment I use an app called Nights Keeper that automatically blocks ALL sound notifications for me during the time I sleep.

The problem is I would like to have most sound notifications (calls, SMS messages, E-mails…) automatically blocked during the time I sleep while some other ones would remain intact (so for example I wouldn’t hear if somebody called me or sent an email to me, but I would hear if somebody messaged me on WhatsApp).

Is there an app that can do this?

Thank you in advance for your answers.

Editing static blocks problem when saving

I have 1.9.0.3 Magento website, everything was fine, website wasnt edited in a year and when I tried to edit some existing static block and save or save and continue editing I am returned in CMS/Static Blocks panel and no changes are made. It allows me to create new static block, but when I copy paste code from existing old block same happened. What I noticed when playing with blocks when I copy/paste code from existing block in new block for example:

 <div id="banner-slider-demo-2-new" class="owl-carousel owl-theme owl-middle-narrow owl-banner-carousel">     <div class="item" style="background:url({{media url="wysiwyg/porto/homepage/slider/02/13_new.jpg"}})  

Cant save the new created block. When I remove word “style” everything is ok and block is saved. It happen with all lines with “style”. Code is not proper without “style” but block is saved. I flushed everything, deleted cache, same happened. In system.log I found error that repeats 20 times per day in last 12 months:

2019-05-20T16:27:25+00:00 ERR (3): Warning: Invalid argument supplied for foreach() in /home/fedorsoaps/public_html/app/code/local/Smartwave/Socialfeeds/Helper/Data.php on line 79

And, line 79 in Data.php is:

 79    foreach ($  doc->getElementsByTagName('ul')->item(0)->childNodes as $  child) {         $  raw = $  doc->saveXML($  child);         $  li = preg_replace("/<li[^>]+\>/i", "", $  raw);         $  peopleList[$  i] = preg_replace("/<\/li>/i", "", $  li);         $  i++; 

Meanwhile website frontend is working normally but I cant make any changes. I am not coder, just basic Magento installer, thanks for any help.

Bitcoin Blocks Date not coherent?

I was taking data from the BTC Blockchain with a custom script. I found something really weird.

Block nr. 24668 was created at 2009-10-09 23:02:57

Block nr. 24669 was created at 2009-10-10 00:15:48

Block nr. 24670 was created at 2009-10-09 23:15:43

Now tell me, how it’s possible that block 24670 is ‘younger’ than the 24669? I already checked and all the blockchain explorer websites show exactly this data.

Thank you for your attention,

Mattia

Updated laptop from 16.10 to 18.04 LTS, Stuck at /dev/… clean, ***/*** files, ***/*** blocks

Haven’t touched this laptop in a while, so when I did, I updated it to the most recent LTS.

It is a dual-booting Windows 10/Ubuntu system.

I get stuck at /dev/nvme0n1p7: clean, 291381/1324512 files, 3883511/5297920 blocks. after selecting Ubuntu in GRUB.

I saw some other users fix by purging nvidia drivers, which my system does not have (no nvidia GPU, tried it anyway, just listed 0 installed, 0 removed etc.)

Saw some others suggest sudo apt update, to which I got these:

Failed to fetch http://au.archive.ubuntu.com/ubuntu/dists/bionic/InRelease Could not resolve 'au.archive.ubuntu.com' and similar 5 other lines, with the last one being cannot resolve 'dl.google.com'.

Does anyone know what I can do to get back into my system?

Problem about /dev/sdc2:clean blocks

guys.My English is not good.Apologize. And here’s my problem,I installed Ubuntu 18.01.2 LTS to my Mechrevo X1 GTX 1050 laptop to build dual system (with win10 pro) earlier.After some works,it runs perfect.I installed nvidia graphic driver and some development apps.And I have another moniter, it’s works well.I always play games on windows,and switch to ubuntu for work.One time I boot ubuntu, the screen of my laptop got message ‘/dev/sdc2: clean ****/**** files, ****/****** blocks’, but the second moniter works.I can not remember what was the last change of system.Is there some way can solve this?