/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1527874297391.png (1700x1374, 1.1M)

Other urls found in this thread:

marktarver.com/bipolar.html
github.com/awesomekling/serenity
en.cppreference.com/w/c/io/fscanf
twitter.com/NSFWRedditVideo

I support this thread over the other because it has anime girls

Attached: Miyamizu_Mitsuha_On_Ownership_And_Borrowing.jpg (1920x1080, 314K)

I however do not

Attached: 1551611344884.png (1048x567, 780K)

stupid frogposter

I pick this thread because it has animu grils instead of Jow Forumsshit.

>What are you working on, Jow Forums?
I'm doing a shitload of refactoring in my wayland compositor library.

Attached: 1354789686022.jpg (1311x1784, 626K)

I'm falling behind

Attached: 2f7.jpg (601x508, 31K)

I don't know why you come to these threads seeking sympathy, and not even give any details about any legitimate issue you're having.

Attached: 1550385410152.png (199x220, 18K)

do you use upper or lower case for hex numbers?

I'm really inconsistent about it. I can think of at least 3 times where I've flipped back and forth about my preference to which one I like more.
It's lower-case at the moment.

#
marktarver.com/bipolar.html

read this

Numbers have no upper/lower case and hex (base 6) doesn't even have any alphabet symbols if that is what you mean.

He means 16 not 6

(defn g
([x & moar] (+ (first moar) x) )
)


How do I get all elements in the list instead of just the first one to add up to x?

Attached: 1451055561880.jpg (720x720, 50K)

>base 6
you mean Senary?

I have taken the courtesy to bump this shit thread. Now, please reciprocate and move over to the real thread

Fuck off. Nobody wants your Jow Forums shit.

Attached: 1496114727751.jpg (400x562, 33K)

Fuck off

Stupid Akari Poster.

Trying to figure out how the fuck the PSP gets game code from an ISO without having to manually trace it back through the emulators compiler. All I need to do is change two instructions but I can't for the life of me figure out where the fuck those instructions are actually stored on "disk".

Attached: hLLG58s.jpg (900x520, 109K)

JavaScript rocks!

Attached: js-rocks.png (1000x494, 368K)

I started working on a GUI text editor for my operating system. I didn't have any kind of multi-line text widget, so I'm implementing a reusable component for that.

Attached: Screenshot at 2019-03-07 01-51-21.png (1920x1080, 670K)

You never took it seriously until what? I want to read your story.

*adds word-wrap to TODO list*

The full text says "I always wanted to write my own operating system, but I never took it seriously. Until now."

ayy

I actually just wrote my own terminal text editor. It was surprisingly easy.

Cool :) Did you find anything particularly challenging?

Honestly, not really. I'd say efficiently highlighting syntax if I had to pick something. Multiple buffers, tabs, and splits were all things I expected to be a pain but were trivial.

Makes sense. How did you end up implementing syntax highlighting?

I don't have code samples handy at the moment, but check out something like kilo. I did something pretty similar.

Mind sharing your OS? I'm curious to see some code.

github.com/awesomekling/serenity
have a look :)

I have a heart attack every time I open a PR. What if they bully me? I don't wanna get bullied.

Attached: asfrt3w4etfg.jpg (1280x720, 101K)

Just bully them back harder.

Attached: 1548359373838.jpg (1920x1080, 263K)

Do it enough times and you'll eventually feel nothing.
And if you get rejected, eventually you'll just go "meh" and just move on.

make sure you use the weebest fucking avatar possible. you'll have so much cred nobody will dare bully you

Attached: 1551551943878.png (288x218, 121K)

This. The best contributions unironically come from weebs.

Attached: 1544991463520.jpg (330x560, 118K)

How does one even get started on something like this? I only have a bachelors in CS and my OS class was pretty garbage.

Attached: 1530108480870.png (846x720, 330K)

Thank you for supporting this thread, I agree that non-animes /dpt/s are improper.

Attached: 1551627134428.jpg (880x667, 105K)

I had some free time and just decided to get started. I never took any OS classes or anything like that, so I'm just figuring this out as I go.

int main(){
return 0;
}

Shit.
int main()
{
return 0;
}

Shit.
int main() {
return 0;
}

Perfection.

NOTHING
help me Jow Forums
i got out of college and went for a brainless it janitor job in colorado so i could ski all day, but i'm bored to tears and realized my coding skills are now totally dusty after 2 years.

WHAT SHOULD I BUILD? TELL ME PLEASE

Attached: 8POjqLy_d.jpg (640x361, 16K)

idk, what are you into?
you could make your own basic OS, or your own embedded firmware, or your own new webstack, idfk.

you can do nothing
this is the abyss

I knew someone who got a Bachelors in CE. All he had to do was be part of a team project, and he did memory paging. The others didn't do their part and the project wasn't completed.

