/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

example.com
hackerrank.com/challenges/queue-using-two-stacks
Sup
twitter.com/SFWRedditImages

I like Rust's cargo. So I've decided to create a project manager for C/C++. Basically it's a fork of both meson and conan

Happy birthday Sup Forums

example.com
So what's the official terminology for this text? URL? URI? Link?

I want to make a terminal emulator for windows, since everything i tried sucked in one way or another. What ui library/framework dou you find the least insane?

C + WinAPI.

Url ?
A Uniform Resource Locator (URL), colloquially termed a web address, is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. A URL is a specific type of Uniform Resource Identifier (URI)

So this is the power of Sup Forums

Electron

Fuck you, winapi is terrible.
Might as well use Hyper then.

Just finished working on this, started it about 6 minutes ago. Will probably not work on anything else for months.
if ((window.location.href.indexOf("?search_query") !== -1) || (window.location.href.indexOf("watch?") !== -1)) {
window.location.href = window.location.href.replace("you", "hook");
}

>terminal in windows
Please

With mingw and ubuntu bash on windows it's quite usable. I'd love to switch to linux, but muh games and i don't feel like rebooting all the time to switch systems.

if ((window.location.href.indexOf("?search_query") !== -1) ||
(window.location.href.indexOf("watch?") !== -1)) {
window.location.href = window.location.href.replace("you", "hook");
}

...

Does anyone know if it's possible to do some compile time mumbo jumbo in c# to force an interface to have a method?

You mean like define the method in the interface?

Just run Windows in a VM.

.catalog-thread::after {background-image: none !important;}

>yellow moot brings /prog/ back
>5 posts a day on average
>4/5 posts break at least one global rule

I tried the othe way around (ubuntu in vm) and it was performing quite poorly. Might try it out on linux host though. What vm software is best? I've been using virtualbox.

I pressed enter to fast so a big part is missing of what I wanted to ask but. But I want:
public interface SomeInterface {}

public class SomeClass: SomeInterface {}
public class SomeOtherClass: SomeInterface {}
public class SomeNewClass: SomeInterface {}

public interface SomeOtherInterface {
void do_shit(SomeClass sc);
void do_shit(SomeOtherClass soc);
}
to error.
I want the SomeOtherInterface to always include a do_shit method for every class that implements SomeInterface. So the above should not compile until I change the definition to include:
void do_shit(SomeNewClass snc);

Add a void do_shit(SomeInterface si) method and inspect the type of the argument passed to it.

how to algorithmic/AI music

bach + neural network

What are some fun APIs to help me enjoy programming again?

My code is currently a void do_shit(SomeInterface si) with a switch statement in it and wanted to move away from it to something a bit nicer.

How do I learn C-hashtag

css is the fucking worst, nothing works as you'd think it would

>add 1px margin
>entire thing explodes
>add float left
>suddenly everything breaks


this shit is embarrassing

I'm not aware of any nicer way to do it in C#

I guess this is the non-webscale programming thread huh.

make video games in unity

MSDN

Professional developer here. I've been more negative lately than I have in many months. I like programming, but I hate software development. For those of you thinking about a career in programming, let me tell you some hard truths.

>25% of programmers are so incapable, it will feel like helping your mom with her computer when you work with them
>Another 50% of programmers can write code without hand holding, but what they produce is terrible. It's not just bad code, it's also the very idea and general approach they took that was bad and basically unworkable.
>A majority of your day will be putting out fires caused by the 75% of your coworkers who don't belong in this field. You will rarely make much forward progress on anything.
>Some of those programmers belonging to the 75% will have giant egos and think themselves god's greatest gift to mankind. No matter how many failed projects lie in their wake, they're the next fucking Linus Torvalds. They'll often get promoted over you because management doesn't know better and buys into the story they weave about how they saved the project when really they were the cause of it being in trouble and everyone else had to bail water on the sinking ship.
>The amount of dumb Indians you meet will make you start to associate the accent with stupidity. No matter how not racist you are, you'll start avoiding Indians, even if subconsciously.
>The term "legacy code" is completely irrelevant. You'll see new code for a new project that started one week ago and it's already swimming in diarrhea. The age doesn't matter. The code was always shit.

hackerrank.com/challenges/queue-using-two-stacks

Tell me I'm dumb. The only way I can think of implementing a queue using two stacks is like this:
Enqueue: append element to first stack
Dequeue and peek: reverse the first stack using the second stack and popping the last element off the second stack. peek would put the value back.

However if I write it this way most of the test cases timeout. I really don't believe the time limits would be set so micro-optimizations would matter. SO there must be something wrong with this algorithm.

Whoops, sorry didn't mean to reply.

