/dpt/ - Daily Programming Thread

Old thread: What are you working on Sup Forums?

Other urls found in this thread:

stackoverflow.com/questions/32404247/cant-find-windows-forms-application-for-c
openhub.net/p/linux
trac.sagemath.org/query?status=needs_info&status=needs_review&status=needs_work&status=new&order=priority&col=id&col=summary&col=status&col=type&col=priority&col=milestone&col=component&keywords=~beginner&report=38
up-for-grabs.net/
codetriage.com/
firsttimersonly.com/
openhatch.org/
codemontage.com/
bountysource.com/
bountify.co/
docsdoctor.org/
issuehub.io/
pullrequestroulette.com/
freecodecamp.com/
hacklang.org/
twitter.com/SFWRedditImages

first for C

I'm learning C++.
i've got the basics.
>if, for, while, do, try/catch.
>returns, breaks, continue, goto
>int,char,string,unsigned, etc..

Can you guys give me some pointers to what to learn in order from basic to advanced?

I've read books but +100 pages on single topics make me feel lost. it'll be nice to know what topics are the best to learn first.

fuck off pajeet

pointers

improved
#include

int8_t largest(uint16_t n) {
uint8_t length = 1, highest = n % 10;

while ((n /= 10) > 0) {
++length;
if (n % 10 > highest) highest = n % 10;
}

if (length != 4) return -1;
return highest;
}

Speaking of this... I'm trying to make software for Windows, but written in C++. Does Visual Studio support C++? Seems like it defaults to C#, but the problem is I need the interface designer in Visual Studio like what Android Studio has.

Is there a way to design the interface and still use C++? It's obviously all just code regardless, but I need something to design it in and it seems like Visual Studio is the only way.

Isn't the express version c++ only?

Dunno about the community edition.

there is an interface designer but it's more finnicky. they are the .rc files.

just make an MFC application and look at the .rc file in the resources folder, there you can add forms and stuff.

shit, sorry im kinda drunk now.

I meant, make an empty CLR and add a UI windows form in the UI node.

you need to configure your project then. like this:
stackoverflow.com/questions/32404247/cant-find-windows-forms-application-for-c

if you get errors in the designer just close the myform.h file and open it again

posted in the wrong thread

college pajeet in training here, learning java for CS-101

this project involves taking in an expression from the user using Scanner in the format
> 2 + 5
>% 14 3
>13 ^ 2
That sort of thing. The problem is that I need to catch and reject inputs that have too many or too few tokens in the input. I've hamfisted it to where it rejects inputs of too few tokens, but I cannot for the life of my retarded self come up with a way to catch an input with too many tokens.

Can I get some suggestions on this, please?

Read an entire line, parse the string.

0x04af8c53
0x8cef939b
0x938fbac7

Use a string tokenizer (or just regex) to break up the expression then count how many tokens you have.

I finished a MOOC on C in a month last summer, because I got bored with a Java course on the last stretch of 20 or so exercises.
Since then I've done nothing besides fiddling with and dropping a CLI RPN calculator that should show an arbitrary amount of lines from its stack and print over its previous input. I'm a bit unmotivated.

>2001 + 15
>still using 32 bit addresses

import os
import shutil

def move(src, dest):
shutil.move(src, dest)

SCAN_DIR = "/Users/max/Desktop/dispatch/"

IMG_EXT = ('.png', '.jpg', '.gif')
IMG_PATH = "/Users/max/Pictures/"

VID_EXT = ('.webm', '.mp4', '.mkv')
VID_PATH = "/Users/max/Movies"

DOC_EXT = ('.pdf', '.html')
DOC_PATH = "/Users/max/Documents/"

PROG_EXT = ('.c')
PROG_PATH = "/Users/max/Etc/"

ETC_PATH = "/Users/max/Etc/"

