Open Side Menu Go to the Top
Register
Programming homework and newbie help thread Programming homework and newbie help thread

07-26-2017 , 11:29 AM
Use Mono for C# on Linux?
Programming homework and newbie help thread Quote
07-26-2017 , 12:28 PM
I don't know what that means. Given the MS link shows the syntax as c++, I assumed that's what it's for. Is that not the case?
Programming homework and newbie help thread Quote
07-26-2017 , 01:10 PM
Without VS, you can alernatively install Mono on Linux to compile your program as a *.exe. Though this would be C# not C++. Mono is tested.
Programming homework and newbie help thread Quote
07-26-2017 , 01:13 PM
This is the sort of task best done with AHK, imo.

edit: Oh wait, you're asking how to do this on Linux?
Programming homework and newbie help thread Quote
07-26-2017 , 01:22 PM
a quick google led me to xdotool: http://manpages.ubuntu.com/manpages/...xdotool.1.html
Programming homework and newbie help thread Quote
07-26-2017 , 01:40 PM
Quote:
Originally Posted by leavesofliberty
Without VS, you can alernatively install Mono on Linux to compile your program as a *.exe. Though this would be C# not C++. Mono is tested.
Got it installed and the test program working. Thanks! Now to figure out the rest.

Quote:
Originally Posted by _dave_
This is the sort of task best done with AHK, imo.

edit: Oh wait, you're asking how to do this on Linux?
Well, sort of. I'm asking how to write and compile it properly in Linux so that it runs on windows. For the mono hello world test, you write a .cs file that has "using System", I'm just wondering what libraries if any I need to import/include to write the small looping program posted earlier (sans installing any other software on the windows environment)
Programming homework and newbie help thread Quote
07-26-2017 , 02:39 PM
more quick googling leads me to believe mouse_event is user32.dll (standard part of Windows), and you need
Code:
System.Runtime.InteropServices
https://stackoverflow.com/questions/...-using-c-sharp
Programming homework and newbie help thread Quote
07-26-2017 , 03:45 PM
Had to add "using static System.Threading.Thread" to get Sleep to work. Nothing I can find is working for mouse_event. :-/
Mind, I saved a quarter gig of hdd space by installing mono-dev instead of the full thing. Could that be the problem?
Programming homework and newbie help thread Quote
07-26-2017 , 07:18 PM
Warning, haven't tested this:

Code:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;

public static class Program
{
    public static void Main()
    {
		while(true) {
			Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y + 1);
			Thread.Sleep(60000);
		}
    }
}
This uses a managed method to move the mouse. We don't normally make direct Win32 API calls in .NET.

Should also be noted that moving the mouse is not really the right way to keep the screen on. Should instead call SetThreadExecutionState and set the ES_DISPLAY_REQUIRED flag.

Always interesting seeing what people come up with when they don't know a language. I had forgotten the "using static" construct existed. It's never used in practice because it's just syntactic sugar which obfuscates where you're getting the "Sleep" method from, making the code less readable.
Programming homework and newbie help thread Quote
07-26-2017 , 09:06 PM
Haven't tried the Mono yet so can't add anything more. :/
Programming homework and newbie help thread Quote
07-27-2017 , 05:22 AM
Also gl on your bot.
Programming homework and newbie help thread Quote
07-27-2017 , 11:48 AM
Not really a bot. Just an "I have to read long technical articles for work and I want to prevent my chat clients from routinely going to auto-away" tool.

Maybe I should check if there's a way to disable that in the programs themselves.

Quote:
Originally Posted by ChrisV
Warning, haven't tested this:

Code:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;

public static class Program
{
    public static void Main()
    {
		while(true) {
			Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y + 1);
			Thread.Sleep(60000);
		}
    }
}
This uses a managed method to move the mouse. We don't normally make direct Win32 API calls in .NET.

Should also be noted that moving the mouse is not really the right way to keep the screen on. Should instead call SetThreadExecutionState and set the ES_DISPLAY_REQUIRED flag.

Always interesting seeing what people come up with when they don't know a language. I had forgotten the "using static" construct existed. It's never used in practice because it's just syntactic sugar which obfuscates where you're getting the "Sleep" method from, making the code less readable.
Tried this on mcs but compilation didn't work. Will have to fiddle around with some other compilers or something.
Programming homework and newbie help thread Quote
09-07-2017 , 01:46 PM
Hello all,

