/dpt/ - Daily Programming Thread

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

Attached: desktop_rob_malda.png (1024x768, 390K)

Other urls found in this thread:

en.wikipedia.org/wiki/Data-oriented_design
github.com/bloc97/Anime4K
github.com/nagadomi/waifu2x
stackoverflow.com/questions/6916805/why-does-a-base64-encoded-string-have-an-sign-at-the-end
twitter.com/SFWRedditImages

Roguelike.
As a Ctard someone help me on the reasoning of when I should use classes or not. When should I go beyond just arrays of structs or structs of arrays and separate methods operating on them

You'll know of you need them. Don't have them just to have them.

Ignoring the messed up formatting, is this a stupid idea, /dpt/?
And is it clear what's going on?

Attached: comp.png (400x420, 23K)

wut

Can you call glVertexAttribPointer multiple times for the same vertex buffer?

Reposting from previous thread.

Working on a series of blog posts explaining how to write a compiler for a functional language in C++. Using C++ because that's what I originally had to use (the first version was for a class project).

Might be using some non-standard notation in the draft (pic related). Will have to double check with a textbook.

Attached: 2019-08-13-225317_3840x2160_scrot.png (3840x2160, 355K)

The difference between the top and bottom post.

No I am saying I literally dont.
Is it when you require some complicated intialization of your data?

faust language is amazing

Help
//Screen.h

#include "Window_mgr.h"

