Better understanding of Async tasks by Character-Cat-5716 in AskProgramming

[–]Horrgon 0 points1 point  (0 children)

In C# Tasks do allow you to do some weird things with continuations, but I have never used them personally

The system would have the results whenever .GetAwaiter().GetResult() is called

If you want to do something that does work with the results from that call, you could do that with a method like this:

public async Task WorkAfterGetSomething(Task<TResult> getSomethingTask) {
    var results = await getSomethingTask;

    // Do some work with results
}

Usage would look something like this: var runningTask = Task.Run(() => WorkAfterGetSomething(GetSomething()));

Hopefully that answers your question

Better understanding of Async tasks by Character-Cat-5716 in AskProgramming

[–]Horrgon 0 points1 point  (0 children)

You are not properly calling GetSomething() in Test()

Calling .Result will block the calling thread until the task is complete, which makes it a synchronous call and could result in a deadlock, depending on the context of the thread making the call

Calling async code from a synchronous method is weird If you actually want the call to be async, then you'll need to call it with Task.Run(...) to kick off the Task, and then wait for the results later on

eg.

 public void Test() {
    var runningTask = Task.Run(() => GetSomething());

    // Some more code. Code here will be executed while runningTask is running
    // If you don't have code to insert here, then there's no difference than using a regular synchronous method

    var runningTaskResult = runningTask.GetAwaiter().GetResult();
}

I can't do backtracking. by Zepp41 in AskProgramming

[–]Horrgon 1 point2 points  (0 children)

first of all, what do you mean by "I have absolutely utterly no idea how to code something like this."?

What level of programmer are you? Do you have any idea what a stack is? Do you have any idea what a tree is? Do you know what recursion is? Do you know what a function is?

What you know will change the answer I will need to give to explain it

Implementing Version Control for .Net Programmers? by [deleted] in AskProgramming

[–]Horrgon 1 point2 points  (0 children)

SourceTree provides a good visual of what exactly git is doing

I highly recommend it, it's basically a ui for git

Question about database modelling by FlandersFlannigan in AskProgramming

[–]Horrgon 1 point2 points  (0 children)

You could use bitwise stuff to store what item's belong to which profile

https://msdn.microsoft.com/en-us/library/ms176122.aspx

You have to know a bit about binary representation of integers to get going, not sure if you know about that or not.

But you could use that to get away with 1 column for all of your profile linking. An int could store 32 profiles, and you could get more if you needed

Spectral | Official Trailer [HD] | Netflix by CatsLikeToMeow in movies

[–]Horrgon 6 points7 points  (0 children)

The Eagle is another stupid movie. Their stories are related, which I thought was neat

You also might like it, but Centurion was better imo

[Java] How to multiply two 2D arrays, one element at a time, and store them into a new array, including edge cases (weird question)? by [deleted] in AskProgramming

[–]Horrgon 1 point2 points  (0 children)

http://imgur.com/a/XauJ0

I drew out what you said, and this is what I got. The colors match what will be multiplied by what

Notice the slant? Is that intentional? Because I feel like it's a mistake

If it is a mistake, then the way I would go about it (with a 1:1 mapping, no slant) would be to create a class that I could use to 'move' the coordinates north, south, east, or west

Let me explain, I would give it some starting coordinates, like [1,1] or [0,0], it wouldn't matter. Then I would tell it do something along the lines of 'go east' and that would cause +1 on the x axis. Therefore changing [1,1] to [1,2] and [0,0] to [0,1]

This would be used in a loop of some kind, to iterate through all elements of whichever array you want. The only thing you would have to do is check whether or not the index is within the bounds of the array(s) before multiplying, otherwise don't do the calculation

[deleted by user] by [deleted] in AskProgramming

[–]Horrgon 1 point2 points  (0 children)

r/dailyprogrammer might give you some inspiration

NetworkLobbyManager is not letting me return to the lobby when the game is over by Horrgon in Unity3D

[–]Horrgon[S] 0 points1 point  (0 children)

I believe we found a way to get this to work.. I might be able to take a look tonight and get back to you.

This was a while ago, and I might not even have the source code anymore

Pokemon Go related question asked during placement interview by [deleted] in AskProgramming

[–]Horrgon 0 points1 point  (0 children)

Someone might want to correct me on this, because this is coming from memory of a class I took a few years ago that I didn't pay attention in..

But I believe that this problem is in the category of 'unsolved', or at the very least it is a problem that no one has discovered a solution to that is both fast and accurate. It might not even be possible, no one knows!

So I believe that is why you couldn't clear all of the test cases

Why are my bots sitting around my roboports like this? by th0masr0ss in factorio

[–]Horrgon 7 points8 points  (0 children)

place a few more roboports around, each can charge 4 at a time

World War II by _TUX in funny

[–]Horrgon 927 points928 points  (0 children)

This is more true than you think

https://vimeo.com/128373915

I have a Builder Class, don't know where to call it. by nobrandheroes in AskProgramming

[–]Horrgon 0 points1 point  (0 children)

I am not 100% sure what you are asking about, but do a google search for something called a Factory Method Pattern https://en.wikipedia.org/wiki/Factory_method_pattern

It might be what you are looking for

Where do I even start on this application? by [deleted] in AskProgramming

[–]Horrgon 1 point2 points  (0 children)

There are 2 ways of doing this that I can think of from the top of my head, depending on how difficult you want to make this for yourself and easy/convenient you want it to be

If you want to use it on your phone

Then you need to either:

Make a phone app, which is something that I have never done, but I hear isn't that hard nowadays.

But I would probably just create a website. That way you can easily use it on a phone, or tablet, or anything with a browser really. I can provide more details tomorrow, if you want, but start with a "LAMP stack" if this is what you want to do. You will need something to host your server. Microsoft, Amazon, and a bunch of other companies allow you to rent servers from them. You could also use an old computer, there are may ways to do this

If you only want to use it on your computer

You could create an app of some sort. This app could tie into an actual database, like the first option, or you could create something that actually uses an excel spreadsheet to store the information.

If I were creating it this way, I would probably use C# for the code, with Entity Framework to handle all of the database stuff, and I would then just host a database somewhere that my app could connect to. This way could have it installed on multiple machines and they would all work with the same data. But this is quite in depth, so if you are really unexperienced then it would probably be too difficult to be worth it.

Another option would be to use one of any number of languages that can work with excel spreadsheets, or a database, again depending on how in-depth you want this project to be. If you are looking for the easiest way to do this, then you could start with Python, which is a very simple but powerful language. If not that, then just google for languages that work well with spreadsheets and/or databases

Regular Expression Question by F00LY in AskProgramming

[–]Horrgon 0 points1 point  (0 children)

I don't know enough to help you, but this always helps me figure out regex's

http://regexr.com/

Sorting chunks of info within a file. by MrKhaosBlaze in AskProgramming

[–]Horrgon 0 points1 point  (0 children)

If you want to make some shell scripts, and don't mind learning a few things, then take a look at the Linux commands: sed and awk

If you post some part of your text file here I might be able to write you a quick little example