/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

stackoverflow.com/questions/19185958/wait-only-5-second-for-user-input
youtube.com/watch?v=j_Z1_7iay3I
github.com/MattRix/UnityDecompiled/blob/82e03c823811032fd970ffc9a75246e95c626502/UnityEngine/UnityEngine/GUILayer.cs
sandbox.onlinephpfunctions.com/code/52764570310e22d7ce8d8677982549e8ce79db49
docs.python.org/3/library/functions.html#any
twitter.com/SFWRedditImages

Reading the best book ever
>Also first for AS3 is best language

How do I learn .NET?
I've done heaps of programming in Java, C++, C#(Desktop), VBA, HTML, JavaScript, PHP, Java Servlets.

I want to learn some .NET

>Pajeet
public String loo implements poo

Can't apt recv-keys. dirmngr says my libksba version 1.3.3 is too old but dpkg -l says I have version 1.3.5.
Pic related.
How fix this?

>C#
You know .NET

Threadly reminder that D-chan is not dead, and she's super duper cute! Say something nice to her, anons!

I see you've finally succumb to Stockholm Syndrome, norway-kun.

Obviously he means he wants to learn the framework, not a specific .NET language

honestly I'm not 100% sure what I mean

what's in the framework that I might not know from making desktop apps in C#?

I've never met a single woman in my entire life that uses lisp or has ever used lisp.

Why would you want to meet 3DPD at all?

...

>Arbitrarily labelling a cute tomboy anime girl
You D(ead)lang fags sure are desperate.

>typical C# programmer

Too late, I started picking up Rust lately. D will always be my trusty sidekick language for prototyping though

>caring about what women are using
>implying women are programmers

Silly question:
I was making a quick interface for an experiment I was doing, and I wanted to make a user input, so I could classify the data.
I didn't want to use a big library for this, so I thought I could do it with STL.
But how do you quit a std::cin?
Is there a way to send data to it from another thread or something?
I want something similar to opencvs waitkey, check for input, if no input has been given before a deadline, give up and check if I should still check for inputs.
Do I really need to make a gui for this?

I have met a woman with a lisp though.

I failed my class in C++, should I give up on programming or selfteach c#/java and try to get a job this way?

that wasn't a woman, user

stackoverflow.com/questions/19185958/wait-only-5-second-for-user-input

If you couldn't handle C++, what makes you think you'd be able to handle C# or Java?
Python might be more your speed.

>Too late, I started picking up Rust lately
Enjoy your permanent training wheels

Stop with your silly sepples memes.
#include
#include
#include

int main()
{
struct pollfd pollfd = { .fd = STDIN_FILENO, .events = POLLIN };

printf("Enter something within 5 seconds:\n");

if (poll(&pollfd, 1, 5000) > 0) {
char buffer[1024];
fgets(buffer, sizeof buffer, stdin);

printf("You entered: %s\n", buffer);
} else {
printf("You fucked up\n");
}
}

do c++ again . Why would you jump ship to c#/java. You need to stick to c++ until you get it down. There are so many resources to learn it, find a good book from amazon on C++. Then torrent it and read it, dont listen to Sup Forums books, these retards dont know how to help beginners. Not everyone gets programming on their first try, just keep at it. Make sure you go through each part of the book and do the exerices if they have any. Watch youtube aswell

I bet you think people who drive motorcycles with helmets on are "pussies".

dumb frogposter

dont make him do python, that is such a bad language to learn as your first. It makes everything too easy, too high and you dont learn shit. Its better to learn c++/java first then reward him with python.

They are. People wearing helmets drive/ride more recklessly, thinking they are more safe, and leads to them getting into more accidents.
People who are riding around without one realise what danger they're in and are more cautious.

...

Can you please just fuck off? You're shitting the place up.

...

sure. let me ask you something else - would you drive an automobile with no air bags, no seat belts, and no emergency break?

Stop being a pussy, mate.

this implies that Rust is somehow lacking in performance, which we all know is not the case. it doesn't pay for it's increased safety. also zero cost abstractions.
also thank you Mozilla for the 0.05 cents!

a person who actually gives feedback to a question is asked to fuck off. Suck my nuts

