/dpt/ - Daily Programming Thread

Tip of the day: Removing comments makes your code run faster

Old thread:

Attached: Screenshot_2018-07-15_22-18-58.png (701x506, 32K)

Other urls found in this thread:

developers.google.com/sheets/api/
mono-project.com/docs/tools libraries/libraries/monocurses/
github.com/jweinst1/Fire
stackoverflow.com/questions/10506973/can-not-increment-global-variable-from-function-in-python
en.cppreference.com/w/c/keyword
twitter.com/NSFWRedditVideo

Shit op.

Check the catalog autismo
we use short names like dpt for a reason

As a self though novice programmer i have to ask.
Do the *learn to program free* and *coding bootcamps* that girls post on instagram actually teach you anything?
It looks to me they spend more time taking pictures with their latest laptop than anything else.

those bootcamps exist for you to find some washed up thott with chlamydia and gonorrhea at the last years of its fertility period and marry it so as to give birth to kids barely healthy.

A beginner sysadmin here. I'd like to start programming.

My plan is to make a program which copies a column out of a google spreadsheet table and pastes it into my own excel's "2nd column", then compares my "1st column" with the new "2nd column".

How should I do this Jow Forumsuys?

Attached: maho.png (800x720, 674K)

You want your program to get data from a spreadsheet stored on google docs? You will probably need to use google's api for accessing docs: developers.google.com/sheets/api/

I haven't used it myself, but it seems to have really good documentation. Once you have your data, you can easily append it as a column to a csv file. However you'd be better off with a library to use an .xlsx instead of a csv

Is ruby slow because rails falls asleep if it hasn't been used in a while?

Thanks user, got a little more details please?
We only used C# at school, just to edit .txt files

Hi, /dpt/. Rate my code.
pastebin.com/wYYnqVAz

Why are you using hex number for ASCIICHECK and HEXCHECK instead of:
(c >= 'a' && c = 'A' && c

Honestly fuck off with those defines and make them functions

It's so I can keep the actual values fresh in my mind. Ah, I didn't know I could lop off the ternary apart.

I feel like it's a waste of function call. It's not necessary.

Also, I have to exclude '/' from the list. I understand that from a readability standpoint, hex values aren't the preference, but it's readable to me.

BTW, I should've mentioned that this program decodes url encoding from filenames.

return an optional

time to roll to enjoy the saturday night

Attached: 1532391405194.png (3840x2160, 1.19M)

...

Jow Forums

roll

hoping to get an easy one

roollllll

I took a C++ class once, maybe I can try

How do I take a selection of an Image in C++?
I'm working with PPM files.

So I've been trying to improve my programming by taking on challenges/problems. Some guy used an algorithm that seems to go way over my head. I understand what it's doing, I just don't understand why it's correct. It's regarding having a certain amount of money and specific coins, and all the different ways you can get to that amount with the coins you have. Am I just dumb for not understanding and should I give up?

What's the algo?

Anyone had experience with MonoCurses lib? I want to try it in C#, download the tar in link below. Tar extracted in pic. How do I include it in my C# project?

mono-project.com/docs/tools libraries/libraries/monocurses/

Attached: monocurses.jpg (618x342, 62K)

if anyone has advice on how to get good at rust, let me know. Only my third day using it but it seems like a great lang.

making an OpenGL-based tiling work environment. I like i3 but only for when I'm programming, so I'm gonna make something that I can open in fullscreen, use like i3, then just alt-tab back into my normal desktop.

take a look at stb, and if that's too primitive for your needs, try OpenCV

I'm a professional C developer whose only academic experience with C is a single intro to C/C++ class. You can do it, desu

roll, the only thing I've ever done off of one of these was a brainfuck interpreter. Was pretty fun though.

Attached: rust.png (1159x1069, 377K)

I have a pretty in depth class project on my github (text based game in java that uses a BST, Linked List, XML parser, OOP, etc...) but I'd like to pad my github with a couple more projects. I'm looking to get a summer 2019 internship that will cover my travel/housing so I really need to impress. What projects will give internship recruiters boners? Ideally in the web dev field but I'll be applying to anything this September.

Attached: Martin_Septim_Monk.png (600x1000, 898K)

Read about dynamic programming.

>Ideally in the web dev field
How about something webdev related. Like a website maybe?
Just pick up a full-stack webdev tutorial and post exercises on github.

What programming language would Megumin use? I am thinking maybe Elixir because it is a magical language and powerful it is.

Attached: happy.jpg (2000x1414, 1.11M)

java

does worth the time to read "The C Programming Language" considering that I already programmed some algorithms using pointers and structs?

>does worth the time to read

Attached: whaaaaat.gif (215x219, 500K)

ada

1) You gotta fix that grammar up son. I understand what you're saying, but people will release their inner redditor when they see the first part of that sentence.
2) Yeah, it's worth reading just so you can understand C's dynamic memory allocation system, which is a bit more complicated than that of C++ or Java. But in your case, just start past wherever you're comfortable with the material and start with the new stuff.
>>>/reddit/

