[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 313
Thread images: 17

File: timetocode.webm (2MB, 1152x648px) Image search: [Google]
timetocode.webm
2MB, 1152x648px
This is /dpt/, the best subreddit of /g/

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

/!\ ** Read this before asking questions ** /!\

http://mattgemmell.com/what-have-you-tried/
http://www.catb.org/~esr/faqs/smart-questions.html


What are you working on ?
>>
Daily reminder that anime makes you bad at coding.
>>
>>57569108
>What are you working on ?

STOP PUTTING A SPACE BEFORE THE QUESTION MARK REEEEEEE

I'm working on some metaphorical glue for some Bluemix services so I can do a partnership with IBM. They say the project is fantastic, and have moved forward with requesting a prototype.
>>
>>57569108
After some research, it turns out this image has nothing to do with coding. It's just some teen who lazes about all day, drinking cola, eating potato chips and playing online games.
>>
what programming language should i learn to get some work online during the weekends for easy money?

note that i don't want a contract job in the office, only from home bite size stuff
>>
>>57569299
javascript

simple websites for small businesses
>>
>>57569108
if( op.image.isAnime() == true )
reply("fuck you for watching anime weeaboo scum\n>>>/a/");
>>
static const bool TRUE = FALSE;
static const bool FALSE = TRUE;
>>
var areas =
from primitive in primitives
let area = primitive switch (
case Line l: 0,
case Rectangle r: r.Width * r.Height,
case Circle c: Math.PI * c.Radius * c.Radius,
case *: throw new ApplicationException()
)
select new { Primitive = primitive, Area = area };
>>
>>57569372
langugae?
>>
>>57569386
C#

>langugae
Get some coffee, anon.
>>
>>57569393
Reminder to not consu
mmle coffeine after 1800 oclock.
>>
>>57569402
consume*
>>
>>57569264
So just like most """coders""" then?
>>
>>57569393
what does "let" do in C#? is all of that LINQ stuff?
>>
>>57569417
http://austinzheng.com/2014/12/16/swift-pattern-matching-switch/
>>
>>57569417
https://github.com/dotnet/roslyn/blob/future/docs/features/patterns.md

There are examples at the bottom of the page.

It's cannibalized from F#.
>>
>>57569402
>1800 oclock
Lol. Fucking Europeans, amirite?
>>
>>57569108
Why do you have to advertize Reddit?
>>
>>57569440
Idiot 24h clocks is the only logical thing to do. Btw you should be ashamed to believe in retarded memes like imperial system.
>>
>>57569409
I guess.
>>
>>57569446
Yes, if only he hadn't mentioned reddit, no one here would know it exists. You fucking mongoloid.
>>
>>57569440
twelve inch quarter pounder yourself in the ass.
>>
Looking for insight into this C++ code. I can't figure out what's wrong with it. I'm shit at coding, just need to pass a class for a certificate basically. The context is as follows.
"You are going to write a guessing game program. The program will ask the user to guess a number between 1 and 10. The input will be compared to the secret number, which is 5. If the user guessed the wrong number the program will output “sorry, guess again” and ask the user to enter another number. If the user guesses correctly then the program will output “that’s correct!” and stop."
 #include <iostream>

using namespace std;

int main()

{
int answer=5;
cout <<"Guess a number between 1 and 10.">>endl;
cin >> answer;
if (answer==5)
{


cout << "That's correct!";
}
else
{


cout << "Sorry, guess again!";
}
}
>>
>>57569484
Joke's on you. I actually came to know about 4chan before Reddit.
>>
Should I use JSON for my JavaScript objects?
>>
>>57569509
declare an empty variable named "user answer"

use a while statement

while user answer is not 5, request the user to guess again

once you leave the while loop, the correct answer has been guessed and you can provide this feedback
>>
>>57569509
> >>endl;
> >>
>>
>>57569520
>I actually came to know about 4chan before Reddit.

Is that not the norm?

I was using 4chan before Reddit even existed.
>>
>>57569521
if you want to serialise them, then sure.
>>
>>57569551
Yes, if you knew about reddit before 4chan, why the fuck would you be on 4chan?
The only reason I browse here is because I was ruined by this website before I could discover the alternatives, and thus can't use them.
>>
>>57569509
Switch jobs asap senpai you're not cut out for it
>>
>>57569437
so immutable var for C#? neato.
>>
>>57569561
Fuck off of here, Schlomo.
Go back to plebbit.
>>
>>57569561
I like 4chan for the fact that i don't need to log in, and the few intelligent things i say aren't tainted by my shitposting history.
>>
Can anyone help with c homework? How do i take data from examadat.txt?

Write a program to grade an n -question multiple-choice exam (for n between
5 and 50) and provide feedback about the most frequently missed questions.
Your program will take data from the file examdat.txt . The first line of the
file contains the number of questions on the exam followed by a space and
then an n -character string of the correct answers. Write a function fgetAnswers
that inputs the answers from an open input file. Each of the lines that
follow contain an integer student ID followed by a space and then that student’s
answers. Function fgetAnswers can also be called to input a student's
answers. Your program is to produce an output file, report.txt , containing
the answer key, each student’s ID and each student’s score as a percentage,
and then information about how many students missed each question. Here are
short sample input and output files.
examdat.txt
5 dbbac
111 dabac
102 dcbdc
251 dbbac
report.txt
Exam Report
Question 1 2 3 4 5
Answer d b b a c
ID Score(%)
111 80
102 60
251 100
Question 1 2 3 4 5
Missed by 0 2 0 1 0
>>
>>57569561
I discovered 4chan a few years before reddit got popular. Now I use both. Perhaps you're autistic?
>>
>>57569586
Does Reddit has a reputation system?
>>
>>57569623
>Can anyone help with c homework?

No, for your own good.
Do your homework if you want to learn.
>>
>>57569629
Anything that has a persistent identifier attached to the posts has a reputation system.
>>
Is Java the best?
>>
>>57569796
That depends on what kind of problem you are trying to solve with it.

But the answer is still no.
>>
Winfag here. Should i be using
#pragma once
when developing for Linux?
I know it's probably supported by gcc, but is it considered bad form, or something, to rely on non-standard directives?
>>
in Haskell this is just
isJavaTheBest _ = False
>>
Is there a tool to automatically generate extern "C" for c++ headers?
>>
>>57569988
Too verbose.
isJavaTheBest := false
>>
>>57569964
it's supported by every compilers
>>
>>57570018
in Haskell that is just
isJavaTheBest = false
>>
>>57570022
Then there isn't a reason to use old style #ifndef include guards, ever.
>>
>>57570045
It's not supported by every compiler
>>
>>57570045
It's not in the standard.
>>
>>57570025
In Java thats just
Java a best
but it will throw an exception.
>>
>>57570094
You mean it won't compile
>>
>>57569623
>How do i take data from examadat.txt
http://www.cprogramming.com/tutorial/cfileio.html
>>
>>57570103
I don't know, I never did Java.
>>
>>57570094
I didn't read this
>>
how can I write to a specific line in a .txt file with c++

say my text file looks like this


a
b
c
d
_
_
_
_
e


is there any way to write to "_" without having to rewrite the whole file?
>>
>>57570280
yes
>>
>>57569796
yes
>>
File: 1479286874867.jpg (174KB, 633x758px) Image search: [Google]
1479286874867.jpg
174KB, 633x758px
>>57569402
>mfw I can't stand the coffee
wat do?

Also, on topic, which's better for scripting, Python, Perl or Bash?
>>
Learned how to make a simple compiler this semester and now I'm trying to design a language
Any ideas? I want to do something cool you see
>>
>>57570122
>http://www.cprogramming.com/tutorial/cfileio.html
thanks
>>
>>57570076
it is
>>
>>57569509
#include <iostream>

#define SUPER_SECRET 5

int main() {
int response;

cout << "Guess a number between 1 and 10: ";
cin >> response;

if (response == SUPER_SECRET) {
cout << "That is correct!" << endl;
} else {
cout << "Sorry, guess again!" << endl;
}
}


Non-coder here.
>>
>>57570354
Perl.
>>
please try to decipher this string

tck dy tcy wdosnweersuodp s owic.uooen aane no,dAy ,amonnnng.tA o e uh as daey e iwfd
>>
childhood is rooting for haskell, adulthood is realizing javascript makes more sense
>>
>>57570280
Assuming all lines contain one byte of text and one byte of newline, open in r+ mode and seek(line_no*2), then write one byte.

If your lines are different lengths then you'll have to read through counting the line endings before you write.

If you're writing a different size of bytes into that line then you'll need to copy the rest of the file around the new size.
>>
>>57569402
this
>>
>>57570444
True adulthood is realizing they're both shit.
>>
>>57570424
Reason?
>>
>>57570444
>javascript makes more sense
>>
>>57570444
> your inner child has a PhD in category theory
Nice.
>>
>>57570472
Because I know more Perl than Python.
>>
File: 1460871172165.jpg (474KB, 1410x2048px) Image search: [Google]
1460871172165.jpg
474KB, 1410x2048px
>>57569120
Daily reminder that crossdressing makes you good at coding.
>>
>>57570354
Lua
>>
I'm trying to use visual studio code, but when I do std::cout<"string" it doesn't show the output anywhere, and when I do std::cin>>variable it keeps running doing nothing, as if it's waiting for my input, but when I type the input in the debug console it gives me "Unable to perform this action because the process is running.".
what am I doing wrong?
>>
>>57570428
if it's not just a caesar cipher or something simple like that, forget it

>tck dy tcy

don't know which common three letter words would share the first two letters like this
>>
>>57570413
>
#define SUPER_SECRET 5

literally made me want to kill myself
const int SUPER_SECRET 5
>>
>>57570535
>not constexpr
>>
File: output.webm (3MB, 1280x720px) Image search: [Google]
output.webm
3MB, 1280x720px
since I am not hardcoding that shit and trying to solve it with math functions it's not very smooth, but I am at it.
>>
>>57570535
As I said, I'm no programmer.

I briefly glanced at C++ about 20 years ago and never looked at it again.
>>
>>57569623
little unclear about what fgetAnswers is supposed to be for exactly since they just described it vaguely instead of giving a prototype, but I have a working implementation of this problem if you get stuck on anything besides basic file i/o covered in >>57570122
>>
>>57569509
>this bracket placement
>these indentions
>>
>>57570535
>>57570563
I also forgot the namespace, whatever.
>>
>>57570388
Declarative and C-like.
>>
Learning Perl for the first time. I have strings in either type of format:

aaa.bbb.ccc.ddd
www.yyy.zzz


I can split the first line like this:

my ($field1, $field2, $field3, $field4) = split(/\./, $firstline)


I'd like to split the second line so that I get the following:

my $field1 = 'www;
my $field2 = 'missing';
my $field3 = 'yyy'
my $field4 = 'zzz'


Is there a best way to pull this off?
>>
>>57569509
come on this is babby's first day tier
>>
Trying to find out how to set up websites with a CMS or something like Jekyll for some $$$ (got a potential customer who is being ripped off by their current developer).

Unfortunatley it has to be editable to some degree and has to be secure (old site got hacked at least once)
>>
>>57570618
without regexes
>>
>>57570618
my @fields = split(/\./, $firstline)
my $field1 = @fields[0]
my $field3 = @fields[2]
my $field4 = @fields[3]
>>
what's it called when you have a parent class that takes some number of arguments and you want to initialize a child class using those arguments without passing them to the child class constructor
>>
>>57569215
He's probably a French-speaker.
>>
File: duck.png (215KB, 684x690px) Image search: [Google]
duck.png
215KB, 684x690px
haha

how amusing

;_;
>>
>>57570735
Why bother even having a comic strip format, if the joke is entirely text-based, and the visuals contribute nothing?
>>
>>57570618
I hope by perl, you mean rakudo star.
>>
>>57570651
just use wordpress.

if the owner is a pleb and won't have full time IT plebs, give him the wordpress.
>>
>>57570681
without regexs you will need to create some formal rules for your string and then build a recursive decent parser or use some parser generator.

or just use regexp you tard.
>>
>>57570570
Sorry I forgot some of the sample data, maybe that will make it more clear:

ID Score(%)
111 80
102 60
251 100
Question 1 2 3 4 5
Missed by 0 2 0 1 0

do you have to define the text file above main before trying to open and read it? And I'm a little confused on how to point to it exactly,

That site is really helpful. Definitely will be using that site as a resource. Can you share your implementation? I'm actually trying to learn, not get a quick answer and I appreciate your help
>>
I'm a dumdum
>>
>>57570025
What is 'false' bound to?
>>
>>57570756
I wouldn't have chuckled if I read that joke as text. The comic format gives it some pacing and you get the visual gag of a rubber duck speaking.
>>
>>57570388
lol. why?

Best i can tell you is to study what powers you have with a context free grammar.

you'll find it's pretty much nightmarish to make a language that's actually different from another language.

if you actually want to do this, I'd recommend you study lisp and then make some meme tool like ansible for *insert your favorite language here*

at least ansible has the benefit of having an AST out of the gate as well and it's basically lisp.
>>
>>57570735
My rubber ducks at school, ie. teachers and ta's, just call me a noob and tell me i'm doin' it wrong.
>>
>>57570756
1. Because that's actually a visual joke and you might have autism
2. It's part of a series following a specific format, meaning there's value in a degree of consistency in presentation
>>
>>57569329
Your reply does not include OPs post number in the string.
Why are you so bad at coding?
>>
>>57570842
I won't post the code but I'll try and answer specific questions

>do you have to define the text file above main before trying to open and read it?
The file pointer is just a variable like any other, it doesn't have to be "above main", i.e. a global variable

int main(void)
{
FILE *examadat = fopen("examadat.txt", "r");
/* ... */
}


That declares the FILE pointer variable examadat and opens the text file "examadat.txt" in read ("r") mode.

Then you can read from it just like you do with other user input, except with functions usually prefixed with 'f'. For example, scanf(fmt, ...) reads from stdin, but fscanf(file, fmt, ...) reads from FILE pointer file.

fscanf(stdin, fmt, ...) is equivalent to regular scanf, since stdin is a FILE pointer to standard input.
>>
>>57570842
>>57570570
I'm still learning, I know it should look something like this
#include <stdio.h>
#include <stdlib.h>

FILE *examdat.txt;
examdat.txt = fopen("c:\\examdat.txt", "r");


void fgetAnswers(){


}

int main()
{




return 0;
}


not sure what fgetanswers is supposed to do and how to go about it though
>>
>>57570444
Those two languages are usually used for very different things.
>>
Reminder to use your comments to personalise and cutify your code. The optimization loss is neglible in anything you'll ever write
>>
Equivalence is left-to-right in C++, but I want to check equivalence of multiple variables without using so many lines.

if (a == b == c == d) { do shit; }


This reads as:

if (((a == b) == c) == d) { do shit; }


Even if all variables are equal, it'll end up looking like this:

if (((TRUE) == c) == d) { do shit; }
if ((FALSE) == d) { do shit; }


How do I check if all three are equal without bullshit like:

if (a == b) && (b == c) && ( c == d)


????
>>
>>57571011

a && b && c && d


did you even look at a c++ textbook
>>
>>57570959
desu I'm not really sure what fgetAnswers does either since the description is pretty vague, I would ask your instructor to clarify and maybe even provide a function prototype (what it returns, what parameters it takes)

You can't have executable code outside of a function like that, you will need to do

FILE *examdat;

void fgetAnswers() {
/* ... */
}

int main(void)
{
examdat = fopen("examdat.txt", "r");

return 0;
}


also:
- . can't be used in identifier names
- if you give the path to the file as just "examdat.txt" it will read from the same directory as where you are running the program, so you can just put examdat.txt in the same place as your source (unless you're using an IDE which might organise source/binaries in its own arbitrary way)
- a global variable is mostly fine for such a small program, you could also write fgetAnswers like
void fgetAnswers(FILE *examdat)

and declare examdat in main, then pass it to fgetAnswers when you call it in main. Whether this matters or not depends on if you're instructor has talked about avoiding global variables or not, some may want you not use them.
>>
>>57571032
that'll only work for booleans
>>
>>57570508
is their any scientific basis to this
>>
>>57570879
For fun.
>>
>>57570995
What is Haskell actually useful for?
>>
>>57571011
Does C++ have an equivalent to the
.Aggregate()
LINQ method? This example is for booleans, but you could use whatever comparison for whatever type you want:

bool CommonBool(bool[] bools) => bools.Aggregate((x, y) => x == y);

var ayy = new[] { true, true, false, true };
var lmao = new[] { true, true, true, true };
var cuck = new[] { false, false, false, false};

new[] { ayy, lmao, cuck }.Select(x => CommonBool(x)).ToList().ForEach(WriteLine);


Output:
False
True
True
>>
>>57571159
good luck then.

when you learned "compilers" did you use a parser generator like bison?

if not, I highly recommend you make your prototype with one. it will make the process a thousand times faster.

flex/bison is pretty common.
there are also PEG ones which are syntactically easier, but not as easily expressive as the EBNF ones like bison or yacc.
>>
>>57571168
https://wiki.haskell.org/Haskell_in_industry

Have fun.
>>
>>57571192
No, we made a recursive descent parser. Bear in mind that I'm doing this just for self enrichment and not really to make something extraordinary.
>>
>>57571168
strong typing and functional "correctness."

that's about it.

it's kind of a bitch to make it realistically useful though.
>>
>>57570487
Solid reasoning tbqh
>>
>>57571048
Huge help man. Do you know whats wrong with my path? I just have the sample data saved to the desktop, still returning null
#include <stdio.h>
#include <stdlib.h>

FILE *examdat;

void fgetAnswers()
{

examdat = fopen("c:\\desktop\examdat.txt", "r");


}

int main()
{

fgetAnswers();

return 0;

}


Yeah he advises against hard coding, which is what a global variable falls under, right? He says it's fine for small call stuff like this, but to be aware in the work field. Yeah, it says fgetAnswers() has to input the answers from an open input file, but doesn't provide samples for that. Since it wants an answer key, each students ID, and the score as a percentage, I have to transfer the data from the samples to a new text file with all this somehow. I'm getting it a little more and more, bare with me I'm dumb
>>
>>57570487
kill yourself.

perl is a god awful language.

at least learn perl 6 (rakudo star) and try to get cucks to use it instead. it at least has sane and modern features.
>>
>>57570875
whoops, I mean False
but you could also do

false = False
>>
>>57571213
I don't understand any of that.

>>57571240
So it's a tool for theorists.
>>
>>57571317
>I don't understand any of that.
That says a lot.
>>
Hey guys.
I started C++ a few months ago and now I am stuck with a really stupid question.

I have a vector which contains classes and thos classes contain other classes.

the class Dispenser which contains an int number and a ingredient* ingredient

ingredient is as you can tell also a class which contains a string

Now my question is, how can I print my vector with all its elements.

I was thinking of something like that.

cout<<myCocktailmachine->Dispenservec.at(i)->ingredient.name;

In this case Cocktailmachine is another class which contains all the information.

Here my two pasebin links.
The C++ cpp file on line 259 is where I am stuck right now.

just copied you my entire Code so dont be shocked.

http://pastebin.com/cXySSKMt -->all the header
http://pastebin.com/urkKRmnV --> cpp Data

thanks for helping me out. I really enjoy learning coding as I am looking forward to change my profession
>>
>>57571317
>So it's a tool for theorists.

not really. it's just niche language for type safe and mathematically "provable" code.

Many cases, people just extensively test the shit out of their C-like shitcode to accomplish what can be done in haskell.
>>
>>57571294
>Do you know whats wrong with my path?
Well, C:\desktop isn't usually the path to the user's desktop in Windows, it would be something like "C:\Users\<your username>\Desktop". For now I'd just put it directly under C:\ if you can, to make things simpler.

>Yeah, it says fgetAnswers() has to input the answers from an open input file, but doesn't provide samples for that
The sample in>>57569623 seems to contain everything you need

examdat.txt
5 dbbac
111 dabac
102 dcbdc
251 dbbac


the first line means "there are 5 questions on this exam, these are the correct answers"

each following line means "the student with this ID # put these answers for each question"

Now that you've opened the file, the next step is to read that first line. You know pretty much the exact format of it, so it should be a simple matter to scan the contents and pull out two pieces of data, the number of questions on the exam, and the correct answers to each question.
>>
Is alpha filter and Exponential Smoothing the same thing?
>>
Hello /dpt/
I have a slider that I want to use to match the user's input
But the slider's value goes from 1 trough 256
Obviously thats way more precise then I would need to match values like this:

If value is between 1 and 16 do X
If between 17 and 32 do Y

You get the point
But how should I do this?
>>
>>57571395
>I have a vector which contains classes
No, you don't.
>>
>>57571395
>I have a vector which contains classes

i've been drinking but what? do you mean objects?
>>
>>57571451
I'm an idiot
I'm using java for this project
When possible refer the slider's value as i (int)
>>
File: Screenshot_2016-11-18_17-56-50.png (255KB, 528x700px) Image search: [Google]
Screenshot_2016-11-18_17-56-50.png
255KB, 528x700px
Added archive uploads to my shitty imageboard. Now working on backend HTML rendering.
>>
>>57571451
so you want to map its range?
>>
>>57571472
Yes

Also see this >>57571468
>>
>>57571420
gotcha, is there something worng with my syntax? I'm using codeblocks and this file doesnt wanna open
examdat = fopen("c:\users\<username>\desktop\examdat.txt", "r");
>>
>>57571465
>>57571459

Oh yeah. My fault. Since I am learning more or less by myselfe I am not very familiar with the terms but yeah it's supposed to be object
>>
>>57571487
You might need to escape all the backslashes (so \\ instead of \), \ has certain special meaning in C strings (like how \n means a newline character)

If its still not working I'd try putting examdat.txt in the same folder as your C source code and just doing
fopen("examdat.txt")
>>
>>57571451
>>57571468
Try something like this

if (i >= 1 && i <= 16) {
// whatever
} else if (i >= 17 && i <= 32) {
// whatever
}
>>
File: anal beads.png (17KB, 873x289px) Image search: [Google]
anal beads.png
17KB, 873x289px
reeeeee release expression-bodied switch statements so I don't have to use ternaries
>>
int average = (int) (((double) (a+b)) / (double) 2)

Is this a good way to average two ints?
>>
>>57570553
>using a raspberry to do simple shit like that
>>
>>57571489
that's okay, also I assume english isn't your first language so it's not a big deal

I am too full of beer to read through your stuff but it sounds like you are over-engineering whatever you are trying to do. You shouldn't make a class for just a single string.

have you tried using range-based for loops?

something like

for (Dispenser dispenser : cockmachine->vector )
{
cout << dispenser->number;
cout << dispenser->ingredient;
}
>>
>>57571395
>>57571489
Without having bothered to look at your code, i understand you want to do something like
    for each element e in vector yourVector
print e


What specifically is your problem with this?
>>
>>57571687
>You shouldn't make a class for just a single string.
Particularly because the standard library already has a class like that. It's called string.
>>
I have 3 text files saved to my local machine. I'm trying to run a word count on them for multiple words. I'm a noob.

In my UNIX Terminal I use:
 grep -o 

to output each occurrence of the word:
 digital 

in the target document:
 1.txt 

and then count the output with:
 wc -w 


So:
grep -o digital 1.txt | wc -w 
grep -o Digital 1.txt | wc -w
grep -o digital 2.txt | wc -w
grep -o Digital 2.txt | wc -w
grep -o digital 3.txt | wc -w
grep -o Digital 3.txt | wc -w


It works, but it's very inefficient. I have to read all 6 outputs, manually adding lines 1+2, lines 3+4, lines 5+6. Then I have to run it for the next 7 words.

1. Should I set up an IDE and do this with Java or some other OOP-language?
2. How can I have the command search be case-insensitive?
3. If 2 is a no, then can I have the shell add the outputs?

Thank you

pls no bully
>>
I've done something daft, /dpt/. I've made copies of a set of files, to three different projects in the same git repo, and now i don't know which set of files is the most up to date.
>>
File: output.webm (546KB, 526x310px) Image search: [Google]
output.webm
546KB, 526x310px
Working on my terminal emulator, improving the URL hint story, thinking of a better algorithm to generate hint labels.

And considering starting to port it to Windows.
>>
>>57571567
weird, none of that gets the file to open
>>
>>57571766
grep -oi digital *.txt | wc -w
>>
>>57571655
Nope.
>>
>>57571766
grep -o "[d|D]igital" 1.txt 2.txt 3.txt
>>
>>57571790
I don't understand anything you just said.
What's a URL hint story?
What's a hint label?
>>
>>57571859
Like in vimperator, you press f and it adds labels to every link on the page, then you can press the keys on the label to open that link.

It does the same in the terminal, each URL is labeled and you can press the keys to act on it.
>>
>>57571225
One of the main issues with recursive-descent parsers (other than inefficiency) is that they can't handle left-recursive grammars without some additional hacks (which can be quite error-prone), and many practical grammars (e.g. C, and languages derived from it) have left-recursive rules.

Either use bison, or learn about LALR parsers.
>>
>>57571886
Oh. I think i understand. It's some sort of dynamically and procedurally generated key bindings?
>>
>>57571933
Kind of, yeah, it's a fast way to use links without having to move your hands away from the keyboard.
>>
File: stallman.jpg (63KB, 480x640px) Image search: [Google]
stallman.jpg
63KB, 480x640px
I need somebody who knows a little about Cryptography to review my plan for a Bittorrent Sync alternative before I fuck something up badly.

Any takers?


https://github.com/AnthonySuper/hardwater
>>
File: boringkids.jpg (67KB, 625x626px) Image search: [Google]
boringkids.jpg
67KB, 625x626px
Does anyone else hate making Java GUIs?
>>
I needed a program to quickly multiply a string by a random amount (within a set limit), and copy it to my clipboard.

#!/usr/bin/env python3

import random, os

# Config
lower_limit = 32
upper_limit = 899
string = "XD"

def gen_multiplied_string():

multiplier = random.randint(lower_limit,upper_limit)

multiplied_string = string * multiplier

file = open("multistring-temp", "w")
file.write(multiplied_string)
file.close()

os.system("xclip -selection clipboard multistring-temp")

while True:
input("Hit Return to copy new string")
gen_multiplied_string()
>>
>>57571966
Cool. Not something i'd find useful, though.

You're writing this in rust?
>>
>>57572000
Everyone that's not Pajeet.
>>
>>57572018
No need to write to the file.
os.system('echo "{}" | xclip -selection c'.format(multiplied_string))
>>
>>57571818
Is your whole class using your setup (Code::Blocks on Windows)? You can ask the instructor how to correctly format the path, I don't really have a Windows machine nor Code::Blocks to test this on.

I remember Tutorials Point has this little online IDE that gives you a little shell/file directory and everything
https://www.tutorialspoint.com/compile_c_online.php
you can click the + at the top to add a file, right click and rename it to "examdat.txt" and add the sample data, unfortunately their Share Code thing seems to be broken so you can't save your work, but it should be fine to test the code and file i/o.
>>
>>57571418
>Many cases, people just extensively test the shit out of their C-like shitcode to accomplish what can be done in haskell.
Elaborate? Examples?
>>
>>57571766
That probably doesn't do what you want.

grep will output every line which matches, then wc will count all of the words in those lines. So unless each word is on a separate line, the answer will be wrong.

Other commands that may be of use:
cat [123].txt - to join multiple files into a single stream
tr '[A-Z]' '[a-z]' - to convert upper-case letters to lower case
sed 's/[^A-Za-z]\+/\n/g' - to replace non-letters with newlines (i.e. put each word on its own line,)
awk '/.+/ {if (!($0 in a)) a[$0]=0; a[$0]++; } ; END { for (k in a) print k,a[k];}' - count words
>>
>>57571688
the problem is that I want to print the name of the ingredient.

normally I just do things like myvector.at(i) or myvec[i] and thats all fine but this time I have to go a very strange way:
objectA has a vector with contains a bunch of objectsb and in objectb there is a objectc which has a string I and a int I want to print.

something like that:
for i < vec_withobjectB
cout<<objectA->vec_withobjectB.at(i).objectC.string_toPrint<<endl

I hope I could explain it.
>>
>>57572048
Further cleanup because I can.

#!/usr/bin/env python3

from random import randint
from os import system

LOWER = 32
UPPER = 899
STRING = 'XD'

def main():
while True:
input('Hit return to copy new string.')
system('echo "{}" | xclip -selection c'.format(STRING * randint(LOWER, UPPER)))

if __name__ == '__main__':
main()
>>
>>57572061
Nah just me. I want to move on to doing it straight from the command line tho. I tried in in VS and eclipse and it still wouldn't open, so I'm gonna try that resource you provided. You have any other C resources you'd recommend? Though, the first one you linked me to seems like all I'd need. Thanks for the help, it's appreciated.
>>
>>57572204
Do you know how to compile it from the command line? That would make things simpler since the relative path (just "examdat.txt") will work.

Another option is to use one of the many other online compilers. Most of them don't support virtual files but you can substitute stdin/stdout for now:
http://ideone.com/cycVRr

When you edit the code it will give you a new link you can post back here too for others to review.
>>
>>57572139
personally, i'd do something like
#include <sstream>
#include <string>

//assuming objectA is an instance of ClassA
std::string ClassA::toString()
{
std::ostringstream oss;
for ( auto e : vec_withobjectB )
{
oss << e.objectC.string_toPrint << std::endl;
}
return oss.str();
}

std::cout << objectA.toString();


Would that work for you?
>>
>>57572048
>>57572152
Nice, I changed it to this.

#!/usr/bin/env python3

import os, random, time

LOWER = 32
UPPER = 899
STRING = "XD"

def gen_multiplied_string():
multiplied_string = STRING * random.randint(LOWER, UPPER)
os.system("echo '{}' | xclip -selection c".format(multiplied_string))

while True:
gen_multiplied_string()
time.sleep(3)
>>
>>57572273
No I don't, I just know I would need to download something called gcc compiler, right?
If i use one of these online compilers, I should just paste thate data inside examdat.txt and report.txt in standard input and it will display what it does, if anything, on the output side? Sorry Im not used to using these onlnie ides
>>
>>57572273
>>57572379
Also right here
fputs("This will be the report file", report);

Right here fputs is creating a new file, with the required info?
>>
>>57569108
what are all the hashes you can do with hashlib in python? so far on my list I have md5 and sha512
>>
>>57572411
Its not creating a new file, its writing to the file report, which in this case has been assigned to stdout (
report = stdout;
) so anything you write to that "file" is displayed on standard output.

fputs() is like puts() but it takes a second argument which is the file to write to (puts only writes to stdout). fputs("hello world\n", stdout) is equivalent to puts("hello world").

The file is created when you open it for writing (
report = fopen("report.txt", "w");
), in your real program you would use that but for now I've commented it out and uses stdout instead.
>>
How do I get myself to start programming? I used to program simple applications in Visual Basic long time ago and I kinda learned it because I wanted to make specific programs, but now even if I want to learn a new language I wouldn't have any idea on what to program.
Should I just go and read guides and follow tutorials?
>>
>>57572460
https://en.wikipedia.org/wiki/Cryptographic_hash_function#Applications
>>
>>57572018
>>57572048
>>57572152
>>57572300
Look into using the pyperclip module over os.system(). I don't particularly condone your spam generator however.
>>
>>57572502
https://wiki.haskell.org/Learning_Haskell#Online_tutorials
>>
I currently only know Python. What would be a good language to learn next if I want to move towards AI development in the future?
>>
>>57572466
thanks I been trying get this file to open for the past 3 hours to no avail. I have both files in the same folder as my source. Both with the correct path, but it doesnt wanna open
>>
Hi /dpt/

I'm working on a mobile website for my UI class.

I want to implement "pages" as shown here:
https://framework7.io/examples/

I can't use any libraries other than jQuery.

Should I just keep a stack of "pages" and pop/push whenever I want to change the page?
>>
>>57571843
>>57571849
>>57572086
Thank you
>>
>>57572567
Also, I'm thinking the stack is just a stack of HTML objects.
>>
Why are there different definitions of "megabyte"?

How many bytes are in a megabyte? Does it matter what context the measurement is in?

I'm trying to display network usage in a small bit of software I'm developing.
>>
>>57572553
How are you testing if they're opening correctly?

Try this
#include <stdio.h>

int main(void)
{
FILE *examdat = fopen("examdat.txt", "r");

if (examdat) {
puts("File opened successfully.");
} else {
puts("Couldn't open the file.");
}
}


make sure the file is called examdat.txt in the same place as the source file you put the above code in. It should print "File opened successfully." if it can find the file.
>>
>>57572585
bits per second for networking
NOT bytes
>>
>>57572598
Firewall and VPN data shows bytes sent and received.

I want to show these as megabytes, as in, total amount of download/upload.

bytes/1024/1024
or
bytes/1000000
?
>>
>>57572632
https://en.wikipedia.org/wiki/Mebibyte
>>
>>57572758
There is conflicting information online.

For example, hard drive manufacturers use 1,000, not 1,024.
>>
>>57572596
On execution it doesn't open anything at all except a blank console with a 0 and the time elapsed. I've been able to read from files on the desktop and retrieve some characters doing this:
    do
{
c =fgetc(file);
printf("%c", c);
}

while (c != EOF);

fclose(file);

not sure how to actually open the file though, the ways shown havent worked at all
>>
>>57572780
Huh? If you have been able to read from the files then you must have opened them. Just replace "file" with "examdat" in the code you just posted, that's exactly the sort of thing you want to do, except in this case instead of just printing the same characters back you want to print out different information based on the characters examdat.txt contained.
>>
>>57572596
That worked, thanks man. How do i get it to the console though. I think I was expecting the file to open in notepad, which it doesnt (it should right?) Th e if statement did say it opened sucessfully though
#include <stdio.h>

int main(void)
{
FILE *examdat = fopen("C:\\Users\\<name>\\Desktop\\examdat.txt", "r");

if (examdat) {
puts("File opened successfully.");
} else {
puts("Couldn't open the file.");
}
}
>>
>>57572814
>I think I was expecting the file to open in notepad
no no no, "open" doesn't mean open in notepad, it means "able to read or write to".

fopen opens the file for reading or writing by functions like fgetc, fscanf, fputs, etc.
>>
>>57572814
Will you guys stop doing this retards homework?

This is some basic shit that he should be able to think through.
>>
>>57572814
>I think I was expecting the file to open in notepad
jesus fucking christ

read a book
>>
>>57572838
I have a learning disability sorry didnt mean to clutter the board.
>>57572831
I see thanks
>>
>>57572814
No, what you actually want is ShellExecute:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx

You provide it with the path to Notepad and the path to the file.

You can then use SendMessage function:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms644950(v=vs.85).aspx

To send keystrokes and press the save menu.
>>
>>57572814
(you)
>>
>>57572763
Yes. Binary does not lend itself neatly to SI prefixes. A megabyte is technically 10^6 bytes, but we casually and historically refer to 2^20 bytes as a megabyte. The term mebibyte was introduced to alleviate this problem. In formal contexts, you should do the same.
>>
Is there a site like checkio which doesn't require a login to """"play""""? I just want to solve some problems with python.
>>
>>57573016
project euler
>>
>>57572541
i looked it up and it says haskells an academic/theory language, what about real languages like you write code with?
>>
>>57573219
OCaml
>>
>>57573219
Haskell is a general purpose programming language
>>
>>57573219
fuck off yank
>>
>>57571011
template<typename T>
bool equal(T) {
return true;
}

template<typename T, typename U, typename... Args>
bool equal(T t, U u, Args... args) {
return t == u && equal(u, args...);
}


if (equal(a, b, c, d)) { ... }
>>
File: output.webm (1MB, 1280x720px) Image search: [Google]
output.webm
1MB, 1280x720px
stuff is going gewd
>>
>>57573249
Is this hacking?
>>
>>57573242
what's this mean then https://xkcd.com/1312/
>>
>>57573282
fuck off yank
>>
>>57573266
pretty cool but why are you doing it? just to kill time or does it have a purpose?
>>
>>57573282
Self masturbation over the "useless haskell" bandwagon
>>
>>57573318
- learn
- kill time
- add backlight to an old engine to have nice ambient light
- RGB leds gonna light up according to outside temperature or just fade slowly
- collect weather data (lol dunno why)
- maybe do some home automation with it.
will see what comes to my mind
>>
>>57573361
If hasklel is so useful then why nobody uses it?
>>
File: IMG_2346.jpg (2MB, 3000x2000px) Image search: [Google]
IMG_2346.jpg
2MB, 3000x2000px
>>57573397
woopsi, forgot picture
>>
>>57573407
fuck off yank
>>
>>57573407
they're too busy masturbating over how useless they think it is
>>
Chapel or D for c++ replacement?
>>
Why are all popular websites made with shitty languages?
google
youtube
instagram
twitter
why anons? why are they made with python/ruby
>>
>>57572585
>>57572763

>I'm trying to display network usage in a small bit of software I'm developing.
Networks are usually Kbps = Kb/s or Mbps = Mb/s, etc. Notice the small b which means bit whereas B would mean byte. for example MB/s and Mb/s are different.

Regarding the new system aka kibibyte/mebibyte/etc. it's due to the fact that kilo-/mega-/giga-/etc. are SI prefixes, they mean 10^n. However computers use binary so historically for use in programming, computer design, etc. they meant their binary equivalent keeping their order of magnitude intact.

Unfortunately as science and engineering progressed and got more rigorous and correct and SI is everywhere it's not really acceptable to keep it like that. It's ambiguous. That's why they made the new system.

However due to historical reasons it became the de facto standard to know what SI prefixes mean in conjunction with units used in fields related to computers so no one is keen on switching.
The correct one is the IEEE standard. However it's rarely used in consumer tech and the hacked SI allows mass storage manufacturers to "cheat", but technically their use is entirely correct.
>>
>>57573460
Rust
>>
>>57573460
Dlang
>>
>>57573249
i dont get it. why
return true
?
>>
>>57573460
D, never even heard of the other one
>>
>>57569108
>What are you working on ?
I'm currently working on figuring out what to work on. Sadly I have absolutely no clue.
>>
>>57573536
Base case. He could have made the base case two elements, in which case it would be regular equality. Result would be the same.
p && q && ... && r && true == p && q && ... && r
>>
>>57573249
is this functional programming in C++? it's an abomination
>>
>>57573276
Yes, he's probably inside the NSA mainframe as we speak
>>
>>57573610
kek
>>
Does the word 'code' used as a verb trigger the fuck out of anyone else?
>>
>>57573642
Yes, only hipster retards use it.
>>
>>57573642
I use it to describe my job.
>>
>>57573642
You make this post every damn thread
>>
>>57573655
Kill yourself.
>>
>>57573599
It involves a heterogeneous list. Most languages can't even express that.
>>
Is there any good reason to learn C anymore?
>>
>>57573651
What's wrong with being a code artisan? Liking to code is nice!
>>
>>57573688
If you don't learn a low level language you'll never be a good coder.
>>
>>57573688
Yeah, it's called embedded newfriend
>>
>>57570618
Pick a better language and start again.
>>
>>57573707
C isn't low level
>>
>>57571655
Yeah. The other anon just doesn't know what the 'double' keyword is for.
>>
>>57573642
No. Seems like an accurate enough description.
Technically, all acts of writing is coding, but whatever.
>>
>>57573737
low quality troll
>>
>>57571790
>port it to windows
Why waste your time? Nobody on windows is going to want a terminal emulator.

If it supports copy&paste from X's clipboard and a decent amount of themeing (padding, colors, font) then it'll probably gain popularity.
>>
>>57573772
low quality troll
>>
>>57573775
Why wouldn't you want one on windows?
>>
>>57573824
Using the console on Windows is as retarded as using the GUI on Linux
>>
>>57573737
of course its low level you fucking autist
>>
>>57573850
>>57573772
That is an embarassing opinion to hold.
>>
>>57573824
Because there isn't much support for command-line applications on windows. Anyone who uses one doesn't use it frequently, and therefore, wouldn't put the effort in to switch.
>>
>>57571790
the jumping text is irritating
>>
>>57573853
>hurr its not machine code so its not low level
>>
>>57573796
>>57573850
>>57573707
No it isn't, kek. It has low-level memory management systems in place, but it's not a low-level language and has effectively no features of low-level design. It's very abstracted from machine code, unlike assembly or LLVM IR, which compile/assemble to machine code with a nearly 1:1 association between tokens and machine code.

Now get off my board, you stupid fucking C fanboys.
>>
whats the highest level?
>>
>>57573891
see >>57573869
>>
>>57573854
Still, would be interested in following the development of a windows port, if only it was done in a language i know, ie. c++.
>>
>>57573869
How can you be so wrong?

>>57573891
You are now needing to make up arguments on my behalf to defeat.
>>
>>57573893
Abstraction can be continued infinitely, but things like prolog would be examples of very high level languages.
>>
>>57573893
Your mum.
>>
>>57573900
Whoops, didn't mean to reply to >>57573891
>>
>>57573898
LLVM IR and Assembly are machine code in your mind?
>>57573900
I'm not the anon you're responding to. I posted >>57573891 as my entrypoint in this argument.

You don't know what you're talking about.
What makes C low level but Fortran high level, exactly?
>>
https://github.com/kw-udon/constexpr-8cc
>>
>>57573931
hn?
>>
>>57573685
>It involves a heterogeneous list.
why?
>>
>>57573945
yes
>>
>>57572547
Python is good enough for machine learning.
Try C# and C++
>>
Is there a college/university where coding classes are done on mac?
>>
>>57574139
All of them.

PC's are just a different kind of mac.
>>
>>57574139
why would this matter?
>>
>>57574204
I don't want to share the same lecture room with poorfags.
>>
>>57574225
oh so it's just bait to get (you)s thanks for clearing that up
>>
>>57573599
it's a template metaprogram. it's a turing complete type language that generates code at compile time. it's a very advanced feature that most C++ programmers will never use

there are regular runtime functional idioms in C++, e.g. closures, map() etc.
>>
Is it me or does GNU no longer write man pages for C++?
>>
>>57571011
just write a variadic function with the exact call signature that you want and then do the verbose thing internally. that's the only way you'll get the exact call signature that you want.

some functional languages would let you write an elegant solution using map(zip(args[0:],args[1:]), ==) but unfortunately C++ iterators are not really great for chaining higher-order functions.

>>57573249
is incredibly powerful and arguably the best solution if you understand it. it generates the exact code you want at compile time.
>>
>>57574442
>is incredibly powerful and arguably the best solution if you understand it. it generates the exact code you want at compile time.
And one day you discover the LISP macro.
>>
>>57574442
>is incredibly powerful
>powerful
You really need to stop using this word if you don't want to die for some undefined reasons.

>it generates the exact code you want
What is ASM
>>
File: dpt.png (2MB, 1920x1080px) Image search: [Google]
dpt.png
2MB, 1920x1080px
Gaze data heatmapping
Working on a biometric passcode system using eye-tracking.

Somebody buy me this: http://www.tobiipro.com/product-listing/

I want to train a pair that can tell if somebody is high on dude weed and sell it to law enforcement agencies in order to become a multiple thousandaire.
>>
>>57574716

That screenshot.

Goddamn I'm fucking gay.
>>
>>57574615
this is competing for the most incoherent set of meme responses i've ever received in over a decade of posting
>>
File: h.jpg (89KB, 644x781px) Image search: [Google]
h.jpg
89KB, 644x781px
Been trying to learn HTML/CSS for months now and I still can't make a decent looking webpage.

What do?
>>
>>57575075
look for a template
>>
File: brain problems.jpg (9KB, 192x220px) Image search: [Google]
brain problems.jpg
9KB, 192x220px
>>57569329
>comes on anime website
>complains about anime
>>
What's the difference between OOP and functional, /g/?
>>
>>57575123
One is the future, one is the past. Guess which is which.
>>
>>57575123
One is for work and the other for fucking around.
>>
>>57575123
One is a bigger meme than the other. Any non-retarded language is multiparadigm.
>>
>>57575189
so javascript?
:^)
>>
>>57575200
That's reversing the logic. Any non-retarded PL is multiparadigm, but not all multiparadigm PLs aren't retarded.
>>
>>57575123
One exists and ther other is abstract.
>>
>>57575123
one is real, the other is a meme used solely by weebs on 4chan
>>
File: theAnimeGallery_202318_1600x1200.png (636KB, 1600x1200px) Image search: [Google]
theAnimeGallery_202318_1600x1200.png
636KB, 1600x1200px
>>57569120
it's a good thing I strive to be good at programming, then
>>
>>57569402
consuming coffee at 17:33 to maximize coffee consumption but still be a good citizen during the no coffee hours
>>
test
>>
>>57575343
>>57575251
>>57575189
>one is a meme
>one exists
>one is real
WHICH ONE?
>>
How do I get a gf, /g/?
>>
>>57575480
You don't.

Virgin masterrace.
>>
I want to condense the below in java.
if(impulseX > 20) { }
if(impulseX < -20) { }


Is there any way I can do this?
Something like code related, but that works

if(|impulseX| > 20) { }
>>
>>57575480
Gay clubs. Dress as a cute programmer, dykes coming up to you left and right
>>
>>57575513
https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#abs-double-
>>
>>57575480
From personal experience, obtaining a gf is literally impossible.

I don't really believe that girls exist. They are just background simulations which are there only to taunt me.
>>
>>57572000
use a modern framework that blows up XML layouts instead of swing you fool.
>>
>>57575466
OOP is real, functional programming isn't. google OOP in industry and functional programming in industry and see which has more results
>>
>>57575547

>>57575547

>>57575547

>>57575547

NEW
>>
>>57575536
literally this.

women are a lie.

>>57575551
u wut m8?

both are real paradigms.
just cuz you make corporate monkey tier shit doesn't make OOP any more real than functional.
>>
>>57575532
thank you anon
love you <3
>>
>>57571011
The only true way:
reduce(operator.eq, itertools.combinations((a, b, c)))
Thread posts: 313
Thread images: 17


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.