I need to programm something similar to pokerstove / equilab using the programming language python.
The programm only needs to be able to do the basic stuff like simulating all in situations or calculating equity in general. Userinterface is not important.

has this been done before with this language and is there already a source code out there to give me some inspiration / ideas on how to approach the task?

many thanks for help!
Programming homework and newbie help thread Quote
09-11-2017 , 03:28 PM
I found this the other day, and will probably try it soon
https://www.periscopedata.com/blog/h...-pure-sql.html

It's a method to get fast approximate results for count-distinct type queries
Programming homework and newbie help thread Quote
09-13-2017 , 03:23 PM
Hi there.

Any way to conect odds oracle to excel to do poker equity calculations in there?

I usually use excel to do simple poker things and was wondering if this was possible
Programming homework and newbie help thread Quote
09-14-2017 , 08:05 PM
Pretty good blog as far as I can tell for OO design with focus on unit testing. Plenty of concrete code examples to go with abstract design ideas.

http://misko.hevery.com/

Edit: Look for My Main method is better than your main method for a jumping off point for links to others. Also something with 3vi1 in the title it's a satire on what to do to write code that isn't designed well.
Programming homework and newbie help thread Quote
09-16-2017 , 04:15 PM
I'm having a problem with Visual Studio. I can not sign in. No matter what I do, it constantly says I need to "reenter my credentials." Most of the time when I attempt to sign in, basically nothing happens and the "reenter your credentials" message just remains. Other times I get a message that says "An error has occurred and we can no longer retrieve information for your account. Please reenter your credentials." My Microsoft account works perfectly fine everywhere else. I've been searching online for solutions but have come up with nothing to this point. Any idea of what is going on here and some potential fixes? This is driving me crazy.
Programming homework and newbie help thread Quote
09-17-2017 , 10:51 AM
Can anyone spot what is causing segmentation fault in this C++ snippet:

http://dpaste.com/3ETY9XF

When I run
Code:
$ foo.x < input_file > output_file
through CL, it will process all the strings in input file and then seg faults before reaching "waypoint 1". This is homework so I'm required to use c-strings.

Last edited by Jeff W; 09-17-2017 at 11:08 AM.
Programming homework and newbie help thread Quote
09-17-2017 , 12:59 PM
It seems likely the problem is either in CopyString() or in the way you've defined stringarray but neither is in the snippet so it's not clear which it is. The use of the buffer and std::setw() looks fine.
Programming homework and newbie help thread Quote
09-17-2017 , 04:22 PM
Quote:
Originally Posted by well named
It seems likely the problem is either in CopyString() or in the way you've defined stringarray but neither is in the snippet so it's not clear which it is. The use of the buffer and std::setw() looks fine.
Here is the code for these: http://dpaste.com/15WXRAN

That part of the code was provided by instructor. Only way I can see these causing a seg. fault is if strlen() or strcopy() but I thought that && (std::cin >> std::setw(buffsize) >> buffer) should terminate the while loop before CopyString() is called on a buffer that could trigger seg fault with those functions.
Programming homework and newbie help thread Quote
09-17-2017 , 04:48 PM
I don't usually like to use cin, so I am unsure about something. Does setw() limit to strings of length N or N-1? Because in C strings, the end of a string is usually considered to be NULL. Your CopyString function does a strlen() on it's input which will try to find the first NULL in the input.

As an example, if you had
char mystr[5] = "foo"
then myrstr would literally look like
f o o NULL X
where X is somewhat undefined

If you said
char myrstr[5] = butts
then it would be
b u t t s
with no NULL
strlen()'s behavior is somewhat undefined in this case - but in all likelihood you'd get a segfault

(btw have you tried using a debugger?)
Programming homework and newbie help thread Quote
09-17-2017 , 09:32 PM
Well, this runs for me without segfault: http://dpaste.com/1AWNTHW

So I'm not sure what the problem is.
Programming homework and newbie help thread Quote
09-17-2017 , 09:53 PM
Are you passing inputs that are the size of or greater than the allocated buffer space?
Programming homework and newbie help thread Quote
09-17-2017 , 10:09 PM
Yeah.
Programming homework and newbie help thread Quote
09-18-2017 , 07:01 AM
This might work, not sure:

Code:
char* buffer = new char[buffsize+1];
Programming homework and newbie help thread Quote

      
m