What are you working on, Sup Forums?

What are you working on, Sup Forums?

Previous thread

Other urls found in this thread:

docs.scipy.org/doc/numpy/reference/generated/numpy.polyfit.html
twitter.com/NSFWRedditImage

bump

Math homework. I am not as good at math as I am at programming because of a learning disability. Please no bully.

revolutionizing the for loop
conventional for loops are much too fast and don't give enough power to the user

i'm changing this

how are you not blind?

>how are you not blind?
what do you mean?

Working on a big dashboard project at work so have been evaluating different time series databases and graphing platforms. I’ve got influxdb and grafana running on my home network. I have it collecting data from my ubiquiti gear, my servers, and deluge.

I’m looking to wall mount a display for dashboard, especially for the grafana clock plugin as my teammates are in 4 different time zones. Suggestions on displays? I was thinking either a fire hd tablet or just go big and get 32 inch tv. I don’t want to have to mess with a computer to display it though so a tablet or smart tv with a browser would be preferred

>fire
Please do not support Amazon.

I wanted to make a simple console game in C++ and I'm already failing at that because I can't make a simple string variable to contain my fucking intro text

I don't fucking get headers and other fucking files in C++, why would you let me declare a variable in a header, use it in the .cpp file that header is included in, but give me an "undeclared identifier" at compile time. Fuck's sake Sup Forums, I didn't know I was this much of a brainlet.

files look like this right now:

stdfax.cpp:


// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include "targetver.h"

#include
#include
#include
#include


std::string introText = "Hello";

Game01.cpp:

// Game01.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


int main()
{
std::string input;

std::cout > input && input != "EXIT")
{

}


return 0;
}

Somebody explain to me like I'm 3 years old why this isn't working please

I took a long ass break from my programming process so I'm rustier than a tin bucket in a monsoon

that font and color scheme are atrocious.

hmm i find it pretty easy to look at. what color scheme/font do u use?
if it seems better i'd love to transition

Lisp

Take's a user's binary number, puts it in a string, I then push each element from the string into a stack so that the conversion algorithm is applied correctly.
My expected output should be the converted decimal number but deci keeps returning 0.
void binToDeci() {

std::stack tr;
std::string num;
int deci = 0;
char n = 0;
char temp;

std::cout > num;

for (unsigned i = 0; i< num.length(); ++i)
{
tr.push(num.at(i));
}
std::cout

1: Why are you skipping every other char?
2: You're getting input as chars but not converting them to actual numbers, they're still ASCII values

Compiles fine for me with g++.

I blame stdafx.h - try putting it all your stuff in another header file and including that and see if it works.

oh user... there are so many things wrong with this

Can someone hold my hand on reductions? I feel dumb as fuck

Given two strings P and w;
Is P the source code for a Turing machine that when given w as input will at some point try to move left from the first tape square?

I know that the acceptance problem reduces to this but I don't really get how. Posted in /sqt/ but /dpt/ is generally a good bit more knowledgeable/helpful

>/dpt/ doesn't appear in post
Delete this thread and remake it. It's not searchable.

void binToDeci() {

std::string num;
int deci = 0;

std::cout > num;

for(int i = num.length(); i >= 0; i--) if(num[i] == '1') deci += pow(2, i);
std::cout

I use a stack so that the operations are applied in reverse order.
for instance the binary number 1000 would incorrectly be processed as 1 instead of 8;

>i--

Nevermind, I read your code again.

I tried your code out, it's ran but 1000 is coming out as 1 and 0001 is coming out as 8.

1) comparing '1' as a char with 1 as int, you need to change that to '1', or use the ascii int value of '1'
2) you're double poping variables and increment n

stylistically, use modern c++ instead of the for loop you have do for (char i : num){ }
and you don't need to multiply pow(2,n) by 1 even if you were doing it correctly, right now you're multiplying 2^n by 49 since that's the int ascii value of '1'.

FTP automated async upload fired by an image upload on a webapp

Sorry, user.

