/dpt/ - Daily Programming Thread

Previous thread: I assume some of you are working on something that doesn't involve const_cast. Please talk about that instead of const_cast, thanks.

Attached: 1493628024068.png (640x640, 16K)

Other urls found in this thread:

pastebin.com/xAjvcC5f
lazyfoo.net/tutorials/SDL/11_clip_rendering_and_sprite_sheets/index.php
twitter.com/NSFWRedditVideo

first for rust is a god given language

Attached: serveimage.jpg (1280x720, 99K)

fpbp

Then why doesn't Terry use Rust? Checkmate RESF shills.

>Please talk about that instead of const_cast
Make me faggot

>There are people who actually think const_cast can't mutate things

I'm glad we agree now that C++ does allow you to enforce immutability.

Say that again, motherfucker.

Attached: 1517142509104.jpg (125x125, 2K)

He's currently working on holyRust. It's the same, but better. Even backwards compatible to standard rust

Attached: sexyboi.jpg (900x900, 108K)

C++ does not, and that's fine.
C++ is for people who know what they're doing. Only faggots and rust programmers (oh wait, they're the same thing) need hard restrictions.

help /dpt/
I'm forced to program a file exchange via java NIO. My problem is, I can exchange the files, but have no clear way to exchange the filename in the same stream.