I was thinking of build stuff using the MERN stack since I'm pretty comfortable with node and react already. I just didn't know what to build, maybe a CRUD app?

>Removing comments makes your code run faster
Comments are ignored at compile time. Stop being a faggot.

That's the joke my good lad.

I can't think of any language that has explosions

Attached: 1521567227317.png (282x300, 78K)

test

what programming language would ryuko use?

github.com/jweinst1/Fire
not explosion but close enough

Never read a programming book in my life, and here I am interning as an embedded dev
If you think it will help you, go for it. Try to find a sample online and if there's stuff you don't know, it might be worth a shot.

Attached: thinkpad ryuko.png (650x686, 238K)

>implying that impatient brainlet would even program
also stop avatarfagging, you already got banned for it im sure.

I would like to crop an image using inputs in c++.
I am using PPM files and would like to do pic related.

Can someone help me out because I am pretty retarded at code and just don't understand.

I've only got it to crop only horizontally.

Attached: example.png (1152x648, 26K)

>>implying that impatient brainlet would even program
what exactly is "impatient" about that post?

i answered your top question you absolute retard.

>he's this angry
mfw

Attached: lol2.gif (800x786, 844K)

that seems like its a bad thing. surely girls who at least can code a little must be more desirable than those who cant code at all?

also, are you implying that females who start to learn programming are in their 30s or older?

Beginner haskell autist here, is there a way to safely unwrap Maybes in the integerToNat function? Right now im using fromJust and while i know that this code wont throw an error it doesn't feel like its the best practice.

Attached: Capture.png (1347x522, 36K)

What do you think of this new social network? counterpart.epizy.com

Attached: 38471733_2068872866465202_2980923555027353600_n.jpg (540x960, 34K)

>succ
UwU

>listening to anybody from instagram

Not gonna make it bud

>surely girls who at least can code a little must be more desirable than those who cant code at all?
what does a girls programming ability have to do with her worth you fucking virgin

>that seems like its a bad thing. surely girls who at least can code a little must be more desirable than those who cant code at all?
no more desirable than a girl who doesn't know how, but respects and appreciates the skills of other people, even if those skills are different from her own
same applies the other way, I don't have to understand the things she does, as long as I respect and appreciate it.

Roll

>finally decided to implement that rad functionality into my program that I have been delaying to do so for months
>spend several days fixing old shit instead of adding anything new

Attached: 74614.jpg (1322x1079, 144K)

You should definitely start with something smaller. But if you really want to do this, then you'll need to learn about http requests.

>doing a project for my masters involving energy informatics
>involves grid-lite memes
>large datasets need processing
>decide to just pre-process them
>serialization on server-side to clientside is slow
>ok pre-serialize them
>deserialization is slow
>ok, put the data on the clientside
>hard-coding it is slow
And so I have created my magnum opus.

>create a configuration file describing the fields of your data (name, type, comment) and indices of location
>input from this file is fed into a java program, which collates it to create another java program
>this second on is fine-tuned to read and process data from the data-file you have described, and transcribe it into a java file with hardcoded types as you have described

And all this for a dumb concept that I know is bad practice. Am I beyond saving? Should I post code?

I really don't understand what triggers Python to start thinking global variables are local variables, can someone explain this?

Pic related throws 'local variable 'bracketCounter' referenced before assignment', however if you remove line 51 then it's perfectly fine. So, it references the variable bracketCounter in line 50, which it's happy with, but doing so again on line 51 throws an error. What's the difference here? Also, is there a way to get around this without using the global key word?

Just to add - I'm a self taught amateur, please go easy.

Attached: file.png (526x344, 32K)

Throw in a space between the var and +=, and += and 1

Believe it or not that did nothing

If you want to alter a global, you need to declare it within the scope of the function using global. Put
global bracketCounter

at the top of bracketSeperation. Or you could pass it as a argument to the function. Or something else. Global vars are bad design.

Yea I'm familiar with this method but I've read it's very bad practice and frowned upon (although I'm not certain as to why).
What I'm especially wondering is why Python's doing this in the first place. Again, it's happy with line 50 but not 51.

Just checking