>this implies that Rust is somehow lacking in performance
It is. Don't kid yourself, a few synthetic benchmarks aren't going to fix that. We saw the same shit with java, with some idiots claiming its faster than C.

Only problem I have with that image is it implies Rust is somehow light, which it isn't.

Can the Rust faggots please leave the thread for good? It used to have a friendly atmosphere until you came along with your socialist agenda.

Seriously fight the "cis white het males" somewhere else.

FAKE BENCHMARKS

Please respond.

you're the one shitting it up. imagine if people replied to anime images or w/e with that kind of comment

>same shit with java, with some idiots claiming its faster than C
ah I remember you! it was actually C# (actually Java is marginally faster than C# generally). Only a complete fool would try to argue that Java is faster than C or C++.

lol idiot, rust is significantly slower than C, and rust is a shitty language overall with a cancerous mozilla/webfag community

Is there any actual argument left except for edgy Sup Forums buzzwords for C tards such as yourself?

What is the permanent training wheel you are referring to?

the difference between anime and frogposting is that the former is part of the culture (anime website) and the latter is represents what's wrong with Sup Forums (normalfaggotry and Sup Forums).
>w/e
I suggest you return to whatever social media hellhole you came from. thanks

don't reply to them, user. whenever you see an offending post, just report and hide.

lol, you are are normal fag just for simply posting on Sup Forums. all of the real deals left long ago. my fucking grandmother knows about Sup Forums. my 14 yr old nephew browses Sup Forums.

this

youtube.com/watch?v=j_Z1_7iay3I

This actually. Sup Forums is now home to edgy social outcasts who think they are some special snowflake alt-emo garbage

>this projecting
how cute. now please leave

>lol
Is this what it has really come to?
Please user, for the sake of everybody: just kill yourself.

this is what happens when people fail to lurk and mods and jannies don't do their damn job. god I hope hiro just shuts this shithole down so I can move on with my life.

mooom it's not fair! the normie s are pissing me off! why can't they just go back to re ddit already! T rump won get over it!

Trump won, congratulations. Get cucked permanently by z**nists. Good job.

How pathetic.

What's your favourite anime, reddit-kun?

well no, it's more like
var loo = awaits pajeet.PooAsync();

>all these people getting mad at the people getting mad at frog pictures
you guys like getting trolled, dont you?

I'm sorry Reddit-kun, but who are you quoting?

...

So I'm trying to use C# reflection to determine whether or not an object has a certain annotation, and then get the data from said annotation. The annotation is this fucked up corequisite thing for designers so that they don't fuck your shit up, and it's completely broken (which is why I'm reflecting to get its info). It stores types that are required to be on the class.
///
/// Returns the [RequiredComponent] annotations of a given type in the form of a list.
///
/// The type to check
/// a list of all RequiredComponents for this Type
public static List DependanciesOf(System.Type type){
IEnumerable requiredComponents = type.GetCustomAttributes(typeof(RequireComponent), true).Cast();
var requiredTypes = new List();
foreach (RequireComponent r in requiredComponents)
{
if(r.m_Type0 != null)
requiredTypes.Add(r.m_Type0);
if (r.m_Type1 != null)
requiredTypes.Add(r.m_Type1);
if (r.m_Type2 != null)
requiredTypes.Add(r.m_Type2);
}
return requiredTypes;
}

This works for ALMOST everything. However, there are a few inbuilt classes like
github.com/MattRix/UnityDecompiled/blob/82e03c823811032fd970ffc9a75246e95c626502/UnityEngine/UnityEngine/GUILayer.cs
for which it does not function whatsoever. Does anybody know why it might be failing to get this attribute on this class, but work for almost all others? (the attribute is the [RequireComponent(typeof(Camera))])

>Please respond.
hi!

in php when doing something like
// code
while (condition) {
$array[] = array(key=>value);
}
//code


Does it add a new element to the array or does it replace the content ?

If C didn't have a for loop, how would you write a macro for it?

Try it!

Unfortunately it relies on unhygienic macros and won't work in all contexts.
#include

#define my_for(init, cond, post) _Bool _first = 1;\
while ((_first ? (init) : (post)), _first = 0, cond)

