/dpt/ - Daily Programming Thread

Od thread: What are you working on, Jow Forums?

Attached: 1561867565250.jpg (900x1042, 275K)

Other urls found in this thread:

snoyman.com/blog/2018/10/rust-crash-course-01-kick-the-tires
os.phil-opp.com/
github.com/gelbpunkt
twitter.com/NSFWRedditImage

Object1_X = '0'
Object1_Y = '0'

Object2_X = '1'
Object2_Y = '1'

So I just happen to know as a matter of that from Object1 to Object2, Object2 is 45degrees above Object1. How would I figure this out using Python?

Attached: grid0011.jpg (419x313, 24K)

anime

How do I convert C headers to rust

amine

What are your goto languages for starting new projects? Python fags need not apply.

just check that the difference in x is the same as the difference in y and that object2's coords are greater than object1's

Almost always C.

but how does that equate to 45?

Python.

it will always be 45 if the difference in both x and y between the objects are equal

Terrible.

no u

Do you use Glib/something similar or just write that sort of stuff yourself? Maybe I'm a brainlet but reinventing the wheel seems to be a bit of a problem when starting a new project in C. Particularly with strings.

>What are you working on, Jow Forums?
Learning full stack webdev atm. Am planning on cloning niche websites like zillow/airbnb and market it to some people on nigeria and mongolia.

>glib

Absolutely fucking disgusting

Stay in school and learn basic trigonometry? I forget when you cover this stuff, maybe at 14 or so?

used to be sepples, now it's rust

How do I into rust? I feel like I'm about to go full c++ autism mode

basic trig my dude, the ratio of height to width is used to calculate the slope, which is directly related to the angle from the normal

I used based haskellman's intro
snoyman.com/blog/2018/10/rust-crash-course-01-kick-the-tires

First you buy your programming socks, then you get that book by Klobnik.

Whatever is best suited for the job?

So i am learning openGL and just starting and there is shit like this, how the fuck do you guys remember such shit,i apologize for the awful ss

Attached: 241214124.jpg (662x410, 29K)

Forgot to mention: I'd like to write freestanding programs so if there's docs related to that please link them. I have lots of C experience and some C++

So C++ always

It's just an extra u, you can spell it either color or colour it doesn't matter.

then try this also:
os.phil-opp.com/

>not usign multiple concatenated strings

lmao

>writing shaders as strings

>Glib
Fuck no. I avoid that shit like the plague.

That's what he did. If he must do that then at least do it properly

>inb4 i was only pretending to be retarded

C++ would absolutely be the best language if they made a C++ lite that removed half the shit nobody uses anyway.

They could call it C.

So Go? It's like C but better.

>GC

And a shitty GC at that.

just dont use

Is Hacker's Delight worth the read?
Or there is a library that sums up everything in it.

>What are you working on, Jow Forums?
Just got a first version of a .stl file parser working and I am seeing the correct input. I am excited.

struct STLFacet_t
{
GLfloat normal[3];
GLfloat vertex1[3];
GLfloat vertex2[3];
GLfloat vertex3[3];
};

struct STLSolid_t
{
Uint8 header[80];
std::vector facets;
};

struct internalSTLSolid_t
{
Uint8 header[80];
Uint32 numFacets;
STLFacet_t *facets;
};

// UINT8[80] - Header (must not begin with "solid")
// UINT32 - Number of triangles
// for each triangle
// REAL32[3] - Normal vec3
// REAL32[3] - Vert 1 vec3
// REAL32[3] - Vert 2 vec3
// REAL32[3] - Vert 3 vec3
// UINT16 - Attrib Byte Count (typically zero)
bool ParseSTLBinary(std::string &str, std::vector &solids)
{
Uint32 totalSize = str.size() * sizeof(char);
Uint32 offset = 0;
do {
if (totalSize - offset < sizeof(internalSTLSolid_t)) {
Error("Malformed solid totalsize < headersize");
return false;
}
internalSTLSolid_t *stlHeader = (internalSTLSolid_t *)&str[offset];
STLSolid_t solid;
memcpy(solid.header, stlHeader->header, 80);
offset += sizeof(internalSTLSolid_t);
if (totalSize - offset < sizeof(STLFacet_t)*stlHeader->numFacets) {
Error("Malformed solid totalsize < numtriangles (%lu < %lu) [size: %lu]",
totalSize - offset, sizeof(STLFacet_t)*stlHeader->numFacets, sizeof(STLFacet_t));
return false;
}
STLFacet_t *facets = (STLFacet_t *)&str[offset];
for (int i=0; inumFacets; i++) {
solid.facets.push_back(facets[i]);
Debug("Added facet size: %d", solid.facets.size());
}
solids.push_back(solid);
offset += sizeof(STLFacet_t)*stlHeader->numFacets;
Debug("totalSize-offset = %lu", totalSize-offset);
} while (totalSize - offset > sizeof(STLSolid_t));
return true;
}

Attached: stl_ms_3d_cube.png (1920x1040, 203K)

>library for bitwise ops

the absolute state of the dpt

Amazing user. Please open source it the world needs more competition in the proprietary 3D graphics space

if you say so bud

ITODDLERS BTFO

Attached: 1562031829099.gif (500x491, 376K)

Does Lisp have fmap?

It should be jtoddlers in this thread.