for file in os.listdir(SCAN_DIR):
if file.endswith(IMG_EXT):
move(SCAN_DIR+file, IMG_PATH+file)
print("Moved " + file + " to " + IMG_PATH + file)
elif file.endswith(VID_EXT):
move(SCAN_DIR + file, VID_PATH + file)
print("Moved " + file + " to " + VID_PATH + file)
elif file.endswith(PROG_EXT):
move(SCAN_DIR + file, PROG_PATH + file)
print("Moved " + file + " to " + PROG_PATH + file)
elif file.endswith(DOC_EXT):
move(SCAN_DIR + file, DOC_PATH + file)
print("Moved " + file + " to " + DOC_PATH + file)
elif file.endswith('.DS_Store'):
print("FUCK YOU MOTHERFUCKER DIEEE")
else:
move(SCAN_DIR + file, ETC_PATH + file)
print("Unknown file type moved to" + ETC_PATH + file)


Hard-coded a python script to scan a folder on my desktop that I drag shit into. Going to create a more robust application and gui where I can create rules based on file types. Might even make a a gui. Does Sup Forums design first or just start writing shitty code like this.

Oh shit, I think I finally got it working.

Thanks a ton, guys.

So how exactly would something like google's doodle work for determining how straight of a line you draw?

...

my initial thought is to find the two ends of the drawn line, then draw an imaginary straight line between them, and find out what percent of the drawn line is inside of the imaginary line.

>mfw Visual Studio opens faster than Visual Studio Code
Electron was a mistake

The simplest solution is always the best one.
int largest(const int n)
{
unsigned len = log10(n) + 1;
char num[len];
sprintf(num, "%d", n);
unsigned i, largest = 0;
for (i = 0; i < len; i++)
if (num[i] - '0' > largest)
largest = num[i] - '0';
return largest;
}

gets(4).chars.map(&:to_i).max

>The simplest solution is always the best one.
No.

>The simplest solution is always the best one.
Usually, the simplest solution has the worst runtime.

It's also easier to maintain, and in the grand scheme of things, processor time is much cheaper than developer time.

>It's also easier to maintain
Hello to rewrites when things scale up.

That's a fucking retarded attitude to have.
Algorithmic time-complexity is extremely fucking important. In this case, it's a simple O(n) problem, but in the face of O(2^n), your CPU doesn't mean jack shit.

By the time you would need to scale up, it's no longer your problem.
You've either been promoted or you sold your company and your shitty crufty codebase to a larger company for mad dosh.
Let them hire pajeets to figure it out.

>pajeet detected

>Let them hire pajeets to figure it out
>implying pajeet can do that

I'm a C# pajeet, I'm now porting my C# knowledge into C++.NET.

it feels good when you have no idea what are you're doing but it werks.

working on a map converter that converts quake 3 maps to source engine maps as i mentioned on the only language i'm good at is php at the moment so i made a little script that reads quake 3 maps line by line and converts it to source engine's map format, vmf.

still trying to figure out how i can convert vertical and horizontal shifts of textures since those values in both map formats are pretty fucking different.

any of you Sup Forumsrus have any idea?

>into C++.NET

Why?

What's the common pitfalls to using std::threads and copy constructors together in C++? Because everything is good until the method that I'm threading (which takes in a deep copy of a class) tries to call another method, at which point it promptly crashes.

>What's the common pitfalls to using std::threads and copy constructors together in C++?
std::thread doesn't have a copy constructor.
A common pitfall is that std::threads don't join or detach when they leave scope.
You have to write a RAII class for that.

>Because everything is good until the method that I'm threading (which takes in a deep copy of a class) tries to call another method, at which point it promptly crashes.
It's hard to tell what's wrong without the code.

I recently heard of devdocs.io and I love it.
Of course you can disable all that web programming shit that's there by default.

>micro-optimizing homework
>ISHIGGYDIGGY

i wish I could view all those docs in texinfo format and not with my web browser.

Most documentation is available as html. So it makes sense to use that.
I think you can pull devdocs from github and run all the scrapers locally.
I don't know how they store the results, but I guess it's just a bunch of directories with html file in them.
You could write a script to translate them to texinfo.

>doesn't know the meaning of "micro-optimization"