int main()
{
int i;
my_for(i = 0, i < 10, ++i) {
printf("%d\n", i);
}
}
If you don't mind the statement going inside the macro arguments, then
#include

#define my_for(init, cond, post, stmt) { \
init; \
while (cond) { \
stmt \
post; \
} \
}

int main()
{
int i;
my_for(i = 0, i < 10, ++i, {
printf("%d\n", i);
})
}
works better.

sandbox.onlinephpfunctions.com/code/52764570310e22d7ce8d8677982549e8ce79db49

#include

int main(){

int c = 5, d;
d = ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c + ++c;

printf("%d\n", d);

return 0;

}


How much is d?

138 i think,
not that it matters since you shouldn't write code like this anyways.

It isn't 138.

undefined

The result is undefined and completely meaningless.

whats a good name for "internal" that are used to add the implement the actual behavior?
bit hard to explain, heres an example:
interface IMailService
{
void Send(Mail mail);
}

abstract class BaseMailService implements IMailService
{
// Prevents having to duplicate error handling across all implementations
void Send(Mail mail)
{
try
{
SendInternal(mail);
}
catch(Error e)
{
log(e);
}
}

// Implements the actual send behavior
abstract void SendInternal();
}

class RealEmailService extends BaseMailService
{
void SendInternal(Mail mail)
{
// Send mail
}
}

what would you call "SendInternal" in this case?

holy fuck i meant "whats a good name for internal methods that are used to implement the actual behavior"

in c++, when I allocate space using new, I get 5 additional space I haven't asked for.

For example

char * string = new char[10]

then I get with

strlen[string]

15

Why is that?

inline it?

you need to initialize it. strlen looks for a null terminator

Any turing-complete instruction set can be translated into any other turing-complete instruction set. So yes, Megaman runs on Lisp OS.

I just completed the settings pipeline from file to option to employing the option!

>char * string = new char[10]
don't do that, that's legacy c code. use std::string.

>new
>that's legacy c code
You sure are stupid.

OOP: solving problem that it itself created.

It is 138 on Clang, TCC and PCC. It is 139 on GCC.

That's what you get for trying to bait people with undefined behaviour.

> learn C++
fuck off faggot, assembly is what REAL man learn

Implicit dereferencing is cancer

symlinks?

Anyone here has experience with MongoDB?

I have to make some queries for Mongo on Python, and right now I have this query

cursor = self.db.blocks.find({"transactions.to" : None},{"transactions.from" : 1, "_id": 0 ,"transactions.to": 1})


But this also returns me transactions who have not "none" in the "to" field and happen to be in the same arrays from those who do
How do I filter these out?

manual pointers are cancer.

No. You're stupid.

>*could run on Lisp OS if anyone cared about Lisp OS

>oh god please let me do more menial work c-sama~

Hey was wondering if there was anything wrong with having multiple return statements. How would I fix that in something like this?

def hasCycles(G):
S = set()
for root in G.nodes():
Q = list()
Q.append(root)
while Q:
u = Q.pop(0)
S.add(u)
for v in G[u]:
if v in Q:
return True
elif v not in S:
Q.append(v)

return False

2 separate queries maybe?

Disclamer: I don't know MongoDB

Are you arguing for those cancerous C++ references or something?

Absolutely nothing wrong with having multiple return statements.

Good auto-pointers with the option to take control should be standard.
C++ is not in this discussion.

Not at all m8, this is a fine example of short-circuiting the rest of the nodes as long as you find a counterexample. Here's an example of the official python docs doing it: docs.python.org/3/library/functions.html#any

If you were to finish the iterations you'd just waste CPU time

>with having multiple return statements
There is a very outdated and stupid sentiment that some programmers (especially older ones) where they think functions and programs should only have a single exit point.
It's pretty fucking stupid though, and almost always leads to unnecessary logic where you have to pass an error to the end of the function, and just clutters the code up.
So pretty much, multiple returns are completely fine.

Sadly, I can't query a cursor item further

I want to make a program that takes a 2d picture as input at makes a 3d picture using ray techniques.

Is there a good book/tutorial on the topic.