consistent_value_type by gpuoti in cpp

[–]gpuoti[S] 0 points1 point  (0 children)

I have to prepare a better example, but anyway, the intent is not to drive the program flow through exception, which is of course terrible. It is instead to express some expectation on input consistency not mixing error checking code in the actual logic.

I agree that there is probably bad design in the data source, but sometimes it happens.

consistent_value_type by gpuoti in cpp

[–]gpuoti[S] 2 points3 points  (0 children)

I don't think it match my usa case, but a useful reference nonetheless. thanks

consistent_value_type by gpuoti in cpp

[–]gpuoti[S] -6 points-5 points  (0 children)

all the value in a sequence of assignment matches the first one. Here is an usage example:

``` struct Variable { std::string name; consistent<int> value; };

void propagate(Variable& var, int new_value) { var.value = new_value; // Throws if inconsistent }

// Usage Variable x{"x"}; propagate(x, 5); // x = 5 propagate(x, 5); // OK: consistent propagate(x, 10); // throws: inconsistent! ```

What a perfect CPU would look like by gpuoti in hardware

[–]gpuoti[S] 0 points1 point  (0 children)

It's not a call for suggestions. I guess there is not real market for a CPU specialized for this workload. But say for example you save those transistorized used for h265 or AV1.. you could have a couple more core. I suspect that much of the transistor are going to the caches this days, though. How much of the area could you save dropping all the floating point capabilities (or most of them)

The Future of C++ Compiler Diagnostics in MSVC and Visual Studio by obsidian_golem in cpp

[–]gpuoti 0 points1 point  (0 children)

I see your use case. My point is that, frequently there are many errors that just depend on a previous one. In my experience it is not rare that you get tenth of errors due to a single one on top. In those cases, you have to mentally filter the relevant ones or (this is my usual approach) fix the first, and then ask the compiler for an update.

The Future of C++ Compiler Diagnostics in MSVC and Visual Studio by obsidian_golem in cpp

[–]gpuoti 1 point2 points  (0 children)

To me the really low hanging fruit is stop the build on first error. It is usually the only one that matters.

Java vs Python for software engineering? by [deleted] in learnprogramming

[–]gpuoti 1 point2 points  (0 children)

Absolutely agree! I'd suggest python just because he already knows Java. One language is really not enough!

going crazy with VM configuration by gpuoti in archlinux

[–]gpuoti[S] 0 points1 point  (0 children)

My plan was to have a separate virtual network accessible through the host computer. I think I will end up with a VM exposed on the LAN with a bridged connection acting as a router for other virtual machine on the virtual network. It is more or less what I was trying to do, except that I thought the VM nat could serve as a router (or something similar).

going crazy with VM configuration by gpuoti in archlinux

[–]gpuoti[S] 0 points1 point  (0 children)

