/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

forum.dlang.org/thread/[email protected]
chortle.ccsu.edu/vectorlessons/vectorindex.html
u.nya.is/pxzvbu.tar.gz
glfw.org/documentation.html
better-dpt-roll.github.io/
twitter.com/AnonBabble

Thank you for using a desu image

Trying to get a grip on Java after years of deep C++ and C.

What the fuck does static do in simple terms?

What the fuck is a super class? What does extends do? What is Override?

Jesus Christ Oracle. What the fuck

static stuff lives in global scope

dmd backend has been converted to the Boost License
forum.dlang.org/thread/[email protected]

a public static method is basically a global function

reposting from previous thread
#include
#include
#include
#include

#define AMOUNT_OF_STUFF 40

//Learned my lesson! No more easy flags
/*void win(){
system("/bin/cat ./flag.txt");
}*/


void vuln(){
char * stuff = (char *)mmap(NULL, AMOUNT_OF_STUFF, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
if(stuff == MAP_FAILED){
printf("Failed to get space. Please talk to admin\n");
exit(0);
}
printf("Give me %d bytes:\n", AMOUNT_OF_STUFF);
fflush(stdout);
int len = read(STDIN_FILENO, stuff, AMOUNT_OF_STUFF);
if(len == 0){
printf("You didn't give me anything :(");
exit(0);
}
void (*func)() = (void (*)())stuff;
func();
}

int main(int argc, char*argv[]){
printf("My mother told me to never accept things from strangers\n");
printf("How bad could running a couple bytes be though?\n");
fflush(stdout);
vuln();
return 0;
}


do i need to write the machine code for system("/bin/cat ./flag.txt"); and then pass it to the port running this program?

I want to learn graphics programming. I already know some C. Not too deep, but I can work my way through its features.

I've made the same question in the last DPT but I have received only a vague answer.

Where do I start? I hear I'll have to learn linear algebra and stuff. Is there any book that walks through it all, or any interesting material that I would find useful for that end?

I wanted to make a stock trading game until I realized real-time stock information costs a small fortune. So now I'm thinking on using an alternative data set as stock information. My current plan is to make a script that runs on a set interval which counts the occurrences of words on Sup Forums. An alternative idea is to calculate the popularity of the current airing anime by counting the amount of times its mentioned on Sup Forums. Any other suggestions?

static means it is the same for all instances of the class

isn't scraping against the tos?

somehow i learned this by reading K&R and i have no idea why that was in there. it was the first time i understood what static meant. mental since c's the furthest away from poo you can get

hey guys, I could use some help with this template thing. I have a vector2 type that looks somewhat like this:
template struct vector2
{
using V [[gnu::vector_size(2 * sizeof(T))]] = T;
union
{
V v;
struct { T x, y; };
};

template constexpr auto promoted() const noexcept
{
return vector2 { *this };
}

template constexpr vector2& operator*=(const U& rhs) noexcept
{
auto lhs = promoted();
lhs.v *= vector2{ rhs, rhs }.promoted().v;
return *this = lhs;
}

/* all other functions omitted */
};

for some reason the promoted() function fails here. it's supposed to ensure both operands are the same type. I use it in many other functions and operators where it works just fine, but not here.
error: invalid operands to binary * (have 'vector2::V {aka __vector(2) float}' and 'vector2::V {aka __vector(2) int}')

any ideas why this is happening?

You need to pass the correct file descriptor to mmap, right now you're passing stdout to it.

I won't scrape, I'll use the API.

Here is KRC classic "detab" problem.
Wrote this in fucking 10 lines. Those sjw stack overflow cuckders gave me 20+ line of codes.
#include
int main(){
int c;
while( (c = getchar()) != EOF){
if( c == '\t')
while((c=getchar()) == '\t' && c!=EOF)
putchar(' ');
putchar(c);
}
}

oooh wait nevermind. I'm stupid.

i can't alter this code at all to clarify, can you explain to me a bit more what you mean? what exactly is the code doing? i thought it was reading in some arbitrary bytes of data and then executing them

this just replaces tab characters with a space character, make it take an argument that's the tab width and replace tabs with that number of spaces lad

holy fuck you are using all of c++11 features.
I have never used
>template
>decltype
>auto
>constexpr

I have a few links though I haven't worked through them myself.

You need a good understanding of matrices and vectors.
chortle.ccsu.edu/vectorlessons/vectorindex.html

I've heard good things about Computer Graphics - Principle and Practice.
u.nya.is/pxzvbu.tar.gz
Here's some textbooks on the subject, I just hoard things and don't look at them. There's some OpenGL stuff as well.

Static applied to a method means that you can use the method without an object instance of the class.

So for example, String.format(fmt, ...) is static.
You call it using the class name, followed by a dot and the method name e.g:

String exampleStr = "World";
String example = String.format("Hello %s!", exampleStr);


If String.format wasn't static, you'd have to create an explicit string and call the method on it e.g:

String exampleFmt = "Hello %s!";
String exampleStr = "World";
String exampleFull = exampleFmt.format("World");


Sometimes using non-static calls actually makes the code easier to read, but usually static system calls or core utils are better kept static.

I didn't understand.
>make it take an argument that's the tab width?
what is tab width

>never used template

nigga how

have you never written a data structure

do you make every single program type specific

For now just get familiar with the API.
glfw.org/documentation.html

Later on there are two bibles you should read, first is "Computer graphics: C version," second is "Real time rendering" by Tomas Akenine-Moller.

Tried to recreate but it looks like Wolfram's Pokemon indices don't go by Pokedex number in some of the later generations.

Ghost is streaming right now

> after years of deep C++
nigga all the things you just asked about are in C++ too

In my line of work. I just maintain code. never made anything for myself.

Where?

Tab width is the number of spaces that constitute one tab.
Default is usually 4. But some cancer webdev shits use 2.

you're misunderstanding what tabs are, tabs (in unix at least, idk about windows) are just a single character '\t'. in text editors you can change your tab width, so a tab can be four spaces, 2 spaces, 8 spaces, whatever. in the text document, though, it's all just represented by a single '\t'. are you reading the book or just doing the exercises?

Also, don't read latest Graphics principles and practice. The older version has C implementation which is better.The newer version has fucking C# implementation using WPF.

True Capitalist Radio

Anton's OpenGL.
Only this book is needed to start from basic.

how is it called that system characteristic that do not shit itself, when there are for example 10000 users at the same time?

scalability?

Did you even read what I posted?
I uploaded the C version of that book.

this dude on my software engineering class project team uses a single space as a tab. he did work exclusively on the front end, just copy and pasting stuff he finds online, so of course he has a load of LOC on our github. he told the professor today he did 80% of the project. literally nothing he made interacted with any backend whatsoever, no buttons had any functionality

Reading and doing exercise.
In chapter 5 now. But there is problem in chapter 5 that asked to redo chapter 1 detab and entab.
I forgot how I did chapter 1 previously. It was 1 and 1/2 months ago.
I still haven't understood the problem.
I understand replace tabs with "blanks".
So 2 tabs get replaced with 2 space which is a blank.
What exactly is the question asking?

yes

yes but largely ignored

thank you people. Will look into it right now.

unsigned long long main(unsigned long long argc, *argv[9223372036854775807])
{
for(unsigned long long long = 1; long != 0; long++) {
printf("the ride never ends :^)\n")
}
return 1;
}

>Whenever I see link in Sup Forums i ignore the post
how do i know you are not nsa who wants to inject virus into my computer nigger

Does "Load balancing" have a single word with the same meaning?

long is a reserved keyword
you give smart anime posters a bad name

somehow I know this post isn't a joke and you really are fucked in the head from all the botnet memes

Does he wear thick glasses and dyes his hair blue?
Pls describe him i want to related to a smilar guy I know in office.

>smart
>anime posters
what did he mean by this?

not really

%s/l/d

>smart anime posters

>strcmp for hash function

i tutor students who learn C#. is monodevelop good enough to build projects with high school students? i wan't to completely get rid of windows so no more visual studio for me.

BANNED

yes.

Is this correct?
is everyone getting to do the captcha twice? annoying

>I just hoard things and don't look up
What is your life?
I was wondering how I did good in college, got job in MNC company. And how I am about to finally start my own company.
Is this because most people are very lazy to actually learn and read technical books?

he's mexican

the file should look exactly the same before and after

Maybe you just had everything handed to you.

Does anyone know how to easily access my non-OS drive for terminal display in a PowerShell script? Microsoft's documentation is fucking garbage

Let me guess
>Loan Debt
>weed
>friendship
>Television
I avoided above things.

not everyone got a free ride from daddy, you friendless neet

I bet you're gonna make some remark about me projecting, but you're making yourself out to be a clueless brat.

include\c++\bits\stl_algobase.h(224,7): error : could not convert '#'vec_cond_expr' not supported by dump_expr#' from '__vector(2) int' to 'bool'

oh wow gcc that is very helpful.

I'm a professional C#/.NET dev and I use mono at home on Ubuntu. Works great. Nothing you'd want to try and deal with for professional work, but way more than you need for personal projects and tutoring. iirc. most classrooms teaching with C# these days use mono

: e.g
e:

can someone post the dpt project github?

???

yes for the project roulette

better-dpt-roll.github.io/

beginning to learn Vulkan
seems nicer than openGL, but theres still so much fucking housekeeping before anything can be drawn

>correct file descriptor
mmap doesn't need (and ignores) a file descriptor with MAP_ANONYMOUS

>but theres still so much fucking housekeeping before anything can be drawn
Am I the only one who enjoys writing boilerplate?

hello CRUD monkey

>Sup Forums thread quality analyzer
System.out.println("dogshit")

but Conway's Game of Life looks interesting. always wanted to something with emulating evolution

Here

Present

in case you happen to see this, I've gone into this territory before and what I did was to create an account with a bank that was easy for me to get API access... I used Trade King iirc and was able to set up a dev account easily after I created a brokerage account and was able to use their API which provided real time quotes.
I do not remember if there were limitations like only X amount of API calls / $time_period, but it's a feasible avenue for this kind of thing.

If you are not familiar with brokerage accounts don't worry, you can open one pretty easily and get approved for just stock trading (all you need for API access) and you don't ever have to use it or put money in it. I opened the Trade King account solely to get API access and never once put money in it or traded with it - I actually have like 3 other brokerage accounts that I trade out of

Is there an alternative to > and >> in batch to dump the console output in a file? not necessarily during the execution.
If it could dump after the previous command is completed, it would be good enough for what I'm doing.

What language should I use to do all of my computation at compile time?

>tfw your cohort at work writes shit-tier code

I don't know what else to say

If Haskell was competent it would have type level lambdas restricted to patterns. Higher order pattern unification is decidable and it would make newtype gymnastics (Flip, Compose, etc.) unnecessary.

Who said this?

>tar.gz

what the hell is this

It's Turing complete, of course it is and will forever remain incompetent.

C++

gzipped tarball

I said language, not "language".

*this;

C++ question regarding virtual inheritance.

class Base
{
std::map whatever;
}

class DerivedOne : public virtual Base
{
DerivedOne()
{
whatever["wall"]=1;
}
}

class DerivedTwo : public virtual Base
{
DerivedTwo()
{
whatever["blah"]=6;
}
}


If I inherit from one of these derived classes, everything works fine, but if I inherit from both, their default constructors are called but they don't insert those values into the map they share. I'm not really looking for a fix, I'm just curious why that is.

I don't understand why we make the distinction between compiling and assembling.
>Assembly language
Each line of the program is "assembled" into one line of code.
>High level language
So something like C has more abstractions, but just because it's not line-for-line, we call it compiling?

It was strlen.

@59787392
>POO
>inheritance

>Each line of the program is "assembled" into one line of code.
Meant to say one line of machine code.
Either way, I don't see the difference because in the end it all ends up as machine code.

>we
Speak for yourself.

I see you're still at it, user-kun.

>>Assembly language
>>High level language
Whom'st've're't'll said this?

Can you repeat the question?

W-What question?

YOU'RE NOT THE BOSS OF ME NOOOWWWW

Why would you want to know that?