int
main (void)
{
return 1;
}

Shitty app where that controls movement sensors you install in your house.

shader of brownian motion dicks. when dicks touch, print "no homo" to the console.

A project for work -- writing an ass-backwards ""workflow engine"" that, instead of running/managing tasks, just collects state updates from already-running tools and validates the resulting FSMs

in English doc

why do people keep inventing projects?

does your company even need that?

hey guys do you help with dumb noob programming questions or no?
I have this while loop that's supposed to end when the user inputs "stop" but it's not stopping

Scanner scanner = new Scanner(System.in);
String name = "";
String id = "";
ArrayList members = new ArrayList();

while(!name.toLowerCase().equals("stop") && !id.toLowerCase().equals("stop")) {
System.out.println("Enter the next name:");
name = scanner.nextLine();
System.out.println("Enter the next ID:");
id = scanner.nextLine();
TeamMember TeamMember = new TeamMember(name, id);
members.add(TeamMember.toString());
}

while(true) {
System.out.println("Enter the next name:");
name = scanner.nextLine();
System.out.println("Enter the next ID:");
id = scanner.nextLine();

if (name.toLowerCase().equals("stop") && id.toLowerCase().equals("stop"))
return;

TeamMember TeamMember = new TeamMember(name, id);
members.add(TeamMember.toString());
}

now it says the code after it is unreachable

nah

notice that i removed the !! you added there

i added
if (name.toLowerCase().equals("stop") && id.toLowerCase().equals("stop"))
return;

you had
!name.toLowerCase().equals("stop") && !id.toLowerCase().equals("stop")


notice the !

it works on my machine

Enter the next name:
john
Enter the next ID:
123
Enter the next name:
marie
Enter the next ID:
111111
Enter the next name:
stop
Enter the next ID:
stop

yeah that part works but I have stuff after it that it needs to get to after the loop is done
also I think it should be || in that case since I only need one of the variables to be "stop" to end it

Attached: Capture.png (654x314, 20K)

prove that you are homosexual by answering this

why is this wrong?
`maxmin([X|L], Max, Min) :-
maxmin(L, X, X, Max, Min),
!.

maxmin([], CurrentMax, CurrentMin, Max, Min) :-
Max is CurrentMax,
Min is CurrentMin,
!.

maxmin([X|L], CurrentMax, CurrentMin, Max, Min) :-
CurrentMax2 is max(X, CurrentMax),
CurrentMin2 is min(X, CurrentMin),
maxmin(L, CurrentMax2, CurrentMin2, Max, Min).
`

its prolog

But I'm straight user.

Attached: 61d52a1397f3dafef42f1d0856c4f6638d37f683813e53d6b5640ed47bd57b4c.jpg (800x600, 365K)

>using an empty return
>not using break
yikes

ah this fixed it, thank you anons.

why are you here then??

really? nice, im a motherfucking genius

>yikes
he didn't even posted the whole code in the first reply
retard
are we supposed to guess

what a coincidence
I am writing an ass-forwards workflow engine that does exactly what you expect it to do

Does Java strip trailing newlines? The string might actually be "stop\n", which isn't going to be equal to "stop".
I could be wrong, though.

>nextline
>gives you a `\n` for no reason
come on now

Many languages actually do that.

Is PHP the only programming/scripting language that starts from "blank state" each time a request is made to the server? Every other language just has an ongoing process running on the server waiting for requests, right?

Currently learning python, html/css/js, c++ on my own, maybe postgrSQL. And plan on talking cs50x for a basic intro to algorithms and data structures + self study books for rest.

Is Python, c++, and JavaScript an ok start, or is there something else I should focus on? I picked C++ and Python side they seem to work well together. JavaScript because lolweb.

My end goal is basically have the theoretical knowledge of a CS major. I don't have time to go to school due to my day job, but I'm still really interested in the field.

Yes, but it's really specific to our tools. They output data that affects hundreds of technical teams across the company: everything from their roadmaps to their performance reviews. So the ability to validate, record, and report the steps we took to produce our results is invaluable

Your retort really fell off at the end there bud

Fuck off ESL

Fuck off.

>when a cute anime girl forks your repo and sends you a pull request that same day

Attached: comfy.png (376x328, 167K)

>when a random chinese guy forks your repo for no apparent reason

Attached: 1551381513686.gif (379x440, 140K)

>letting random people you don't know fork you

Attached: 1548997722775.jpg (503x503, 213K)

Hi friends. Learning C here, plz no bully.
I'm getting a segfault but I'm not entirely sure why.

#include
#include


void write_func(char *data, char *fname) {
FILE *fp;
fp = fopen(fname, "w");
fprintf(fp, data);
fclose(fp);
}