>Std::threads don't join or detach when they leave scope
Are you sure? I was able to use detach() successfully, it was the fact that I was then trying to free something malloc'd earlier that was only shallow copied and not deep copied.
Basically want to write a series of images but since the write time for the images is so long, I wanted to have threads do the writing separate from the main AND have to deep copy the class that holds the image chunks so i can delete the image chunks later.

How do you stay motivated?

It's so depressing. I've tried so hard to get into programming. I always have these ideas I'd like to make reality, but once I look at the mountain of work ahead of me I end up getting discouraged.

Should I just go to HTML instead and call it a day?

Just read Stroustroup, line by line, chapter by chapter. Until you collapse.

Also stick with "pre-modern" C++ at first. All that auto/lambda/move semantics faggotry will only get you even more mixed up.

>I was able to use detach() successfully
They don't detach or join implicitly by the destructor.
Some people use std:threads under the assumption that they join implicitly.
That's the pitfall I was talking about.

>Basically want to write a series of images but since the write time for the images is so long, I wanted to have threads do the writing separate from the main AND have to deep copy the class that holds the image chunks so i can delete the image chunks later.
Does your main thread need that image after you decide you want to write it to disk? If not, moving a unique_ptr into the writer thread might work just fine.
Do you spin off one thread per image or do you have one writer thread that you communicate with and pass new images to?
Do you keep the images completely in memory or do you only process them in chunks?

>Just read Stroustroup
Fuck no. From a technical standpoint his books may be fine, but they are didactically bad .

Where do I find open-source projects that need some help?

openhub.net/p/linux

trac.sagemath.org/query?status=needs_info&status=needs_review&status=needs_work&status=new&order=priority&col=id&col=summary&col=status&col=type&col=priority&col=milestone&col=component&keywords=~beginner&report=38

piu piu

Just read sicp everyone

