/dpt/ - Daily Programming Thread

What are you pretending to work on, Jow Forums?

Previous thread:

Attached: 7f35e6d1f983a13ec44298026c491ddf.jpg (350x294, 6K)

Other urls found in this thread:

en.wikipedia.org/wiki/Texture_filtering
github.com/vadimdemedes/ink
khronos.org/registry/OpenGL-Refpages/gl4/html/glMapBufferRange.xhtml
hackerrank.com/challenges/max-array-sum/problem
en.m.wikipedia.org/wiki/Data_structure_alignment
twitter.com/SFWRedditVideos

kek

no anime op, shit thread

sekkusu shite

implicit dereferencing in any language with mutability is fucking disgusting and if your language does it then you should be ashamed

making the language babysit you because you cant remember whats a pointer and what isnt is disgusting

explicit > implicit, one character of difference is not boilerplate.

use assembly then if you love being explicit so much
and it's two characters not one

atashi to sekkusu shite kudasai

-> is one character longer than .
* is one character longer than nothing

Is X11 really the Linux equivalent of Windows' Win32 API?

I've made a few programs using the Win32 API and it's something dreadful and extremely outdated, but I got used to it and learned to like it.
Now I want the same nightmarish experience in the Linux environment (I'm porting a few of my programs to Linux), and I don't wanna use any crap like Qt and other bloated 3rd party libraries.

Designing an efficient systems programming language with implicit dereferencing.

pointers were made to point out your micro dick

A memory address is a memory address.

Attached: pdp-11_qt.jpg (800x1000, 127K)

dicklets btfo hahaha

Trying to get my Java program to read from a text file.
I am a novice programmer.

making a piano bot for gmod

So I have a javascript function that calls a JSON API URL, which it does, and then when I log it to console it will print
{"success":true,"message":"LIKE: removed PostID: 5 from your likes"}


so far so good. Then why does trying to print console.log(res.success) print "undefined"?

fetch(Url)
.then(data=>{return data.json()})
.then(res=>{console.log(res.success)})
.then(function(res) {
if (button.classList.contains("typcn-heart-outline")) {
button.classList.remove("typcn-heart-outline");
button.classList.add("typcn-heart-full-outline");
} else {
button.classList.remove("typcn-heart-full-outline");
button.classList.add("typcn-heart-outline");
}
})

Just use wx.

Everything should be written in 6800 assembly.

On a scale from zero to Qt, how much bloat do you think wx is?

my dick is thicker than the c++ standard

Use tk. You just write you want a button in a plain text file and it makes a button. If everyone used tk there would be no problems.

Attached: 300px-Uriel.png (300x225, 51K)

Me on the center top left

Is there anything you are struggling with?

I like you user, we should all strive to be more like you.

Trying to figure out how to do Junit testing from the command line so I can test all my text finding methods.

I really don't want to use an IDE.

I think res.success is the wrong property. try res.ok

Working on improving the look of the column headers in my table view widget. Now with up/down arrows for ascending/descending sort order. :)

Attached: Screenshot at 2019-05-04 18-05-19.png (1920x1080, 997K)

but the key in the JSON is success?

concerning lack of anime in this thraed

Attached: 1486601011322.jpg (1280x720, 156K)

Why are packet header lengths always divisible by 4?

Would the universe collapse into a black hole if i designed a packet header of 3 bytes?

32 bit is a fairly standard data size

It would be awesome if you can make it so that it can apply multiple sorts at once e.g file name ascending THEN created date descending using ctrl+click or similar on column headers
I don't know what this is called but I really needed it some time ago.

I know, but do routers do any optimizations or anything, or can i just have a header of 3 bytes to save 1 byte of space?

>Would the universe collapse into a black hole if i designed a packet header of 3 bytes?
Yes.

concerning lack of javascript in this thraed

good

concerning lack of people being able to spell in this thread

thraed*

I want to write a graphic system that supports high dpi so all drawing functions will take dpi and floating point length as params.
If I choose point as length unit so that 1 unit = 1/72 inch, assuming I only support devices with at least 72 dpi, is it proper to just use integer pixel position calculated with floor(length * dpi / 72)?

Attached: 133428325161.jpg (611x600, 61K)

concerning lack of user who isn't pissy because his life is a mess in this thraed

You need some some of blend function like bilinear filtering to avoid aliasing

give me a comfy SQL IDE, tried DBeaver, buggy as hell.

Attached: 1556129753099.png (2000x1751, 108K)

I went through the documentation and see no solution,
how to I change the "direction" of the axes?

Attached: axis.png (659x729, 112K)

