/dpt/ - Daily Programming Thread

Old thread: →

What are you working on, Sup Forums?

Other urls found in this thread:

youtube.com/watch?v=BOuvnGcvZb4
collabedit.com/
stackoverflow.com/questions/18058389/how-to-switch-between-python-2-7-to-python-3-from-command-line
better-dpt-roll.github.io/
youtube.com/watch?v=csyL9EC0S0c
twitter.com/SFWRedditVideos

>2016

>He writes his software instead of evolving it

What a pleb~

youtube.com/watch?v=BOuvnGcvZb4

Rendering engine that relies on C++17 and Concepts Lite. It's fuckin nice to use at the moment.

Trying to learn AVR assembly after 8052 assembly
Its not working out too well, RISC fucking sucks if you're used to CISC

Learning javascript so I can build my own operating system.

...

>tfw learning R

It's beautiful

Everything is exactly where it needs to be

Anybody have any issues getting SDL2 to recognize a gamecontroller?

I compiled SDL2.0.4 from source, that could be why.

I tried an afterglow 360 controller and an xbox one controller and neither passed the SDL_IsGameController() function.

What I found online is alot of people asking, but no one giving answers. Something to do with xinput.

I am looking to create a peer-to-peer chat program for some friends and myself. Not sure on how to get started.

I figure if I know their route to a specific server, and I know my route to that same server, then I can create a socket and open a connection between two of us. Is that correct?

If I have this string and regex:
String = "memes1 autism autism autism 11 22 33 memes2 autism autism autism 111 222 333 memes3 autism autism autism 1111 2222 3333 shnmkjsrhm
Regex = "memes1.*(\d+)\s(\d+)\s(\d+)"


Why does it grab the entire thing all the way to 3333? I only want it to get "memes1 autism autism autism 11 22 33"

>in person HR interview with some technical questions in two days
>mfw scared shitless and only have 1 half decent pair of business clothes to wear

oh sweet jesus I am hosed as all fuck

You only NEED one pair of half decent clothes, dumb shit

You've got that covered, now make sure you know your shit

send help

I'm putting off working through K&R exercise 5-11 because it's hard.

Does the book get more difficult from this point? I'm gonna do it either way, but it'd be cool to have some expectation.

bringing reply over from other thread

I don't really need the gamecontroller, i'm fine using the joypad, but the left trigger and right trigger use the same axis, so i've had a really hard time getting them to work. Otherwise i've already coded everything I need for the joypad.

That's the only major issue, aside from the DEVICE_ADDED and DEVICE_REMOVED events never occuring (but it's my understanding those don't work period).

learning to write mvvm wpf applications
please kill me

because your autism

I want to learn to make mobile game programming. I have some experience programming simple and intermediate applications. Where do I get started? Please help

>pycurl.error: (7, "Can't complete SOCKS5 connection to 0.0.0.0:0. (1)")
can someone tell me why pycurl shits itself when trying to connect through tor?

import argparse
import pycurl
from io import BytesIO
from bs4 import BeautifulSoup
from urllib.parse import urlparse
import os

#default settings
_proxy_url = "localhost"
_proxy_port = 9050
_page_increment = 12
_follow_redirects = True
_useragent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"

def get_file(url):
buffer = BytesIO()
conn = pycurl.Curl()
conn.setopt(conn.WRITEDATA, buffer)
conn.setopt(conn.PROXY, _proxy_url)
conn.setopt(conn.PROXYPORT, _proxy_port)
conn.setopt(conn.PROXYTYPE, conn.PROXYTYPE_SOCKS5)
conn.setopt(conn.FOLLOWLOCATION, _follow_redirects)
conn.setopt(conn.USERAGENT, _useragent)
conn.setopt(conn.URL, url)
conn.perform()
rcode = conn.getinfo(conn.RESPONSE_CODE)
conn.close()
return rcode, buffer.getvalue()

It's been a while since I took a comp sci class but would it be feasible to programmatically measure population density by devices connected to wifi? Would this include cases where I'm not on the same wifi network?

Question

What software could I use to work on a program with someone else? As in work on the same code at the same time.

you could use google documents to type the code up and then run it on your own machine

nvm I googled this:

collabedit.com/

Hey guys. I'm stuck on something. I'm doing a project in C++ for school and it's been a while since I used C++. My instructor provided us with headers for for the code so we have a place to start. In one header, he has two classes. They one class is friends with the other one.

Let's say the header file is named Foo.h but classes Foo and Bar are defined in the headerfile. Foo is a friend class of Bar. I need to define a constructor of Bar that is laid out in the header file. How would I do that? I tired Foo::Bar(parameters){} and Bar::Bar(parameters){} but both throw errors

Also haven't used C++ in awhile, try with no scope, just

Bar(params)