The main thread constantly writes over a single image, then i want to pass a copy of the image (once I've finished writing that image) to a thread that then writes in to disk, if that makes sense.
So the main thread creates a write thread whenever there is a image to write atm, I wanted to get the basic concept done before looking at further control/thread pooling, etc.
I am keeping the whole image in memory, not chunks.

Are signals important for programming/programmers

As in knowing about signal theory

Has anyone here had such a course

Are you planning on doing any DSP?

If yes, then signal theory is important.

If no, and you're only planning on doing no brainer web dev, then no, you don't need signal theory (although it's nice to know about anyway).

>Has anyone here had such a course
Yes, it's obligatory for CS students at the university I did my degree.

/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA)

up-for-grabs.net/
codetriage.com/
firsttimersonly.com/
openhatch.org/
codemontage.com/
bountysource.com/
bountify.co/
docsdoctor.org/
issuehub.io/
pullrequestroulette.com/
contribhub.org (seems offline for the moment)

Nobody should start to undertake a large project. You start with a small trivial project, and you should never expect it to get large. If you do, you'll just overdesign and generally think it is more important than it likely is at that stage. Or worse, you might be scared away by the sheer size of the work you envision. So start small, and think about the details. Don't think about some big picture and fancy design. If it doesn't solve some fairly immediate need, it's almost certainly over-designed. And don't expect people to jump in and help you. That's not how these things work. You need to get something half-way useful first, and then others will say "hey, that almost works for me", and they'll get involved in the project.

Thank you for using an anime image.

Good response

I'm not planning anything I'm just learning CS and programming as a plan b

forgot freecodecamp.com/

>Ask your much beloved programming literate anything (IAMA)
how do i into php?

...

>php
Please, don't.

hacklang.org/

>hacklang.org/
ebin troll

It's hard to say, for me I have to get chained in order to don't give up, like doing some courses or technical school. Try coding something that u like(games or ur hobbies). Since I've started learning php I've been programming an web app to track my reading based on my browser history(get this information with a java script)

it's a good start to web dev. First u need to know html+css+js, then go to some books like head first

I like this book to start with : Learning PHP, MySQL & JavaScript: With JQuery, CSS & HTML5

hiro is really shitting up the site on mobile

Don't do it, you have too much to live for!

I'm doing something fun with randomly generated cellular automata rules, and I know how to make a way for a computer to tell what is and isn't an interesting pattern (which saves me a lot of time looking at random noise), but how do I use a modulus in such a way that if the value goes lower than zero it will loop back around?

I don't want -5%64 to give me -5, I want it to give me 59, it would make things so much easier.

Going to do some academic research that involves teaching programming basics to blind kids with some simple logo turtle lookalike using arduino/raspberry pi. My teacher told me to use python.
what are some good python books?

add n (the n in x modulo n) number if it's

eg -5 + 64 = 59

alt.

((x % n) + n) % n

Tested it, and it works fine!
Good timing too, I just ran a test and found that my cellular automata isn't actually looping around the edges as it should, but this will let me simplify my code a lot and likely fix the bug inadvertently.

RIP spoopy

Working on a chat bot.

Image tangentially related.

Alright, the cellular automata now has edge looping, like it's supposed to.

What I still don't understand though is that the very first time I ran the code when I had fixed all the major bugs, I saw a truly strange cellular automata.
Black tendrils licked from the edge, then started growing until the entire thing was shrouded in darkness.
I don't think I changed the system at all until just now, but I must have generated a hundred patterns since and not seen anything like that.

cyber cthulu has awoken?

show a recording

>tfw the bot roasts you

Hold on, there's still one major bug with the cellular automata!
If I start from a blank screen, exactly half the time something should happen, and the only thing that would be able to happen is for every cell to turn black, in which case the only thing that could happen is for every cell to turn white again (if the random rules specify it).
It also appears that cells can affect each other at a distance.
I'm guessing what's happening is that as the cells update, they update in response to the mid-iteration map, rather than the map of the previous iteration.
But I wrote
boolean[][] tempMap = map;
for (int x = 0; x < map.length; x++){
for (int y = 0; y < map[0].length; y++){
tempMap[x][y] = rules[surroundingsID(x, y)];
}
}
map = tempMap;
specfically so that wouldn't happen.
Maybe I just don't understand Java.

I don't have the rule set.
I'll set it to print the rules, just in case I see something crazy again.

are you using comonads

It's weird; it's really easy to stay motivated in the learning aspect if you have a job that wants you to program because they need you to solve problems, but I can't really do anything just for myself these days since nowadays there are at least 3 or 4 competing services for things I'd think about making for myself; it's kind of ridiculous. I really wish I had the free time of a NEET or a college student again just to bulk up my portfolio with pet projects.

Alright, I fixed it, but this new code is horrific and I still don't understand why what I did before didn't work.
I'm using arrays to copy every value and it takes up so much space, there's like a third of a page of just copying data.

Say senpai, where will you go when Sup Forums will be closed?

back into my grave.

>Nobody should start to undertake a large project. You start with a small trivial project, and you should never expect it to get large. If you do, you'll just overdesign and generally think it is more important than it likely is at that stage. Or worse, you might be scared away by the sheer size of the work you envision. So start small, and think about the details. Don't think about some big picture and fancy design. If it doesn't solve some fairly immediate need, it's almost certainly over-designed. And don't expect people to jump in and help you. That's not how these things work. You need to get something half-way useful first, and then others will say "hey, that almost works for me", and they'll get involved in the project.

True and wise words.

Trying to get through the pythonic jungle of missing libraries, making funny images.

kek

>kek
how dare you take amusement like that

that joke has been told so many times here

This joke never gets old.

Not quite programming, but I figured you guys might know:

How do I open a file in mpc from the command line? I am trying to pipe a url to mpc and it just opens mpc without opening the file.

I can pipe to clip.exe and paste into mpc's "open" option, but I'm trying to remove this intermediate paste step.

Java doesn't even have pointers

You can even skip the mapping, ASCII-order of single digits is natural order:

p gets(4).chars.max

...

You don't know either huh

Hello, newfriends!

That joke has been told many times before this comic even existed, youngfag.

This is CLI operations 101, but I'm going to be an ass because you asked in the wrong place.

Why doesn't Sup Forums have homepage threads anymore??

nobody here cares about you

if( op.image.isAnime() == true)
{
reply("fuck you for watching anime degenerate weeaboo\n");
}

I seen one not so long ago, user.

>if( op
POO