void binToDeci() {

std::string num;
int deci = 0;

std::cout > num;

int bits = num.length()-1;

for(int i = bits; i >= 0; i--) {
if(num[i] == '1') deci += pow(2, bits-i);
}
std::cout

Yeah, thanks

Fuck's sake, precompiled headers

stylistically and/or by convention, the function should also be returning a number, otherwise it should be named printBinToDeci

Why are you taking powers of 2 with pow instead of bit-shifting? It's way less efficient.

You don't need a function and a stack to do what you're asking about, why don't you just use this (I'll assume you've read your input into an std::string bin_num;)
std::accumulate(bin_num.rbegin(), bin_num.rend(), 0, [index = 0](int res, char c) mutable { return res |= (c - '0')

Because I've been living in JS for a while so my mind rarely goes to bitwise operands

I got to work with some embarrassingly long functions in Python (3.6).
It's all Tensorflow, so there are with: statements abound. Or at least, there would be if the program wasn't friggin huge.

I want to break up these huge functions, but maintain the effectiveness of the with: on the block.
i.e. with tf.variable_scope(): will automatically apply a namespace to any tf.Variables declared inside of the block.

I am pretty sure that breaking up the big function into smaller functions will make the with tf.variable_scope(): do nothing inside of the function's scope.

Since I don't feel like testing that right now, supposing I am not wrong, how would you go about "inlining" functions in Python so that the effects of the with apply also to any code within the function's scope?

Works like a charm
Yeah I was maybe under faulty(?) impression that if you perform an operation between an int by a char, the compiler is able to understand the char is being used as an int.
I'll give it a shot, thanks user

>Yeah I was maybe under faulty(?) impression that if you perform an operation between an int by a char, the compiler is able to understand the char is being used as an int.

That's true for duck typed languages.

I'm probably not technically correct, but essentially, char is basically syntactic sugar for int.

>int
er int8_t

The compiler does understand that the char is being used as an int--the operator overloads for char + int casts the char to an int.
In strongly typed languages this would be a no-go (they would require you to explicitly cast)
In weakly typed languages, whatever the spec says goes.

The issue is that the operator overload doesn't do what you think it does, which is a problem when you live in JavaScript land for so long that you think it's fucked up rules apply to everything.

>That's true for duck typed languages.
and I was wrong about this, you'd still need casting in something like pythingor ruby

>which is a problem when you live in JavaScript land for so long that you think it's fucked up rules apply to everything
hah, sad, but true

I'm working on committing Kotlin syntax, doodads, and constructs to memory. Little challenges, maze generator, Android game, 99 Bottles, etc. God damn this is a nice language.

greetings ivan.

Take a Turing machine N and word w. We'll construct a machine M that moves left of the starting position iff N accepts w.
M's tape alphabet is pairs of letters from N's tape alphabet. We treat the first coordinate of M's letters as what was to the right of the starting position on N's tape, the second coordinate as what was to the left. Thus we can simulate N without ever moving to the left of the starting position. If we reach an accepting state, don't halt yet - first move to the left of the starting position.
If "moving to the left from the start" is decidable, then acceptance is decidable. Contradiction.

[index = 0](int res, char c) mutable { return res |= (c - '0')

Not even. I've just been doing Android development for five years or so and finally have a viable, enjoyable alternative to Java. Try to stop me. I'm over the moon.

How does plain java compare to android development?

Geolocation based messaging/chat application. Basically a rip-off of YikYak.

Coming up on my first full calendar year as a professional web developer and want to build something to show recruiters and really blow their dicks off.

I have a question regarding the && operator. It is super basic, and I feel like a dumbass for asking, but I prefer to clear my doubts. Here's the code:

#include
#include
#include
typedef struct node{
int val, lh, rh;
struct node *left, *right;
}node;
// Allocates new nodes.
node * getNode(int val){
node *ret = (node*)calloc(1, sizeof(node));
ret->val = val;
return ret;
}
int max; // our Diameter.
//Assign maximum Depth to each node.
int query(node *ptr){
if(ptr){
ptr->lh = query(ptr->left);
ptr->rh = query(ptr->right);
if (ptr->lh + ptr->rh + 1 > max)
max = ptr->lh + ptr->rh + 1;
return ( ptr->lh > ptr->rh ? ptr->lh : ptr->rh) + 1;
}
else
return 0;
}
int main()
{
max = INT_MIN;
node *root = NULL,*ptr;
int n, x, i ;
printf("Number of nodes and root value\n");
scanf("%i %i",&n,&x);
root = getNode(x);
char str[12345];
while(--n){
printf("Type your destination\n");
scanf(" %s",str);
i = 0;
ptr = root;
while(str[i] && ptr){
if(str[i] == 'L'){
if(ptr->left == NULL)
ptr->left = getNode(0);
ptr = ptr->left;

}
else{
if(ptr->right == NULL)
ptr->right = getNode(0);
ptr = ptr->right;

}
i++;
printf("%d\n", i);
}
printf("Type your value, please\n");
scanf("%i", &x);
ptr->val = x;

}
query(root);
printf("Max is :%i", max);
return 0;
}

Now, my question lies on this part of the code:
while(str[i] && ptr)


How are "str[i]" and "ptr" getting compared exactly? It is a super dumb question, I know, but it bugs to not completely understand this comparison. I would greatly appreciate it if someone could clear it up for me.

Ignore the && for now.
For something to be 'true' in C, it has to be a non-zero integer or a non-null pointer.

So when you check if 'str[i]' is true, you're checking that the character at str[i] is not the null character (value 0).
When you're checking if 'ptr' is true, you're checking that it actually points to something.
The && is just tying those two comparisons together.

To be more explicit, it could be written as while (str[i] != '\0' && ptr != NULL)

Thanks dude, it makes sense. Part of my confusion was because nowhere in the program the null character('\0') is never explicitly stated.

Since you're asking the question, it's obviously not your code, but I'd like to point out that scanf(" %s",str); is extremely dangerous and is just asking for a buffer overflow in your program.

Yeah, for strings I usually use fscanf. Unless you have a better alternative that you could tell me.

Welcome to the fuckery that is strings in C.

You should use extern std::string intro; in header, and then define it in one of c++ files like std::string intro="Your mum gay";

No kidding, I love C, but dealing with strings there is an absolute nightmare.

The danger is in %s, so it affects fscanf too.
It's a completely unbounded string, so it can easily overflow any possible buffer you write. *scanf has no way to know how large your destination array is, so it can't stop.

char str[10];
scanf("%s", str);
If I pass 11 characters, the buffer will overflow.
"I'll just make my buffer bigger".
char str[100];
scanf("%s", str);
and I'll just pass 101 characters.

You can explicitly use a max string length:
char str[10];
scanf("%.10s", str);
Use fgets instead
char str[10];
fgets(str, sizeof str, stdin);
or if you're fine with non-standard (but still posix-standard)
char *ptr;
size_t len;
getline(&ptr, &len, stdin);
// Do things
free(ptr);

I forgot to initialise that last example.
ptr needs to be NULL and len needs to be 0 for that to work properly.

Like this?
char* ptr = NULL;
size_t len = 0;
getline(&ptr, &len, stdin);
// Do Things
free(ptr);


Btw, thanks a lot for the lesson, man. I will try to use my strings with caution from now on.

Yes. getline is really useful in a loop, which is why it's designed the way it is.
It'll automatically grow ptr to be large enough to hold an entire line.
char *ptr = NULL;
size_t len = 0;
ssize_t nread;

while ((nread = getline(&ptr, &len, stdin)) >= 0) {
// Do thing with string
};

free(ptr);
You don't actually need the nread bit, but sometimes knowing it can be useful.

That looks pretty neat. Just so that I am completely clear, how exactly would get out from that "while loop"? Just pressing enter?

Ctrl-D will send an end-of-file. exiting the loop, or you can program something else which will exit the loop for you.
Perhaps exiting when reading a blank line?
char *ptr = NULL;
size_t len = 0;
ssize_t nread;

while ((nread = getline(&ptr, &len, stdin)) >= 0) {
// Remove trailing newline
if (ptr[nread - 1] == '\n')
ptr[nread - 1] = '\0';

// Blank line
if (ptr[0] == '\0')
break;

printf("Read \"%s\"\n", ptr);
}

free(ptr);

Awesome! That looks fun! However, shouldn't the printf be outside of the while loop? I am sorry for all the questions, I am just really curious. I really appreciate you answering all my dumb questions lol.

The printf is there just as an example of "using the string". It'll print out whatever you type line-by-line.
If it was outside the loop, it would only print the last line you entered, which would probably be empty.

Now I get it. Thanks for the explanations man. Gonna write them all down, so that I don't forget.

I have a list objects which have a property name, but I needed to give it to something that looks for a property label.
So I made a new class with a property label and a function 'fromobjwithname' which just maps name to label and returns the new object.
How is this called ?

Also, in a statically typed PL I'd just make a new constructor and call that transtyping ? Or would it be better to overload the conversion operator ?

>no /dpt/ in the title

I'm working on a major fuck up of a benq R23e joybook

I love rare old shit.

Shit OP.

lol retard

Replied to the wrong person, I'm the user that originally posted this. This is new C++14 stuff.
The [...](...) { ... } is the syntax for a C++ lambda. The things inside the brackets are the capture list of the lambda. C++14 allows arbitrary initializers for captured variables inside capture lists. So [index=0] simply captures an 'index' and initializes it as an int set to 0.

Should I be using EX functions in windows API if I don't need additional features?

>tfw haven't spent any substantial effort on a project in a few months
>haven't touched a development environment in weeks

I've been programming shit since I was 12. What's wrong with me?

Find a new hobby.

My life.

Is there a meaningful difference in program's performance between Visual C++ and GCC when compiling for Windows.

>no dpt in the title
neck yourself idiot

The non-Ex functions are sometimes macros for the Ex versions or implemented in terms of them. It doesn't really matter. Though I have experienced issues with RegisterClassEx where RegisterClass works fine, so YMMV.

Can you be retarded at math and good at programming without being a monkey?

Facial recognition implementation for about 350 stores. 4k cams with 1Mib/sec uplink, VPN and still in talks with business analyst for counting and other business applications.

an NCurses version of tsadmin.msc

Because tsadmin.msc never works anymore and I don't trust the monkeies with cmdlets

Can I become a code monkey with a CS degree?
I'm not so passionate about programming that I want to do it in my free time, but I like it enough to do as a job. I'm not too bad at programming either, at least based on my current experience.

>can you be retarded at math without being a monkey
no
>can you be good at programming without being a monkey
yes

wait nvm

Are you at least passionate about CS? If not, getting your degree is going to be hard and/or suck dick.

SAPUI5 web application on an IIS server with C# backend, Oracle database, Entity Framework and OData for communication

>muh passion
yeah he should try to become an olympic athlete or a movie star
yeah, upload your good class assignments to github and make a personal website before you graduate. link to it in your resume

working on development tools for browsing repos in tty and selecting by name

different connectors to github/gitlab/bitbucket which can be chosen with arguments

I'm looking for doirg polynomial regression in Python, found numpy.polyfit docs.scipy.org/doc/numpy/reference/generated/numpy.polyfit.html

But it doesn't give the R-squared. So I'm looking for that too.

Why do you use space or tabs ?

cHInKvision? I hope for your sake it's not cHInKvision. That's a fucking awful broken SDK.

currently reading config file with python, but would prefer something less clunky, how the fuck do shell scripts read in config data from a file.

You don't need passion to get a lot out of a CS degree. You just need to take your CS classes with the good teachers who won't go easy on you.

Passion was probably the wrong word. 4 years of CS would blow dick if you had no interest in it and just wanted it for a career. But I guess that's true of shit like accounting or most other shit.

Can somebody explain do in relation with goto and while in C?

No. Unless you're balls deep in kernel code or some rare circumstance, there's no reason to use goto.

bashing != teaching

I'm not trying to bash, I'm just saying goto is considered dangerous.

The relation is that do would just begin a loop block of a labeled statement referenced by a goto.

Why not?

in this case, it is. while executes the following expression repeatedly subject to a condition. goto jumps execution to another place of code. if you don't understand why that's bad form, you don't know enough to argue about it so just take his word on it

Can you teach me though?
What does "do" do when it either has or hasn't a while after it.

Or does it change when its inside a goto label

goto is easier for me though, so I'll keep using it for now

i don't really care, since you're obviously not doing anything other than piddling around in your spare time trying to teach yourself

I'm doing a paper review for the first time on data analytics.
Just installed Matlab and LaTeX.

I've never done one before. Any tips?