int main() {
char *file_title;
char *to_write;
printf("Enter file title: ");
scanf("%s", file_title);
printf("Enter data: ");
scanf("%s", to_write);

write_func(file_title, to_write);
return 0;
}

Allocate some static memory

char * file_title [\code] should be char file[69] [\code] or something

fuck a tag but you get what I mean

thanks boss, what about dynamically allocating memory using malloc to write large files? What's the best way of going about that?

but I was serious

>mfw that nsa repo got forked 400 times by total strangers

Attached: 1536535785575.jpg (1440x810, 106K)

well, then im just an asshole and im sorry and you should probably check out one of the 985272938756 open source workflow engines (´・ω・`)

you can just use arrays to store the strings
char file_title[128];
char to_write[128];

you also have your func parameters swapped btw

derp thanks.

Although this breaks for some reason if there are spaces in the strings. Why is that exactly? I thought they would end with a null terminator?

forgot to post code
#include
#include

#define T_BUFF 64
#define D_BUFF 1024


void write_func(char *data, char *fname) {
FILE *fp;
fp = fopen(fname, "w");
fprintf(fp, data);
fclose(fp);
}


int main() {

char file_title[T_BUFF];
char to_write[D_BUFF];

printf("Enter file title: ");
scanf("%s", file_title);

printf("Enter data: ");
scanf("%s", to_write);

write_func(to_write, file_title);

return 0;
}

Using simply standard C, it can kind of be a pain in the ass, because there isn't really a way to know the length ahead of time.
Using some nifty POSIX C stuff though, it's trivial.
#include
#include

void write_func(char *fname, char *data) {
FILE *fp;
fp = fopen(fname, "w");
// Don't use a user-supplied string as the format.
// It's a security risk, because they could do %n.
fprintf(fp, "%s", data);
fclose(fp);
}

int main() {
char *file_title;
char *to_write;
printf("Enter file title: ");
// Without the newline, this is not guranteed to print
// instantly. Use fflush to make sure.
fflush(stdout);
// The 'm' is a POSIX extension for "allocate it for me"
scanf("%ms", &file_title);

printf("Enter data: ");
fflush(stdout);
scanf("%ms", &to_write);

write_func(file_title, to_write);

free(file_title);
free(to_write);
return 0;
}

The %s token in scanf() stops reading when it reaches whitespace
en.cppreference.com/w/c/io/fscanf
you would normally use something else like a loop to read input until EOF

this isn't really working, see

scanf's %s only reads until the next whitespace characters. It's not really the best function for dealing with input line by line.

Today I will work on leetcode

Want to be leetcode buddy?

Might be kinda /v/, but it involves programming so i'm posting here.
How hard honestly is it to do one of those 'MMO fan revivals'? You know the ones. Like when people make WoW private servers for old releases of the game, or the community-run versions of Dark Age of Camelot or Matrix Online. How much of an undertaking is that to pull off?

There is this really interesting now-dead game called KwonHo, which is basically just a 3D fighting game type of thing. How hard would you estimate it would be to bring it online again?

Attached: yinyangemoji.png (420x420, 260K)

Finite State Machine. Instead of going through each step discretely, it probably just verifies that x 'milestones' were hit and if the result was correct or not. Probably designed around minimal test coverages, except you just dump in a bunch of test cases and assume if X->Y->Z outputs a correct answer, then XYZ must be working. So much easier than testing if X works, if Y works, if Z works, usually because Y and Z are context dependent. Basically a "compile it and see if it works" approach to bug checking.

That's a basic programming thing user. Look up server-client designs, or even in programming, imperative and concurrent code styles.

It depends on the game. Some are easier than other, some already have half-built frameworks you can build off of. Things like Runescape or WoW have quite a few server bases. I would like to see someone do a Guild Wars 1 server, but the nature of Guild Wars 1 didn't really make it a priority for anyone.

You'd have to simulate the back-end completely. For content-driven games like MMOs, you have your work cut out for you, because you need to decode the network data (which can be effectively impossible) AND provide back-end logic. If the game server is merely a traffic mirror, that's less troublesome, but it'd still be a bitch to decode. It's reverse engineering, except you don't even have a guess based on instructions. Just random network data being sent back and forth. You can in theory isolate certain behaviors, like if you move a certain amount in a direction, how does the traffic change, or if it's a standard communication from a library.

So based on this info and the fact that KwonHo is just a Virtua Fighter/Tekken-style game, it would probably be less involved than doing it for a full-blown RPG, but would still be a bitch to do.
Thanks for the answers btw. It's a shame these things just disappear though. I only heard about this game like a year after it died, so I never got a chance to experience it for myself. Just recently came to my mind again.

>tfw ascended 105+ IQ god
int
main (void)
{ return 0;
}

int main
( int n
, char** args
)
{ return 0
; // etc
}