I was preparing to write an addon for firefox that would send urls to streamlink and youtube_dl. And after the recent issue, I gave up that idea altogether.

Attached: 6aee3e1f88ad2a414c116b2e6c0bc12a.jpg (736x1341, 291K)

You can figure out the classpath and run the junit core class against your test classes, but that's more of an academic exercise and kind of a pain when you have more complicated test suites. Most projects would just use some requisite test plugin in Gradle or Maven.

Does it successfully print just res?

What I decide to do is to draw anti-aliased elements directly, like using Wu's algorithm.
I just want to know if it is proper to just treat high dpi drawing as if drawing on a larger pixel buffer with everything scaled up but without considering sub pixel positioning.

Attached: DQ4RItoUMAA9l2h.jpg (1200x1200, 139K)

I think it would still be worthwhile, because converting it to a chrome or brave extension will be trivial to do.

is there a way to delete console output in windows?
somehow the solutions from google don't work for me, nothing is ever deleted
try {
Runtime.getRuntime().exec("cls");
} catch (Exception e) {
System.out.println("lol");
}
System.out.print("\b\b\b\b\b");
System.out.print(String.format("\033[%dA",1));
System.out.print("\033[2K");
System.out.print('\f');
System.out.flush();
none of that works

you're asking about how to downscale an image, basically
what you're suggesting is the equivalent to nearest-neighbor filtering, which doesnt look great for minification
en.wikipedia.org/wiki/Texture_filtering

When I just print res it throws this out so

Attached: fDUFKs8[1].png (465x79, 4K)

Hello rust dev

Never heard of data packing?

Processors are designed to more efficiently handle 2^n sized chunks of data

But I'm not doing any texture mapping here. What I am doing is to calculate the pixel position (say an endpoint of a line is (100.4, 150.8) after multiplying the dpi scale factor), and then I use an existing algorithm that only works on integer pixel positions, so I pass (100, 150) as the parameter to the algorithm. The thing drawn is not scaled at all.

in JS this is just
async function dumbAnon(url) {
const response = await fetch(url);
const { success } = await response.json();
console.log(success);
const classNames = ["typcn-heart-full-outline", "typcn-heart-outline"];
if (button.classList.contains("typcn-heart-outline")) {
classNames.reverse();
}
button.classList.remove(classNames[0]);
button.classList.add(classNames[1]);
}

I dont get it. why doesnt this work? the buffer has proper size, offsets and sizes are correct in the mapping and the flags should be ok. but no valid pointer is returned

uint bufferSize = sizeof(float) * (16 + 2);
glBufferStorage(GL_SHADER_STORAGE_BUFFER, bufferSize * 3, nullptr,
GL_MAP_PERSISTENT_BIT | GL_MAP_WRITE_BIT | GL_CLIENT_STORAGE_BIT);


buffer[0] = reinterpret_cast(glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, bufferSize,
GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_PERSISTENT_BIT));

buffer[1] = reinterpret_cast(glMapBufferRange(GL_SHADER_STORAGE_BUFFER, bufferSize, bufferSize,
GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_PERSISTENT_BIT));

buffer[2] = reinterpret_cast(glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 2* bufferSize, bufferSize,
GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_PERSISTENT_BIT));

Attached: 1543359238986.png (730x666, 359K)

wrong

unless I'm mistaken you are taking one integer grid of pixels and mapping it onto another sized integer grid of pixels which is exactly what texture mapping is
>The thing drawn is not scaled at all.
>after multiplying the dpi scale factor
think about what you're saying

>he doesn't make CLIs with nodejs and react

github.com/vadimdemedes/ink

>Specifies a pointer to data that will be copied into the data store for initialization, or NULL if no data is to be copied.

what are you on about
>A pointer to the beginning of the mapped range is returned

khronos.org/registry/OpenGL-Refpages/gl4/html/glMapBufferRange.xhtml

cuz your microdick it so small it doesnt recognize it as a pointer

You were mistaken of what I said.
Think of drawing line like pic related in MS paint. It takes two end points and line width as parameters and only integer is accepted. No texture mapping here.
What I'm doing is to scale up the length unit, round it to integer, and use that as parameters.

Attached: dpi.png (804x418, 13K)

Honestly it should be the opposite you should only be able to access the memory address if you use an operator on it not the other way around.

That insult was uncalled for, user.

then I dont understand what you're asking
how to rasterize vector graphics?

Is that your actual code, or do you still have the other log in there? I don't know why the log isn't working but this code won't work anyway because this line
.then(res=>{console.log(res.success)})