class Screen{
public:
typedef std::string::size_type pos;
friend void window_mgr::clear(ScreenIndex);
.
.
.


//Windows_mgr.h

class window_mgr{
public:
using ScreenIndex = std::vector::size_type;
void clear(ScreenIndex);
private:
std::vector screens{Screen(24,80,' ')}; //invalid use of incomplete type screen

};

void window_mgr::clear(ScreenIndex i) {
Screen& s = screens[i];
s.contents=std::string(s.height*s.width,' '); // member acces into incomplete type screen
}

>friend
God I wish that were me

yes. that's what you do when the data from multiple vertex attributes is interleaved in the same buffer

sup fags. trying to design a system for generating email aliases. looking for some input.

i maintain two mailboxes, [email protected] and [email protected], each used by different people. I only want to give these addresses out to real people, not services. i want to use an alias for each service i use, eg: [email protected]. Plus addressing is trivial to strip, so i can't use that. In fact, I don't want 'bob' or 'alice' to be in the alias at all. However, i do need the generated aliases to be tied to the real address in some way, in order to prevent collisions. I also don't want to have to manually add the alias to my mail system every time i generate one, so I need to use a regex-based catchall.

lot of variables here. currently i'm thinking of using some sort of cipher, but i need to be able to determine who the alias "belongs" to, and i'm not sure how to go about that

[email protected]

Very simple program to change the screen brightness via systray. Currently it does the actual changing by calling xbacklight and sends a notification with notify-send.
I'm definitely changing the notifications to be integrated into the program, since that seems easy, but the code necessary to chamge the brightness seems a bit too complicated for me.

You can't spell trust without Rust.

DOXXED

Working on my depression over my lack of soft skills (ie. communication with coworkers). It really fucks with my work. Are there any tips or success stories to learn from? My code's good, but I keep fucking up at work.

how can you fuck up at work if your code is good.

i don't believe you

instead of using classes like a normal human bean, i just use arrays

for example instead of a "player" class with attributes hp and attack, i make 3 arrays, one holding the player id, the other holding the i-th player's hp in the i-th index, etc

am i retarded or redpilled?

Redpilled: en.wikipedia.org/wiki/Data-oriented_design

Mis-communication. I misinterpret requirements, never quite know when to ask for feedback, have a hard time expressing my views without coming across as pushy etc. When I said I fuck up, I didn't mean that my code is crashing the software, but that I keep having difficulties at work with stuff like that.

retarded. Why not have the player id as the index?

okay, i'm seriously freaking out. my internet connection is solid as a rock, until i post on Jow Forums. then after i post i start dropping packets for a little while? then it comes back

what the fuck

Your government hates free speech websites.

same thing, point is just using arrays for what one would normally use classes

lol didnt know about this, i was just bored of learning OOP syntax in some language i was just starting to use

>4cuck
>free speech
screaming maga and niggers like a juvenile baboon doesn't mean you are practicing free speech

Why is clear() not a method in Screen?

I was actually thinking of stuff like Jow Forums discussions, which is also part of Jow Forums.

based baboonposter

kek

And everyone knows trust is a shit brand.

>Jow Forums discussion
>not screaming maga and nigggers like a juvenile baboon

Attached: 1565344156822.jpg (640x640, 174K)

what radix covers 0-9 and a-z (case insensitive)

It actually does.

base36 you fucking moron.

The only way you'll really know is through experience, because it's a matter of preference
You could program your entire project without using a class

How did these DEFCON people get their jobs?

twitter, for real

Lisp is the most powerful programming language.

are they cool or fags

You could use XOR for this:

bobbob XOR amazon = [email protected]
bobb XOR ebay = [email protected]

But there's no guarantee your users won't generate collisions.

twitter, for real

are they cool or fags

How do I automate everything I do?

twitter, for fags

are they cool or real

are they cool or real?

Cool

threadly reminder that reals don't exist

Writea program that eats a shitton of resources,sleeps most of the time and jerks itself of the rest of the time. It never spawns any children and exits after 35 years.

fags, for real

God is real, unless declared integer.

Attached: 1565830751008s.jpg (200x200, 6K)

twitter is for real cool fags

Attached: pepedistorted.jpg (639x582, 48K)

fuck off dumb frogposter
don't @ me every again

>don't @ every again
back to twitter, fag esl
it's called (you) and the correct enligish is ever again

>correct enligish

Attached: laughs1.jpg (238x212, 12K)

Imagine thinking you were doing a simple string reverse. This is with opt-level=3 of course, without is in the thousands.

Attached: file.png (1530x1216, 211K)

i started reading a book on clojure earlier, got a bit excited and wrote up most of a connect 4 game in the REPL. i don't want to lose what i did already, the win check took me a while. is there any way i can get that shit outta there?

copy and paste?

my terminal scrollback only goes so far

why the fuck does it have so many lines

oh, you did this entirely in the repl?

yeah because i'm a retard

i don't think there is a way to do that in clojure. i know there is a way to do that in common lisp though.

that sucks. well i just noticed i still have the win check in my scrollback, i guess the rest won't take too long to rewrite. thanks.

you can't spell CVE without C

I've been trying to teach myself Python on SoloLearn recently. Any other good sources out there for learning Python? I heard it was a good programming language for cyber security professionals, can anyone confirm?

Practical Common Lisp
programming is a meme

I'm gonna go learn C++ from pre 2000 resources, wish me luck

So what you are admitting is that classes are not needed at all?

Automate the boring stuff with python, you can read it for free online. The first past is a basic of the language, which after you finish it you can move to more specific books about cyber security.

sounds like a waste of time
why not read something newer

Which books do you suggest?

Practical Common Lisp? Should I read this book online, what will it teach me? Never heard of this language

The most powerful programming language is Lisp. If you don't know Lisp (or its variant, Scheme), you don't appreciate what a powerful language is. Once you learn Lisp you will see what is missing in most other languages.>

the future is now

github.com/bloc97/Anime4K

all the newer ones are shit
seems like nobody wants to make an effort on making a decent modern c++ book, other than a few specialized ones that focus on a specific topics

I'm the one who wrote the code in the previous thread. The solution is defective. Here's the proper solution:
use unicode_segmentation::UnicodeSegmentation;

pub fn rev(s: &'static str) -> String {
s.graphemes(true).rev().flat_map(|g| g.chars()).collect()
}


fn main() {
let word = "mañana mañana";
println!("{}", word);
println!("{}", rev(word));
}

mañana mañana
anañam anañam

now lets see what it looks like with a highly detailed action sequence.

Wrong.

For cyber security? It isn't my field of interest but I've heard that black hat python and grey hat python are good for this purpose.

github.com/nagadomi/waifu2x

Wrong.

I only program in pointed hat scheme

Attached: 1565325731696.png (476x409, 404K)

thank you brother

Been working through an x86 32bit linux assembly textbook and am stuck on this causing a segfault.
Not homework, doing this for myself. Any know what's up here?
.section .data
data_items:
.long 3, 67, 34, 222, 45, 75, 54, 34, 44, 33, 22, 11, 66, 0

.section .text

.globl _start
.globl maximum

_start:

pushl data_items # addres of first item used as argument
call maximum
addl $4, %esp # get rid of argument

movl $1, %eax
int $0x80

.type maximum, @function
maximum: # return value is stored in %ebx
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %edx # %edx now holds address to list

movl (%edx), %eax # move first value to %eax
movl %eax, %ebx # maximum goes into %ebx

start_loop:
cmpl $0, %eax # end loop if current item is 0
je loop_exit
addl $4, %edx # increment pointer to point to next item
movl (%edx), %eax # move current value to %eax
cmpl %ebx, %eax # is current value lesser than max?
jle start_loop # repeat until 0 value

movl %eax, %ebx # if not update maximum
jmp start_loop # repeat until 0 value

loop_exit:
movl %ebp, %esp # restore stack frame and return
popl %ebp
ret

Strings are not array of 8 bit chars, retard boomer. It's far more complicated than you think.

Go ahead, post your solution before wanking over ASM line count as if it matters in real life.
Seethe.

>if we just put twice as many pixels it's twice as much detail
>ok but what if we put 4 times as many???

Literally just buy a monitor with a "sharpness" setting and you'll see making things sharper isn't even good most the time, everything looks fucked overall but when you zoom in it looks a little better on specific small parts.

>want to read books
>takes me over a month to go through 200 pages (and a few exercises)
help

Attached: 1536755458072.jpg (283x438, 18K)

What are those icons called?

found the issue. pushl data_items actually accesses the value at data_items[0]. correct would be pushl $data_items

It's shit like this that makes me think, programming took a wrong turn somewhere... I don't know where though.

Attached: chinkbased.jpg (407x405, 37K)

C was an unironic mistake.

I don't want tell you what the solution is (in case this is homework), but you are using the wrong addressing mode.
Treat that you pass into the function as an array and use the applicable addressing more for that.

If you're learning it thoroughly then you're fine. If after that month you still don't understand what you've just read then you're simply not interested enough to learn it.

>a month to go through 200 pages and a few exercises
are you 98 years old? have you only months to live?
now that you're done with those 200 pages and those exercises, do another 200.

the string PHP is invalid base64 because it's 16 bits long and base64 strings must be multiples of 3

this doesnt make sense to me, someone explain

the string "PHP" is 24 bits long, which is a multiple of 3. You're probably wanting to know about trailing = in base64.
stackoverflow.com/questions/6916805/why-does-a-base64-encoded-string-have-an-sign-at-the-end

hey thanks. is this particular to base64 or do other radices have similar quirks? something like hex should just be a straight 1 to 1 mapping right? when does it start getting hairy? base32? 36?