So C++17 is getting a filesystem library. That's cool I guess.
Also what's the deal with modules and why do people want them? what do they do or add?

>no scope

Back to Sup Forums, fucking Call of Duty faggots

Node(Node * prev, Node * next, string category, Queue &orderQueue)

This is the constructor for the "Bar" class in my explanation before. Without scope, I get this error

error: expected ‘)’ before ‘*’ token

Pic related wont compile because the method does not specify that it throws that throwable :^)

Use a different approach, regex wont work. Do it lexicaly or split on space.

[a-zA-Z0-9 ]+\s\d{2}\s\d{2}\s\d{2}

Going to give .NET Core 1.0 a shot here in a bit when Update 3 finishes taking forever to install.

it doesnt return anything dummy

Windows users who use Python.

Let's say I have both Python2 and Python3, and decide to use python in command prompt.

How does it know which one to use, if they're both called python.exe?

The one that is specified sooner inside PATH

i don't know shit about the command prompt but i would hope it (the command prompt) would throw an error

name the py3 binary python3.exe

So I can't use both Python27 and 35 in cmd?

>ame the py3 binary python3.exe
Yeah, that's what I'm going to do, so I can just type 'python3 myscript.py'. I just hope it won't cause problems

also see the second answer: stackoverflow.com/questions/18058389/how-to-switch-between-python-2-7-to-python-3-from-command-line

The command prompt wont throw an error it will execute what is first in path

Do you guys topcoder?

Not on windows, rename 3.5 as just python.exe and 2.7 as python27.exe, thats how its done on Linux

replace localhost with 127.0.0.1

one more question.

What about pip?

do I have to use pip3 or something? else how can it install python3 dependencies to the right location

Hadn't heard of it before. Looks like a combination of a freelance site and a coding challenge site. Do you have any experience with it? It looks relatively new.

memes1.*?(\d+)\s(\d+)\s(\d+)
because .* is "greedy" quantifier, unlike .*?

what do you mean? this is the constructor for the Node class. if a normal header file scenerio, it would be Node::Node(parameters){} and then define what you would do with the parameters

How come my printf slope is printing zero every time?

I've tried to get started with practice problems on it but couldn't make it work in a non-in-browser-coding setup.

I'm normally using code_eval and exercism, and wanted to get into harder challenges with topcoder.

Their corporate vibe is pretty off-putting though.

I had a bad experience with code_eval because their C/C++ environment is shit, although I've heard pretty much all the other env's are okay. How is exercism? I'm a complete newbie to coding, pretty much only know C/C++, and I looked at the requirements for passing their C++ challenges and was too lazy to install/learn Boost. To be honest, I don't mind the corporate vibe if it means I'm getting paid, but from the few challenges I looked at, it's rare for even third place to get paid.

What are some good beginner-level projects to make while learning? Every book etc seems to just show you correct code and hope that you apply it to something you're doing, but I don't have anything that I'm doing. I don't have anything I NEED to make and it really kills my motivation.

Also, what's a decent way to build some sort of portfolio that I can use to trick someone into hiring me eventually? From what I understand fixing opensource shit is a good start but that sounds like something where I'd need to be fairly proficient in the first place to even attempt it.

what is wrong with that awful font

you could use notepad++

better-dpt-roll.github.io/

>watch 3 hour video on creating a program.
>Follow everything perfectly
>Time to compile
>121234 errors
>error c23225345 cannot redefine function defined in winsdfarfafdsa.h
>spend another 2 hours watching video again looking for mistake made
>still cant find it
>slowly rebuild and test compile line by line
>video put a const in a vector
Its shit like this that annoys me about programming.

this is why you test your code every 20 min or so. preferably more often. You brought this onto your self for having bad programming habits.

also
>mindlessly copying what someone did without checking to see if it makes sense

w h a t ' s u p w i t h t h e s p a c i n g t h i n k o f t h e s c r e e n r e a l e s t a t e y o u ' r e d e s t r o y i n g

How the fuck do you read this? Holy shit it looks like I have dyslexia.

two different slope variables. the one you are printing is never assigned a value

Why is programming so hard?

virtualenv was designed for this

youtube.com/watch?v=csyL9EC0S0c
>/dpt/ explained in a single video

Its like youve never made a program. It requires a lot of reworking a code so that you can even compile an incomplete program.
Your green text is clear projection so Ill ignore that.

programming is shitt it's a waste of time and you never will make any useful apps

It's like you've never heard of test-driven development.

It's like you're deflecting because someone pointed out a bad practice of yours.

If you just went through all your compiler errors and fixed them you wouldn't have had to comb through a video for two hours and then gone through your code line by line.

I need help comparing 3 rows of a 2d array to make sure they have unique values. written in python

A 2d array? You mena a list of lists?

yeah p much

Childs play