How are you today mr Dunning-Kruger

I'm fine as long as I get money. Better than being a jobless NEET.

80/20 rule. The lion's share of the work comes from a small number of workers. That's just how it is.

how do i access the count(__.___) from the nested query?

SQL> select memberid, lastname, firstname, count(CurrentLoan.bookid), count(History.bookid)
2 from(
3 select memberid, count(currentloan.bookid), count(History.bookid)
4 from History full outer join CurrentLoan using(memberid)
5 group by memberid
6 ) join Member using(memberid);

--- error msg ---
select memberid, lastname, firstname, count(CurrentLoan.bookid), count(History.bookid)
*
ERROR at line 1:
ORA-00904: "HISTORY"."BOOKID": invalid identifier

the nested query alone works properly, and this works fine also:
SQL> select * from (select memberid, count(currentloan.bookid), count(history.bookid)
2 from history full outer join currentloan using(memberid)
3 group by memberid)
4 join Member using(memberid);

is pycharm meme or actually good IDE?

It's one of the best IDEs for any language

Don't forget the significant number of good programmers who get assigned to fight fires in shitty legacy code, but are never given time to fix the underlying problems. What a waste of talent.

I think it's related to the obsession with having easily replaceable devs. The only way to get that is to force use of lowest common denominator tools and languages. Never mind that highly skilled devs using advanced tools would be far more cost-efficient. After all, what if one of them were to ask for a raise or threaten to leave? We might then have to pay them closer to what they're really worth, and that would be terrible!

I like it. It's simpler and more out-of-the-way than Eclipse and isn't a buggy POS like Netbeans-based IDEs.

I just wish I could get an unlimited stream of .edu address so I can keep using it for free and have Spotify+Hulu for cheap. I would probably set up some forwarding rules so they would never see emails come in. Normies don't look at that shit. But getting the passwords would be the hard part. hmm...

Just pay for them or use free alternatives you cheap bastard

If they can afford discounts for uni students they can afford discounts for me. And I'm willing to put in the effort, my time is worthless.

>If they can afford discounts for uni students they can afford discounts for me
So? They don't have to give you one.

Stop wasting time on useless autistic "challenges" and start writing real world projects

D is dead

software engineering was a mistake

Explain why can't you shouldn't use regex to parse HTML, without going to stack overflow

Because HTML is bonkers and allows insane shit.

explain why i shouldnt parse JSON with regex

Yeah? They don't have to, nor do they intend; but I will make them if I can. Do you not understand the war of wills?

>but are never given time to fix the underlying problems.

A lot of software out there is written around a rotten onion core, and there's no way to safely excise it, so starting from the ground up is the only option. The only problem is that rewrite projects are almost always destined to fail. Not that they're impossible, but they're usually spearheaded by people who are incompetent.

It's a dangerous game.

What real world project are you working on right now?

pong in pure css

You shouldn't use regex to parse anything
Regex is always more complicated than the problem domain, and is always the most complicated part of the solution

It's in the name. Regular expressions are for text which is regular. HTML is not regular. It's very context sensitive. Maybe valid XHTML can be parsed with regex, but you often don't get that in real life.

As long as the structure of the page is going to remain fairly static, there's no reason you can't use regex to extract particular elements.

Obviously, there are preferable options:
1. Use their API
2. If there isn't one, use an HTML parser

The best is when a site doesn't offer an API and they change their layout often, just to piss off developers.

Someone is bad at regex.

Don't worry, I'm sure teaching everybody to "code" in JavaScript will fix things.

I love my 4GB of ram Electron-based desktop applications!

The future is now!

It'd great for code golf
Awful for everything else

>paying for an IDE
t. shill

Rewrite projects are easy with a full test suite

But usually rewrite projects are headed by lazy idiots who can't get around to learning the current code. No way they'd bother writing tests around the current system, even if it would ensure the success of their rewrite.

Yeah definitely bad at regex.

I use that shit all the time when I'm writing. Copy, paste, regex find and replace. I've written simple assemblers using a few lines of regex. I'm written text analysis programs using DAGs of regex nodes. Maybe your interests don't have you deal with text or textual protocols, but their use is a lot more than what you think it is. And what's the alternative? Writing your own parsers for regular languages? Lol. You'd have to try hard to make that end up more efficient than the output of a good regex compiler.

I feel like a retard for asking this.

Building a "sudoku verifier/checker" in C++. Have to a build a boolean function to return a true or false if a specific column contains a duplicate value (1,1,2,3,4, is false etc.) and the information the function needs can only be in the parameters when you call it.

How would you go about checking for a specific column in the array when the parameter of the function already has the number of columns?