stackoverflow.com/questions/10506973/can-not-increment-global-variable-from-function-in-python

lrn2search

You didn't define the variable as global. Makes sense, that it doesn't check every variable for a global reference

Line 50 may be undefined, or default to 0, since the var is used in a read operation.

Line 51 is assignment

>you can access global variables but not alter them
Right, I see now. Thanks - yea I probably should had just googled that but wasn't entirely sure what to search.

>Yea I'm familiar with this method but I've read it's very bad practice and frowned upon (although I'm not certain as to why).
It's not that declaring variables with global to change them is bad practice, it's that using global vars at all is bad design.
For a tiny toy program it doesn't really matter, but in a larger application global vars make it non-obvious what side effects a function will have.

>can only use global in read operation
Neat.

I can see how that's protective. (you didn't define it, be clear, idiot!)

Attached: sch_eqn.gif (521x335, 5K)

fuck me lets go 6am!

but thats shit...

ah, fellow britbong?

Are you saying it's too tough for you?

So the correct way to do it would be to always use a function argument, even if the argument itself will remain constant?

>Pythonlets have to always pass a data object of globals or the single global itself anytime they want to write it!

Christ our code base would look horrible. (I did pseudo-embedded stuff)

Attached: 1cd.png (1280x720, 937K)

\loq\

Now that I think about it, it's not THAT bad if you have a hash or whatever of a "globals" object. Then you could do global."whatever".v or whatever the fuck Python would use.

I must use that for Perl if I do wonky stuff

Really, the correct way to do it in a bigger program is to wrap up common functions/data in classes.
Then your classes functions access the classes member variables, but no side effects are leaked outside of the class.
Read up on object-oriented design.

You don't have to pass the global var as an argument, just declare it with global in your method, done. It's better than C with it's extern nonsense to get globals to exist across files.

might*

Passing around a data struct of globals as actual function arguments sounds like ass, but you could treat a hash as a pseudo-environment.

What's the best competitive programming website for practicing implementation of ADTs and data structures in C? I have a CS exam coming up in a few weeks and I need to practice.

HackerRank is too easy because they give you all the boilerplate stuff, want a site that requires me to implement ADTs from scratch to solve problems.

Attached: joi-blade-runner-2049-4a.jpg (1920x1080, 393K)

Literally just do them yourself, what do you need a website for?
Just sit down and write them you dingus.

You completely misunderstand the use of extern. You DO NOT use extern for global variables. Extern is for using a pre-existing link. If you used a const extern you would have an unwritable to *you* variable that a library could internally modify.

>ADTs in C
how grim

extern const? I should learn better about C's typing system

>You completely misunderstand the use of extern. You DO NOT use extern for global variables.
And is a variable global if it doesn't share the same value across multiple compilation units?
If you don't use extern to access global vars defined in another file in C, you are going to have duplicate definitions of the same var with different values in every file.

en.cppreference.com/w/c/keyword

>t. cnile who doesn't know C

Attached: 1511842514610.jpg (479x599, 64K)

>what do you need a website for
muh gamification

also I can't really think of any novel twists on things like self-balancing trees, dictionaries, hash tables, etc, aside from the very obvious simple operations

My professor is a hardass so I just know he's going to throw some curveballs

Maybe we should discriminate to see if we agree:
>global variable
>accessible to every function in the "complete" file
>if included twice causes errors because of redefinition

>extern variable
>defined once, externed everywhere else (doesn't make sense if used in a single file)

There's locally global variables and externally global variables.

If it's BMP, make sure you respect the stride between rows. It's not the same as width.

This is why lisp has macros. See cl-ppcre, which does exactly that for regular expressions. You have the right idea but your language sucks.

I've only been writing ruby, HTML, CSS for about 2 months and I'm starting to learn JS and desu I'm a little nervous and oh yeah I forgot to mention that I'm in a class and i Never Even looked at code before this class ..any advice for a newbie like me?

Wait, I'm retarded, PPM is an actual format (thought you had a typo there).

I know it sucks and I know there are 100x easier ways of doing what I'm doing.
I just have autism.

CodeForces or dmoj.ca desu

I'm glad my school teaches C desu.

Thanks, I'll check them out.

Every single source defines a global variable as what you are calling an extern variable.

i wish c++ had strong typedefs

Attached: .jpg (741x915, 334K)

I wish you would shut the fuck up.

C doesn't implement global variables then.

This is painful. I hate php 'cause of shits like these

$query_get_data = mysqli_query($link, 'SELECT data FROM bd_name WHERE id = 1');

$row = mysqli_fetch_assoc($query_get_data);

$bd_data = $row['data'];