the Sender class uses:
public class Sender implements Runnable {
private InetAddress target;
private int port;
private String filePath, fileName;

public Sender(InetAddress target, int port, String filePath, String fileName){
this.target = target;
this.port = port;
this.filePath = filePath;
this.fileName = fileName;
}

@Override
public void run() {
SocketAddress server = new InetSocketAddress(target,port);
RandomAccessFile file = null;
boolean error = false;
try {
file = new RandomAccessFile(filePath, "rw");
} catch (FileNotFoundException e) {
error = true;
}
if(!error) {
try (FileChannel fileChannel = file.getChannel();
SocketChannel socketChannel = SocketChannel.open(server)) {
fileChannel.transferTo(0, fileChannel.size(), socketChannel);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}


(cont.)

While the receiver thread is here:
pastebin.com/xAjvcC5f

>faggots and rust programmers (oh wait, they're the same thing)
It's funny because of the people I know who are excessively enthusiastic about Rust, one is gay, one is dating a trans man, and one is a trans woman.

>three are gay

Actually, yeah.

I thought it was indentation that made your code horrible.
Turns out it is just Java.

It is always a python script kiddie or a javalet asking for help with his homework
Fucking ALWAYS.

It could very well just be me. This is the first time I've written java code in my life.

Make sure your implementation can beep

Can someone give me a no-bullshit overview of what Oracle DB actually does and how it's different from something like Postgres, or at least some place where I can learn about it without having to wade through Oracle's stupid marketing-speak? Apparently the Wikipedia page was written by Oracle's PR drones and is a combination of marketing blurbs and useless technical trivia.

Attached: 1505983784597.png (300x300, 13K)

Just drop the crap and use MySQL

FAGGOTS
A
G
G
O
T
S

I'm about to start working for a startup that uses it. It's not my fucking choice.
And if it was I certainly wouldn't pick MySQL. Why would you even suggest that? Are you a PHP developer or something?

So you are forced to deal with Oracle DB and instead of actually working with Oracle DB, you ask about Oracle DB with a meme image of Oracle and asking for comparison with yet-another-db which postgre.
Stop wasting your time and get to work.

Oracle and ServerSQL a lot expensive Applications are write for it, plus Oracle build some super expensive computer for database usually fortune 500 clients.

I have a problem with my homework in Java. I am assigned to make Minimum Spanning Tree method of a Weighted Graph using Prim's algorithm where you can start wherever you want in the graph. So far, I have done very well. It almost manages to find the MST. However, I am completely clueless as to how I am supposed to set up List T so that it searches for the lowest weighted Edge in the List. Instead I've just made it so that it just goes through the tree linearly, vertex for vertex(node), thus it skips some of the nodes. It's kinda hard to explain. Pic related is an example of a graph that I want to find the MST for while connecting all nodes and the pic below is the results...

How would you solve this, as in making List T as if it was a node of its own?
This is how the algorithm works:

MST V is an array/list of nodes

Let T be a set for the nodes in the spanning tree;
Initially, add the starting node to T;

while(size of T

Attached: prims algo.png (936x588, 30K)

any tipps for this?
I can't come up with any other solution than pure bruteforce. Maybe it's the only way though

Attached: toodumblol.png (932x409, 31K)

public MST minimumSpanningTree(int startingVertex)
{
if(startingVertex>getSize()-1 || startingVertex

we need better algorithms

/dhwt/ - Daily Home Work Thread
ps: it is a general but 'thread' makes retards feel better.

I'm waiting for it to download. Figured someone here might have some hints as to what I should brush up on or holes I'm likely to fall through as someone who has mainly used Postgres and SQLite.

Attached: 1505141667112.png (362x64, 4K)

>7.2 GB
Oh god.

pajeet why are you so angry

Attached: pajeet.png (89x107, 13K)

If i,j is a saddle point then neither of i-1, j; i+1,j; i, j-1; or i, j+1 can be a saddle point. That's the only improvement over brute force I notice at a glance. But that doesn't help that much, I think.

Sorry if my question sounded retarded
I will rephrase it:
What I want is that the program finds node u of T that is connected to a node v in V that has the lowest price out of all the other connected nodes between T and V

Attached: 2479.gif (480x360, 12K)

>price
mean weight

Trivial-tier: find the maxima of each row. Then find the minimum for each column that contains a maximum and see if it matches the maximum.

Rather than bruteforce by checking every point for being a saddle point you should come up with a list of row maximums and column minimums and compare.

> Then find the minimum for each column that contains a maximum
There can be more than one maximum (>= every element in the row), so every column contains at least one maximum.

Currently rewriting the Rust compiler in C.

Attached: stages_of_denial_second_edition.png (1024x1024, 338K)

Can you do ghc next? Seems almost impossible to compile a modern version on Illumos.

Oh, I misread the problem. I thought it was a 'local' saddle point.

>used C++ for 8 years
>finally started using C
>my fucking dick when

Attached: 1514301570929.gif (400x304, 1.95M)

Hey guys. I am trying to learn rust. Is there a good source for excercises for a chapter similar to K&R? doc.rust-lang.org/book just explains things without giving any excercises

fuck off rustlet

Anyone else uses C++ like C with class-like structs.

Not that I'm aware of.

>(cast) the return of malloc for 8 years
kek, lmaoing @ ur life

Is it bad to learn a new language? Throughout my uni career, I did a lot of Java, Python, and C. When I interned, I learned about Nodejs. Rust looks cool so I want to try it out.
Ah I see. I tried looking at exercism but it seems like you need to know all the syntax already while K&R gave you excercises that help you understand the topics in the chapter.

Why didn't you tell me sooner?
So many wasted years.

Attached: 1500488683814.png (446x399, 9K)

Maybe Hackerrank or something similar has Rust exercises.

When I write C++, it's literally just C code but with exceptions.

>using C++ exceptions
Wow user.. noexcept

dumb frogposter

>There can be more than one maximum
I did say "maxima".

> every column contains at least one maximum.
This is nonsense.
1 0 0 0
1 0 0 0
1 0 0 0
1 0 0 0

In any case, your objection is irrelevant.

What did you mean to prove by that matrix?

C++ is trash
--------------
Change my mind

I should've said every row contains at least one maxima (because according to the saddle points are row maxima and column minima)

Every single point of that matrix is both a column minimum and a column maximum in the terminology of game theory (where these saddle points come from).

Saddle points are where row maxima and column minima coincide, meaning that every point in the left column is a saddle point.

When I write C++, it's literally just Lisp code but without Garbage collector.

Make me

I can't

do

C++ is worse than trash

>What did you mean to prove by that matrix?
He said that every column contains at least one maximum. "Maximum" in the context of this problem refers to the maximum of a row, not that of a column. Clearly not every column contains a maximum of at least one row in that matrix.

You're right, but your phrasing is imprecise. You mean "the minimum for each column that contains a ROW maximum"

>I should've said every row contains at least one maxima
Yes, user. Any set of numbers has at least one maximum. What a stupid remark.

>Every single point of that matrix is both a column minimum and a column maximum
Yes, user. Because every column is just the same number repeated.

>Saddle points are where row maxima and column minima coincide
Yes, user. That's what the fucking problem statement says. I like how you think making blatantly obvious statements somehow refutes anything I said.

See If you say " find the minimum for each column that contains a maximum" obviously people will interpret "column that contains a maximum" to mean "column that contains a maximum"

>your phrasing is imprecise
Maybe your reading comprehension is pure shit.

"column that contains a COLUMN maximum"

No, your technical language is shit. You left too much ambiguity in your phrasing.

>obviously people will interpret "column that contains a maximum" to mean "column that contains a maximum"
Maybe if they suffer from extensive brain damage, like you. Everyone else is capable of figuring out that the maxima in question are the same ones mentioned in the problem statement, and in the preceding sentence, which are not column maxima.

If you're not using God's chosen 8086 assembly language you're human rubbish

Your parents are piece of shit that should've been sterilized. Please don't repeat their mistakes.

>implying God isn't a RISC-V fag

>If you're not using God's chosen 80386 assembly language you're human rubbish
ftfy

In some code I'm reading, the author has prefixed classes with 'L', e.g. 'LTexture'. What did he mean by this?

Or they just ignored your reply entirely. I was the only one who replied after all.
Nice argument. If you wanted to be precise you would use pronounces properly
BAD:
>find the maxima of each row. Then find the minimum for each column that contains a maximum and see if it matches the maximum.
GOOD:
>find the maxima of each row. Then find the minimum for each column that contains one of THESE maxima and see if it matches the maximum.

*pronouns
Damn maybe I really am too tired to program.

>He doesn't write Power Architecture assembly for GameCube games

Literally anything. It's impossible to tell without context.

It's from the LazyFoo SDL tutorials.

lazyfoo.net/tutorials/SDL/11_clip_rendering_and_sprite_sheets/index.php

In later tutorials he has a class named "LTimer" too.

One can always be more precise at the cost of extra verbiage. I just see no reason to go out of my way just to clarify things for a degenerate animal like you. Anyone that can be reasonably considered human is capable of figuring out what maximum is being referred to (protip: it's the same one that's in the problem statement. protip #2: it's the same one from the previous sentence). Get sterilized, subhuman.

It's probably just short for "LazyFoo", then. C programmers usually prefix all of their functions and typedefs with gibberish to avoid conflicts. C++ has namespaces to avoid this, but some people don't like to use them and will do it the C way.

Consider
>minimum for each column that contains a maximum
When someone reads "maximum" they naturally give the context within the sentence higher priority than the context before the sentence. This is why the interpretation of "maximum" as referring to the column maximum is less strained in natural English.
Obviously someone could realize that this makes no fucking sense in the context of the problem and deduce that it refers to the row maximum of the proceeding sentence, but it would also be natural to deduce that the sentence is nonsense and the author is wrong (especially in the context of a /dpt/).

I didn't forget the previous sentence, I gave the context within the sentence itself higher priority than the context before it.

Ah, I see. Thanks!

>imagine you're a retard like me who forgets the previous sentence as soon as he finishes reading it
Don't care.

> I gave the context within the hurr durr blugh
Don't care. You're not human.

i'm almost 28 and want to learn to code. how do you recommend to start studying? freecodecamp or sololearn? and what language?
i heard python is pretty easy to learn, but don't know how useful it is right now, i heard a lot about javascript, css and htlm5.

I have to migrate a very big set of data, i.e 30 excel files of 1.5-2.5k rows, 2.1k columns (yes I know...) to a database. The Database model is rather different (read "saner") than how it was encoded in excel.
My idea was to gradually reduce the number of columns by replacing them by inserting one object at a time in the Database and replacing it by their row IDs in a new excel/csv file.
e.g. there are 10*5 columns with information relative to an address, I'd iterate over the file a first time and produce a new one with those 5columns replaced by the Foreign Key of the Address table in the database, and so I can use that key for the relationships in my next iteration, the next iteration I'd do the same for the "People" table, etc.

I have 2 questions :
> Is there a better course of action ?
> What's the best tool for that ?
Someone recommended me Talend, but it's a shitty piece of bloatware. And since this isn't so hard to do, I thought I could just programming something myself.
I don't really know what language/libraries would be the most appropriate though. Ideally I'd like to have easy async IO (as long as the appending to the new file can easily be atomized) and something that helps me guarantee everything is correctly transferred/encoded.

unhear that and learn C. K&R

In C++, what's the difference between calling a function like cout as it is and adding the std:: before it?


like std::cout or std::string instead of string data type?

Literally pick up SICP and go through all of it. It gets memed, but it's popular for a reason. If you go through the whole thing, you'll be ready to continue on in any way you'd like.

why do you want to learn how to code? to land a job? in that case the latter three are probably a good choice, but you should look up which languages job offers that seem interesting to you usually require

#define private public

cout isn't a function, neither is string. you always need to add std:: before those two. when it isn't added, it's added beforehand by adding using namespace std;

std::string is the full name of the type. You can only refer to it without the std:: if you import the name with using std::string; or using namespace std;.

>i heard python is pretty easy to learn, but don't know how useful it is right now, i heard a lot about javascript, css and htlm5.

Freecodecamp is for webapps (like twitter and facebook, sites that dynamically change and take in and represent user data)

Python is easy to learn and can be learned through codeacademy (python 2.7), but I'd recommend Automate the Boring stuff which uses python 3 and walthrough some interesting scripts to automate your daily life. Like filling out excel sheets to scraping the web for data.

However I'd take a step back and ask yourself - what do I want to build. Then determine the right programming language from there.

It can't really break anything either, so who cares.

In case of having multiple libs which might have a function named exactly the same, that's how you choose between them

#define i j

Attached: dr.jpg (1400x933, 258K)