Have an array of 1 to however large the number is the max is and then when you cycle through the 2d array of numbers have it count the number in the array and if the same number is counted twice in the array return false otherwise it is true

you dont have a return in the calculateslope function, plus youre not assigning the slope declared in main to the function call.

the way to fix it would be:
line 29: slope = calculate...
line 36: return double...

thanks homie

Nice space complexity, it's simpler to use a hashmap (or dictionaries as they call them in python) and checking if values are already in the map, if the value is not you add it to the map, otherwise your return false.

>Foo::Bar(parameters){}
I'm sorry, but that's really stupid.

This error makes me think Node isn't defined.

Another solution both are good

so right now I have some python code that looks like
list = [a,b,c,d,e]

for i in list:
if i:
#do some stuff


how do I add an else condition to catch if no elements in the list evaluate to true?

>bad practices
making it more apparent youve never made a program. Compiler errors often dont tell you where the error is. Just that something went wrong and broke a file youve never seen before and cant change.

>following tutorial
>test driven development
sure

you would do it just as it sounds else

another if condition to check if i in list at index 0,1,2,3 have no elements evalute to true

for i in list:
if i:
#do stuff
else:
#do other stuff


like this

Fucking kekerino

maybe I should have been more clear here

the else should run once if no elements return true, not n times for n elements

if i get what you mean, its stupid easy.
you can just declare a boolean and set it to false and if any of those eleements are evaluated to true it sets the boolean to true, then you check if the boolean is false after the "for" cycle

actually nevermind I know what you're asking

set a boolean before that is false, in the if set it to true. after the for statement check if the boolean is still false, if it is then that's where you do your "else"

flag = false
for i in list:
if i:
flag = true
if not flag:
pass

that way feels unpythonic, but it works

>unpythonic
the fuck does that mean

It means not pythonic. In other words, it's not idiomatic for python code.

i dont use pyhton usually but thats the only solution i can think of.
also
>unpythonic

OpenGL nerds: I'd love for you to talk about your craft.

>what do you wish you knew when you were first getting started?
>what don't you like about the API?
>what tools/sdks/packages do you feel are necessary or your favorites?
>favorite books/resources?
>what do you think about vulcan?

you may answer any, all or none.

I hope you arent asking about something as basic as
list = [a,b,c,d,e]
if list!=[]
for i in list:
if i:
#do some stuff

>babbys first troleing

I was kinda hoping for the opposite of the for... else syntax

>>> for i in a:
... if i:
... print True
... break
... else:
... print "else"

>I only program in python

>what do you wish you knew when you were first getting started?
How binding works. Lots of tutorials just glaze over it but once I discovered it affects it like a global state I started putting things into structs and classes and life got way easier.

Sorry, but you arent actually explaining what you want.
I was partly trolling you because you arent explaining yourself. If the list is empty the for loop never runs. So I have no idea what the hell you are asking about.

what he's asking for has already been answered but for some reason it's not "pyhtonic" for him

1. That I should have completely ignored all examples given to me. I feel like this one was a special case but is worth mentioning. The professor I had was AWFULLY lazy. We're talking unused variables everywhere, inconsistent spacing/indentation/naming...I could go on. Imagine something ugly and you got it. Because I was being introduced to something completely new and foreign, I didn't immediately grasp how truly obfuscated he made his content. So, my word of advice is for when you're learning to dissect each part of the pipeline into its atomic pieces and think about them like that, then build it back up. When I did "damage control" self-exploration after the course, I learned a lot more.

2. Nothing really.

3. I like SOIL; pretty sure there's a library that includes image loading though. I like to start as bare-bones as possible and then search for libraries when a task would require a significant amount of time to implement and take away from the graphics programming. You could argue that my heuristic is shit and I'm missing out on opportunities.

4. Essential Mathematics for Games and Interactive Applications.
>inb4 gayms book
It's got a lot of good reference. I dig it.

5. Don't care for it. I'm not at that level.

You are given a math Expression with N variables. Their values are given in the array Values, so that Values[0] is the value of variable 'a', Values[1] is the value of variable 'b', and so on.

The expression contains variables, brackets (( , )), binary operators (+,-,*) and unary operators (-,+,[]), where [] means square of a number (E.g. [5] = 25).

Order of priority:

Unary Operators;
Operator *;
Operators +,-;

The expression doesn't contain spaces (' ').
Your task is to return the value of the given expression.

Example

Evaluation(1, [1], "a+a") = 2;
Evaluation(2, [0,25], "[b*a]+--b") = 25;
Evaluation(3, [1,2,3], "[a]*(b+c)*(a*a+b*--+c)-c") = 32;

def uniq_three(*args):
for i in args:
if not isinstance(i, list):
raise TypeError

uniq_dict = dict()

for i in args:
for e in i:
if e in uniq_dict.keys():
return False
else:
uniq_dict[e] = True
return True