But at what point is rewriting around current test actually going to help? Maybe the whole high-level design is fucked and writing an implementation to fit it would be difficult or idiotic. Maybe the tests are shitty and rely upon subtle bugs in the implementation that you then have to design into your new system for it to be compatible. Honestly a full rewrite with a complete API change based on lessons learned from the previous version is the better result. Maybe it's because my time is worthless, but I usually end up doing full rewrites 5 times until I'm moderately happy with the results.

What?

>and the information the function needs can only be in the parameters when you call it.
Okay. So if the function gets the board and the column number, it's pretty straightforward.

> when the parameter of the function already has the number of columns?
Do you mean that the parameters are fixed and don't have the necessary information that I said you needed above?

Ultimately that depends on how the software will be used, if you already have dependents using your APIs and such etc.

I do agree that rewriting your own projects can usually make it better, but rewriting a project you're not already intimately familiar with the conception of is likely to end up as bad or worse.

No actually I just realized my problem actually now that you point it out. Just confused the hell out of myself. Thanks

nested array

google it

>google
botnet

you should recommend a privacy respecting search engine

Where is r?
And why should dval be float, it's a double?

stop using sepples. It's not even real programming language.

>Explain why can't you shouldn't use regex to parse HTML
Proper regex expressions describe linear grammars. HTML has a hierarchical structure, so it can't be described by a linear grammar. What you're referring to as "regex" is a bunch of hacks piled on top of actual regex, many of which can easily lead to exponential running time, especially if you abuse them for stuff like this.

The world4ch SICP redirector link stopped working!

Sup Forums.org/derefer?url=mitpress.mit.edu/sicp/

Can you fix it, Sup Forums ?

probably just a typo

double and float are kinds of floating point numbers.

>mfw my prof is using the building of stuff like Tic Tac Toe and board games in c++ as learning tools

I'm not learning shit, I'm just confused

what shitty book is this

A Reference to const May Refer to an Object That Is Not const

C++ primer. I was bitching about this in the last thread

>A Reference to const May Refer to an Object That Is Not const
Yeah, what's wrong with this?

A Reference to float may refer to an int object

this is incorrect

#include

int main(int argc, char const *argv[]) {

const double d{54.05};
const int &crefd(d);

std::cout

It's crefd is not referring to d. It's referring to the rvalue that results as a result of converting d to an int.

implicit conversion is the source of all cancer

That other guy's code will just convert to 54, but this actually shows a method
#include

int main(int argc, char const *argv[]) {

double d = 59.05;
int *kek = (int*) &d;
const int &crefd = *kek;

std::cout

undefined behavior, use a union fag

As if any C++ compiler on the planet seeing use today would break that code.

Besides, gcc/clang doesn't complain even on -Wall.

>implying unions have well-defined behavior

Will recruiters / companies give a shit if a personal project is canned vs completely original?
example - game boy emulator vs. an original library with several stars on github

please tell me how you would re-implement this in Common Lisp or whatever other slightly obscure lang you main

You could replace the switch statement with a Dictionary, and provide a method for new implementations to register their do_shit().

yeah I know right? a lot of us make fun of front end devs, but they have to put with fucking CSS and Javascript

What books would you recommend to someone who wants to learn C++ and C# well enough to actually become productive ?

Scott Meyers books for C++

This may be controversial, but I always thought the best way to learn a language was to read enough so that you understand the basic concepts and syntax, and then start making things with it / solving programming challenges. Frequently consulting the API, etc...

So I got this program which you put how many multiplication problems you want to do in, then it generates that many random problems for you do to. At the end it tells you how many you got right and how many you got wrong. What I want to do is also include WHAT problems you get wrong. The only way I can think of doing this is passing an array into EasyMultiplier, then filling it via an 'else' statement when it compares the user answers with the correct answers. Problem is, I'm shit at arrays, let alone passing them into methods. Everything I've tried hitherto hasn't compiled correctly. The code is:

import java.util.Scanner;
import java.util.Arrays;
import java.util.Random;

public class Test{

//Main menu of the program
public static void main(String[] args){


Scanner in = new Scanner(System.in);
System.out.print("Enter the amount of problems you wish to do: ");
int amountEA = in.nextInt();
int correct = 0;
correct = EasyMultiplier(amountEA, correct);
int incorrect = amountEA - correct;
System.out.println("You got: " +correct+ " correct!");
System.out.println("You got: " +incorrect+ " incorrect:");

}


public static int EasyMultiplier(int amountEA, int correct){
Scanner in = new Scanner(System.in);
int[]answersEasyMultiplier = new int[amountEA];
int[]usersanswersEasyMultiplier = new int[amountEA];

for(int z=0; z