won't pass res to the next callback, you need to do return res to pass it on.

Jai either might be great or it can be a clustetfuck on par with sepples because of interconnection of all the crazy features it has. Which is it, /dpt/?

nobody knows because nobody has seen it

shit

Basically yes. I just wonder if it is acceptable to just ignore the fraction part of sub pixel position at the end points, since it's easier to implement when the actual drawing code only does on integer positions.

if you are not antialiasing, then round the number (not floor)
if you are antialiasing you need to figure out pixel coverage using geometry

>tfw I solved a dynamic programming problem but it is recursive so it will probably lead to stack overflow

Attached: sir.png (496x244, 25K)

Language "designed" by effectively one guy. Going to be really bad and have a lot of breaking releases in the future probably.

Jesus christ

Attached: 0tsydt6jq8u21.png (950x768, 403K)

>copy the same data a bunch of times
>blame recursion

>Language "designed" by effectively one guy.
most are

Isn't the entire point of dynamic programming that you can use it in a big ass recursive function without it leading to stack overflow?

lol well turns out I still haven't solved it yet FUCK. These are hard.

What is the problem and what is your solution?

oh no no no no

hackerrank.com/challenges/max-array-sum/problem

I tried it with 100 -40 50 43 -50 89 -100 99 and it is giving the wrong result. I fucked up somewhere.

private static (int, int, bool) MaxRec(int[] arr, int start)
{
if (start >= arr.Length)
{
return (0, 0, true);
}

if (start == arr.Length - 1)
{
return (arr[start], 0, false);
}

int max = 0;
int prevMax = 0;
bool canAdd = true;

int i;
for(i = start; i < arr.Length; i++)
{
if (arr[i] > 0)
{
break;
}
}

if (i < arr.Length)
{
(int, int, bool) result = MaxRec(arr, i + 1);
max = result.Item1;
prevMax = result.Item2;
canAdd = result.Item3;

if (canAdd)
{
max = arr[i] + max;
canAdd = i != start;
}
else
{
bool isGreater = arr[i] + prevMax > max;
canAdd = i != start || !isGreater;

int newMax = isGreater ? arr[i] + prevMax : max;
prevMax = max;
max = newMax;
}
}

return (max, prevMax, canAdd);
}

// Complete the maxSubsetSum function below.
static int maxSubsetSum(int[] arr)
{
if (arr == null || arr.Length == 0)
{
throw new ArgumentException( "Array can't be null or empty." );
}

return MaxRec(arr, 0).Item1;
}

Ok bud en.m.wikipedia.org/wiki/Data_structure_alignment

>m

Actually fuck I think I found it.

Forgot to set prevMax when canAdd is true.

Well, I think he has actual team working on it with him. Though, judging by the last stream, he's only now doing compiler intrinsics (while whining that mutexes are literally useless and harmful and if you're not doing everything with CAS loops you're not programming correctly).

enjoy your ruined cache lines

Some architectures either penalize non aligned memory accesses or actually forbid them and throw an exception up your ass.

>aligned
he says chunks, as in packing

Why use ValueTuples if you are not even going to name them?

Okay, you try to access, say, 10th element in that array. You have to determine if this element is on the boundary between words and perform either one or two reads. If you're fine with that - okay (though your branch predictor might not).

I don't know about the particular problem but i'm talking about "Processors are designed to more efficiently handle 2^n sized chunks of data"
which can be very bad for cache latency

I see what you mean I cleaned it up a bit:

It seems to be working now but I'm still not sure if I should remove the recursion.

private static (int r_max, int r_prevMax, bool r_canAdd) MaxRec(int[] arr, int start)
{
int max = arr[arr.Length - 1];
int prevMax = 0;
bool canAdd = false;

int i;
for(i = start; i < arr.Length; i++)
{
if (arr[i] > 0)
{
break;
}
}

if (i < arr.Length)
{
(max, prevMax, canAdd) = MaxRec(arr, i + 1);

if (canAdd)
{
prevMax = max;
max = arr[i] + max;
canAdd = i != start;
}
else
{
bool isGreater = arr[i] + prevMax > max;
canAdd = i != start || !isGreater;

int newMax = isGreater ? arr[i] + prevMax : max;
prevMax = max;
max = newMax;
}
}

return (max, prevMax, canAdd);
}

Lisp is hell

D or Rust?

No

I have graphs like pic related. How do i find the smallest cross section (by smallest i mean least amount of edges) just by looking at the edge count without considering the position of the nodes..

Are there algorithms that can find such necks in graphs? I dont know what to search for.

Attached: meshgraph.jpg (1028x692, 198K)