Reading the rust book. Wow, this language is a pleasure to write in. Should've done this sooner. Much better than Go.

Working on a portfolio manager for my peer to peer lending since websites are shit and excel can only take you so far before becoming a bloated monster.

hi please hate github.com/gelbpunkt a little. He is a python fag

>all those oss contributions

You're the faggot here

Had some issues with struct alignment. This beauty of a loop is what works so far. Woot!

Uint32 totalSize = str.size();
Uint32 offset = 0;
#define FACET_SIZE 50
do {
if (totalSize - offset < sizeof(internalSTLSolid_t)) {
Error("Malformed solid totalsize < headersize");
return false;
}
internalSTLSolid_t *stlHeader = (internalSTLSolid_t *)&str[offset];
STLSolid_t solid;
memcpy(solid.header, stlHeader->header, 80);
offset += sizeof(internalSTLSolid_t);
if (totalSize - offset < FACET_SIZE*stlHeader->numFacets) {
Error("Malformed solid totalsize < numtriangles (%lu < %lu) [size: %lu]",
totalSize - offset, FACET_SIZE*stlHeader->numFacets, FACET_SIZE);
return false;
}
STLFacet_t *facets = (STLFacet_t *)&str[offset];
for (int i=0; inumFacets; i++) {
solid.facets.push_back(facets[0]);
Debug("Added facet size: %d", solid.facets.size());
offset += FACET_SIZE;
facets = (STLFacet_t *)&str[offset];
}
solids.push_back(solid);
Debug("totalSize-offset = %lu", totalSize-offset);
} while (totalSize - offset > sizeof(STLSolid_t));

Attached: vertices.png (1903x1002, 162K)

Because we use a system where 360 degrees is a full circle. For anything beyond practical real world measuring you'll want to work with radians instead.

You really shouldn't be learning python if you don't understand basic trigonometry. Math is a fundamental part of programming.

I've written a B-tree in C and I'm having a bit of trouble extending
it to take arbitrary keys/values. Mostly, I'm having trouble with freeing the values whenever a delete occurs. I figure I've got two options: require the
user to provide a free function that's called automatically on deletes, or
just have delete return a pointer to the deleted value and let the user free
it however they want.

Anyone have any advice?

The first sounds more straight forward and less prone to bugs due to hidden logic desu.

I meant the second. Where the caller is required to free any values that are stored in the btree upon deletion, desu

Attached: 1500089046150.gif (320x291, 2.97M)

Copy the user's data into the tree yourself and manage your own memory so the user doesn't have to?

Yes, be consistent. If the rest of your btree functions copy user data then the btree should free it. If the user provided reference is what is kept in the btree, then the user should be responsible for freeing it.

If the guy's a bro he implements both and supports it by providing an option during btree creation.

>browse around on company internal gitlab instance
>find random coworker’s personal repos
>”my-ssh-keys”

Attached: EAFAB56F-7FC6-4AF9-AA36-D670F41F5EFE.jpg (700x700, 87K)

Wouldn't it make more sense to write a b-tree in B?

Is anyone using Magit? I can't figure out how to commit and push to a new remote branch in one go.

Inary ree.

yes
it's not called fmap though

I LOVE SATANIA AND PROGRAM IN NOTEPAD AM I WELCOME TO THIS THREAD ?!

Attached: 51352462.jpg (4000x3000, 2.79M)

Lisp is the most powerful programming language.

yes

god there's nothing I love more than women making faux pas
for such a social creature to make a mistake and be ridiculed and excluded, its exquisite

SHITTANIA BTFO

Attached: nothing-personnel-shittania.gif (480x286, 1.71M)

You're mean spirited.

What's it called?

Why has your coworker put his personal repo on the company gitlab hub?

map

What's the best java IDE? People at uni keep arguing between Eclipse and Intellij for some reason.

>java IDE
indian designated environment?

But doesn't this only work for conventional lists?

Intellij > all.

Intellij has a very competent backend. I use spacemacs with Java LSP, mostly because I love spacemacs and Java LSP is good enough for me

not just lists, but anything that is a proper sequence.

>not just lists, but lists

note the use of the word "proper," so not circular or dotted lists.

So lists and vectors?

If your favorite language doesn't have an official standard, it's shit.

yes, and?

anything that is a proper sequence as defined by the standard, yes

Well that's fucking useless.
What's the point of it being "generic" if it's only generic over two types and it's not extensible?

What is it about programming that makes everyone either an insufferable cunt or a faggot?

if by two types, you mean lists and vectors, those are just two subtypes of sequence. as long as anything is a proper sequence, then it qualifies.

or in your case, both

What are the other sequences?

in haskell map takes a pure function (unlike traverse), and there are many cases like binary trees where no order is required to map

rekt

by default, you get vector and list, but this in itself is extensible. simply define a new subtype of sequence.

i see
so you probably want something like apply, which simply applies a function to its arguments (could be anything)

I think he's just trying to say he likes typeclasses

If it's extensible that's fine. How do you do this?

learn haskell and stop making stupid replies

>mfw passing functions as parameters in clojure coming from a java background

Because it's a topic where it's incredibly easy to pretend you know shit when you actually don't, unlike, say, discussions about physics or math.

android/kotlin question
How to execute many retrofit requests in parallel and wait for all of them to finish?

i already have
if i'm going to use something that is inherently useless, i am going to use lisp