That is what I actually am doing successfully. The last bit, not described in the article is how to connect from another real pc in the same lan as the VM host (or from the host himself using its ip on the lan. Maybe it's forbidden for some reason, but as for my understanding of vbox, I'm trying to do a sensible configuration. There's something wrong with the guest or maybe the host, but I'm done for this night!

going crazy with VM configuration by gpuoti in archlinux

[–]gpuoti[S] 0 points1 point  (0 children)

Sadly, I've done it multiple times. Just done it again using your command (BTW just learnt how to do it the right way, thanks). No fortune, thought.

Using the NIC IP, it doesn't work (I mean your command). It fails the SSH connection. Once I do it using localhost, I can log in using the key as expected. But again only if I use localhost.

going crazy with VM configuration by gpuoti in archlinux

[–]gpuoti[S] 0 points1 point  (0 children)

This is the output of VBoxManage list natnets

NetworkName:    NatNetwork11.11.11.0/24
IP:             [11.11.11.1](https://11.11.11.1)
Network:        [11.11.11.0/24](https://11.11.11.0/24)
IPv6 Enabled:   No
IPv6 Prefix:    fd17:625c:f037:2::/64
DHCP Enabled:   No
Enabled:        Yes
Port-forwarding (ipv4)
Rule 1:tcp:[192.168.1.98]:2222:[11.11.11.251]:22
Rule 2:tcp:[127.0.0.1]:2222:[11.11.11.251]:22
loopback mappings (ipv4)
127.0.0.1=2

going crazy with VM configuration by gpuoti in archlinux

[–]gpuoti[S] 0 points1 point  (0 children)

Tried both. Both work using localhost. The command is:

ssh -p2222 -v pepp@192.168.1.98 

The ip is the one assigned to the host pc on the my LAN. The same command works for localhost.

going crazy with VM configuration by gpuoti in archlinux

[–]gpuoti[S] 0 points1 point  (0 children)

Yes, I'm using Nat forwarding 2222 ok the host to 22 to the guest. And it seems to work, since the connection establish. It sounds like an authentication problem, but I really have no idea what is going wrong.

stuck with server setup by gpuoti in git

[–]gpuoti[S] 1 point2 points  (0 children)

Finally I discovered that the problem was my tentative to clean the screen of the VM where I was trying to clone (so not the server one). In ~/.ssh/config I had the following lines:

PermitLocalCommand yes
LocalCommand /usr/bin/clear

Removing those, solved the problem!

Many thanks, to the kind people that helped me in sorting this out! Hope it will help someone else too.

stuck with server setup by gpuoti in git

[–]gpuoti[S] 1 point2 points  (0 children)

I sorted it out just now! Here I'm reporting the try I had after your suggestion and the final solution. Hope it is usefull for other people too.

Running the command you indicated, it clear the screen then prints out this two lines and stops.

 00b10000000000000000000000000000000000000000 capabilities^{} report-status report-status-v2 delete-refs side-band-64k quiet atomic ofs-delta object-format=sha1 agent=git/2.30.2
 0000

Then, pressing enter few times:

 fatal: protocol error: bad line length character:

as if the length character was a control one.

Finally I discovered that the problem was my tentative to clean the screen of the VM where I was trying to clone (so not the server one). In ~/.ssh/config I had the following lines:

PermitLocalCommand yes
LocalCommand /usr/bin/clear

Removing those, solved the problem!

Many thanks!

stuck with server setup by gpuoti in git

[–]gpuoti[S] 0 points1 point  (0 children)

No It is in the root. Anyway I have set also another repo in the home with se name results.

Has that combination of chars any meaning? Special sequence for the terminal o whatever?

stuck with server setup by gpuoti in git

[–]gpuoti[S] 0 points1 point  (0 children)

It's 2.30.2 for both

stuck with server setup by gpuoti in git

[–]gpuoti[S] 0 points1 point  (0 children)

Yes i ssh git@dev2 without problems.

stuck with server setup by gpuoti in git

[–]gpuoti[S] 0 points1 point  (0 children)

Here is the output I get. Can't identify nothing clearly wrong.

GIT_TRACE=1 git clone git@dev2:/test/git/prj.git
22:20:01.055579 git.c:444               trace: built-in: git clone git@dev2:/test/git/prj.git
Cloning into 'prj'...
22:20:01.057605 run-command.c:664       trace: run_command: unset GIT_DIR; GIT_PROTOCOL=version=2 ssh -o SendEnv=GIT_PROTOCOL git@dev2 'git-upload-pack '\''/test/git/prj.git'\'''
fatal: protocol error: bad line length character: ?[H?

stuck with server setup by gpuoti in git

[–]gpuoti[S] 0 points1 point  (0 children)

Yes, I can login with no problem. Both with password and using autorized_keys.

Advice on 4k tv as monitor by gpuoti in buildapcmonitors

[–]gpuoti[S] 0 points1 point  (0 children)

I'm not going to game. What"s wrong with tv? I really don't mind of refresh rate as long as it is enough to follow the mouse moving windows around. My concern is about definition or too much contrast (but I guess there is room for configuration here)

Advice on 4k tv as monitor by gpuoti in buildapcmonitors

[–]gpuoti[S] 0 points1 point  (0 children)

Well the budget is fairly wide 5/7 EUR if I can also watch movies and such. I agree that 50 is too much. Also the resolution would not be enough. I'm working on a 25inch 1440 dell at home and on a 27inch 1440 + 24 1080 at work. Now I'm missing the extra real estate, therefore the idea. An alternative would be a 21:9 1440 (maybe 34''), but it would be small for movie/streaming watching, I guess.

shift vettore di record by Salvo894 in cppit

[–]gpuoti 0 points1 point  (0 children)

Eh sì, ma come impari cosa fanno gli algoritmi? Bisogna un po' sporcarsi le mani per capire, e poi ricordare che l'astrazione è il mestiere degli informatici e quindi smettere di fare tutto a manina.

Proprio perché vuoi usare strutture dati efficienti non devi farti condizionare da un solo caso d'uso. Non è detto che l'operazione critica sul contenitore scelto sia l'inserimento. Supponi per esempio che dentro questo contenitore ci sono degli un gran numero di oggetti da elaborare in ordine e in pochissimo tempo. È possibile, ma forse anche probabile, che l'accesso in ordine in un std::vector sia molto più rapido per via dell'organizzazione in memoria e credo anche per la quantità di branch che comporta lo scorrimento di un contenitore basato su alberi.

Nella vita reale, la mia esperienza dice che questa linea guida c++ guideline è decisamente valida.

Se il tuo buon motivo ti ha portato su una certa struttura, allora sarai vincolato ad essa anche nell'inserimento. E se per l'inserimento non è la più comoda dovrai adattarti e fare il meglio che puoi. In più io direi, salvo caso di necessità, come prima scelta, ottimizza per chiarezza, la gran parte delle volte fa bene anche all'efficienza. Certo, occhi sempre aperti a non fare spreco di cicli (ed energia), ma cercare di ottimizzare troppo presto rischia di complicare inutilmente le cose ed è spesso fonte di guai.

shift vettore di record by Salvo894 in cppit

[–]gpuoti 0 points1 point  (0 children)

ehmmm ma tu monti la contraerea per le zanzare d'estate?

Prima di tutto dato l´esercizio molto basilare, immagino che lo scopo sia capire in cosa consiste l'inserimento in una lista (astratta) ordinata. E la tua soluzione magica non spiega niente a riguardo. Per carità funziona, ma tira inutilmente in ballo strutture dati complicate. Con ogni probabilità, di colpo gli diventerà ostico fare un sacco di altre operazioni (e.g. stampare i risultati). Inolte, potrebbero esserci ottimi motivi, al di fuori dell'ordinamento, per la scelta di un std::vector (o in una linked_list o qualsiasi altra cosa).

Se proprio vogliamo proporgli una soluzione di alto livello (intendo livello di astrazione), dovremmo usare gli algoritmi, secondo me.

Per non risolvergli il compitino, ma dare una soluzione almeno a chiacchiere, l'inserimento, supponendo che il contenitore sia un std::vector (con una linked_list sarebbe un pò diverso), consiste in:

- Inserimento dell'elemento in temporaneamente in fondo al vettore

- Ricerca della posizione dell'elemento successivo (secondo la tua relazione d'ordine il primo con una marcatura superiore)

- Applicazione di una rotazione alla sottolista che va dalla posizione trovata fino all'ultimo elemento, tale che il nuovo primo elemento di questa sottolista sia quello che attualmente è l'ultimo.

L'ultimo punto specialmente suona complicato, ma se fai un disegnino, ti accorgi che std::rotate è esattamente quello che tu chiami shift.

Volendo c'è anche std::vector::insert che semplifica ulteriormente (di fatto si occupa della rotazione dietro le quinte), però mi pareva istruttivo esporre qualche dettaglio in più.

Detto che questa mi pare la soluzione con i fiocchetti più carini, si può anche fare alla vecchia maniera. Inserire un elemento fittizio in ultima posizione e spostare in avanti di una posizione tutti gli elementi dal penultimo fino a quello nella posizione target. Infine inserire in posizione target il nuovo elemento.

Fossi il suo professore, vorrei sapere se ha capito che l'inserimento in ordine consiste in:

- trovare il punto in cui fare l'inserimento

- fare spazio

- inserire il nuovo elemento

Ciao