|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On June 17 2016 06:48 Frudgey wrote: So I'm messing around with C# and I'm building a financial calculator (using a form) and I had a question.
So basically I want to calculate the rate of return, but I wish to do so dynamically. So what I would want is that the user inputs data into available text boxes, and then as soon as the user inputs values into those text boxes, the program would populate another text box using that information. Note that this would be done without pressing a button (e.g., hitting a "calculate" button to calculate the value) and would happen as soon as the data is entered.
I was thinking of having a thread or something help me out with this, and I did some looking online and "DoEvents" seemed like a possibility. However I did some reading up on it and now I'm not so sure if that's the best course of action.
If anyone knows what I'm talking about (sorry if I'm unclear) and knows what I want to accomplish and could point me in the right direction, I'd be super grateful.
Use the keypress event for the textbox you're typing in.
|
|
|
On June 17 2016 02:12 Nesserev wrote:Show nested quote +On June 17 2016 00:14 Silvanel wrote: Anyone here with experience with selenium? Yes.
webdriver python3.5 firefox
I am trying to use webdriver with python. I have problem with opening browser (it opens briefly but then shut down with error immiediately without going to desired webpage with error: "ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host".
From what i have read on net this is most likely issue with proxy (is it true?). I tried to setup proxy in my python code but this doesnt solve the issue (i use adress of automatic configuration).
from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.proxy import *
proxy = Proxy({ 'proxyType' : ProxyType.PAC, 'proxyAutoconfigUrl' : 'some_adress'})
driver = webdriver.Firefox(proxy=proxy) driver.get(some_web_page)
And another question, if i dont use proxy for connection to net do i still need to setup proxy in code? Or should it work fine? I still get an error (but different).
|
On June 17 2016 15:30 Nesserev wrote:Show nested quote +On June 17 2016 14:06 DrywMz wrote:On June 17 2016 06:48 Frudgey wrote: So I'm messing around with C# and I'm building a financial calculator (using a form) and I had a question.
So basically I want to calculate the rate of return, but I wish to do so dynamically. So what I would want is that the user inputs data into available text boxes, and then as soon as the user inputs values into those text boxes, the program would populate another text box using that information. Note that this would be done without pressing a button (e.g., hitting a "calculate" button to calculate the value) and would happen as soon as the data is entered.
I was thinking of having a thread or something help me out with this, and I did some looking online and "DoEvents" seemed like a possibility. However I did some reading up on it and now I'm not so sure if that's the best course of action.
If anyone knows what I'm talking about (sorry if I'm unclear) and knows what I want to accomplish and could point me in the right direction, I'd be super grateful. Use the keypress event for the textbox you're typing in. Not familiar with the options available in C# forms (never touched C# in fact), but aren't there better alternatives than using 'keypress' events to trigger this functionality? For example pasting a value probably won't trigger a keypress event (well, it shouldn't). Isn't there an 'input' or 'change' event? Show nested quote +On June 17 2016 10:58 Acrofales wrote:On June 17 2016 08:23 RoomOfMush wrote: Why not react to changes being made to the textfields? Every time the user inputs some numbers you update the other textfield. I dont see why you would ever need multi threading for this. Pretty much this. I don't know anything about C#, but if it requires multithreading to react to user input, it seems terrible... and what I have heard is that C# is not terrible. A lot of event-driven application frameworks use multi-threading under the hood, but this isn't always the case. Some use the GUI's mainloop to react to events and call the 'event handlers' in the mainloop. This way, the decision to do a simple and fast calculation, or to create and start a new thread for heavier calculations, or do anything else, is relayed to the programmer. Whether or not there is a single case in which this approach leads to any substantial advantages... I genuinely do not know.
If the compiler "under the hood" decides to make things multithreaded, doesn't that play havoc with variables? The compiler would have to "know" what parts of the code should be synchronized, and which are inherently threadsafe. A "dumb" compiler would have to add monitors (or whatever other mechanism) to any non-local variable, which seems far from optimal.
Leaving it to the programmer (e.g. Android philosophy) seems like a far smarter approach. But language and compiler design is not my specialty.
|
On June 17 2016 20:28 Acrofales wrote:Show nested quote +On June 17 2016 15:30 Nesserev wrote:On June 17 2016 14:06 DrywMz wrote:On June 17 2016 06:48 Frudgey wrote: So I'm messing around with C# and I'm building a financial calculator (using a form) and I had a question.
So basically I want to calculate the rate of return, but I wish to do so dynamically. So what I would want is that the user inputs data into available text boxes, and then as soon as the user inputs values into those text boxes, the program would populate another text box using that information. Note that this would be done without pressing a button (e.g., hitting a "calculate" button to calculate the value) and would happen as soon as the data is entered.
I was thinking of having a thread or something help me out with this, and I did some looking online and "DoEvents" seemed like a possibility. However I did some reading up on it and now I'm not so sure if that's the best course of action.
If anyone knows what I'm talking about (sorry if I'm unclear) and knows what I want to accomplish and could point me in the right direction, I'd be super grateful. Use the keypress event for the textbox you're typing in. Not familiar with the options available in C# forms (never touched C# in fact), but aren't there better alternatives than using 'keypress' events to trigger this functionality? For example pasting a value probably won't trigger a keypress event (well, it shouldn't). Isn't there an 'input' or 'change' event? On June 17 2016 10:58 Acrofales wrote:On June 17 2016 08:23 RoomOfMush wrote: Why not react to changes being made to the textfields? Every time the user inputs some numbers you update the other textfield. I dont see why you would ever need multi threading for this. Pretty much this. I don't know anything about C#, but if it requires multithreading to react to user input, it seems terrible... and what I have heard is that C# is not terrible. A lot of event-driven application frameworks use multi-threading under the hood, but this isn't always the case. Some use the GUI's mainloop to react to events and call the 'event handlers' in the mainloop. This way, the decision to do a simple and fast calculation, or to create and start a new thread for heavier calculations, or do anything else, is relayed to the programmer. Whether or not there is a single case in which this approach leads to any substantial advantages... I genuinely do not know. If the compiler "under the hood" decides to make things multithreaded, doesn't that play havoc with variables? The compiler would have to "know" what parts of the code should be synchronized, and which are inherently threadsafe. A "dumb" compiler would have to add monitors (or whatever other mechanism) to any non-local variable, which seems far from optimal. Leaving it to the programmer (e.g. Android philosophy) seems like a far smarter approach. But language and compiler design is not my specialty.
A few years ago when I last did UI stuff with C#, changing the UI directly caused thread exceptions, because you tried to change variables in a different thread and C# caught that. You had to explicitely use Invoke() to execute code - like changing a value - in the UI scope. I imagine that it's still the same.
|
|
I am trying to run it on my computer with my own browser. Remote is for running selenium instances on servers isnt it?
I think i will try to downgrade python to 3.4 i remember that it worked with it (altough i wasnt usuing automatic proxy configuration url back then also).
|
|
On June 17 2016 15:30 Nesserev wrote:Show nested quote +On June 17 2016 14:06 DrywMz wrote:On June 17 2016 06:48 Frudgey wrote: So I'm messing around with C# and I'm building a financial calculator (using a form) and I had a question.
So basically I want to calculate the rate of return, but I wish to do so dynamically. So what I would want is that the user inputs data into available text boxes, and then as soon as the user inputs values into those text boxes, the program would populate another text box using that information. Note that this would be done without pressing a button (e.g., hitting a "calculate" button to calculate the value) and would happen as soon as the data is entered.
I was thinking of having a thread or something help me out with this, and I did some looking online and "DoEvents" seemed like a possibility. However I did some reading up on it and now I'm not so sure if that's the best course of action.
If anyone knows what I'm talking about (sorry if I'm unclear) and knows what I want to accomplish and could point me in the right direction, I'd be super grateful. Use the keypress event for the textbox you're typing in. Not familiar with the options available in C# forms (never touched C# in fact), but aren't there better alternatives than using 'keypress' events to trigger this functionality? For example pasting a value probably won't trigger a keypress event (well, it shouldn't). Isn't there an 'input' or 'change' event?
There is. Check the INotifyPropertyChanged Interface.
|
On June 17 2016 21:46 Nesserev wrote: In the second case (multi-threaded), the framework usually calls a new thread for every eventhandler anwyay. The programmer doesn't have to manually manage the threads anymore. Think of JavaScript in your browser.
What do you mean by that? Javascript is single-threaded or to be more precise event-loop and callback based.
|
If anyone is intrested i figured out what was wrong. Apparently selenium (webdriver in particular) doesnt support firefox 47. A simple downgrade of firefox helped.
|
|
On June 18 2016 09:53 Nesserev wrote:Show nested quote +On June 17 2016 23:15 Hhanh00 wrote:On June 17 2016 21:46 Nesserev wrote: In the second case (multi-threaded), the framework usually calls a new thread for every eventhandler anwyay. The programmer doesn't have to manually manage the threads anymore. Think of JavaScript in your browser. What do you mean by that? Javascript is single-threaded or to be more precise event-loop and callback based. Oops, yeah... guess I shouldn't have used an example that I know nothing about. What I was trying to get at is that in some cases, the frameworks do not provide you with the necessary abstractions to handle events efficiently, in which case you have to resort to using your own threads, and some do. I think I started talking about single-threaded vs multi-threaded because of the examples in my mind.
I see. Every even-driven framework will run the callback or even-loop in a single thread (not necessarily always the same one). It's simply a model that makes sense since we can run multiple event loops if we want. At a higher level than a simple message loop, there is the actor model that adds fail-fast and recovery (baked in Erlang and ported to many other languages) or CSP (natively in Go and also ported to other languages). But if one prefers to stick with the bare metal, there are still a few wrappers that introduce very little overhead such as libevent, libev or libuv. Basically, this stuff is hard and bugs are even harder to figure out. For instance, spawning a new thread in a event handler is generally bad. Threads aren't that cheap. It would be preferable to have a scheduler with some work stealing algorithm.
|
Oh the joy of network communication... I have 2 components that communicate via TCP, everything works fine. Now another method of communication gets added and I have to change settings in the VM accordingly for the new method. Result: new method works fine, old method is partially broken, despite not having changed anything in the code. C2 somehow refuses all connections from C1, C1 still accepts all connections/messages from C2 and both have the exact same code for their client/server. There is no conflict with ports, I ruled out wrong adress, changing the VM on which C1/C2 runs doesn’t matter either. If I run C1 and C2 on the same VM and use localhost:port/0.0.0.0:port as addresses everything works. So why in the horned compilers name does C1 -> C2 doesn't work while C2 -> C1 does... Not asking for help, just having to vent a bit before I go for a walk... I love programming, I really do at least I will again after I figured this one out.
|
Maybe a firewall issue? C2 may not accept incoming connections but is OK connecting out.
|
Yeah but since the VMs are clones all settings are the same and it didn’t matter if C1 was running on VM1 or VM2. In the end apparently it was a router malfunction, checked my router and had weird logs, restarted it and everything works now.
To further bring you the joy of my programming life, over the last semester I did an awesome internship at a big software company where in the end I was practically treated like a proper member of their design team. I learned a lot, especially how important it is to really really define what you will deliver to the customer and have him agree to it. I tutor a course this semester and the prof asked me to hold a lecture about my internship and what I learned there which I apparently did to good of a job on.
The students had an assignment which unfortunately didn't listed the functions in the goal section but rather in the explanation of how it should works while in the goal section it is only stated that the program should never ever crash, while not stating that it should still give the proper result or even results at all. The end result was a flashback to this stackoverflow.com, namely:
catch all exceptions in the COM interface of our COM modules, and dispose them silently (this way, instead of crashing, a module would only appear to be faster... Shiny!... As we used the über error handling described above, it even took us some time to understand what was really happening... You can't have both speed and correct results, can you?).
Ever seen a main with a try-catch? Basically I have read multiple programs where either everything is in a try-catch block or the program simply restarts itself if feed with wrong input/something isn’t working for some reason. The icing on the cake was one program which did everything asked in the assignment perfectly and the only one so far which could be described as a perfect solution but also featuring a try-catch block in the main, commented as "just to be sure" and "thanks for the lecture on change-request management / requirement-management mr. waffelz" followed by a nice ascii-art.
So after a very entertaining talk with the professor, I now will give everyone at least a passing grade on this assignment and after that I have to review each and every one of his assignments and rework it regarding its requirements if needed xD
|
Hey folks, I'm trying to get Ubuntu set up again and I'm having trouble with the wireless for it.
This is an almost fresh install of Ubuntu over top of Windows on a fairly new computer. I have a USB wireless adapter, but it can not pick up any wireless signals. It works perfectly in Windows, and wired connections work fine.
lsusb Bus 001 Device 004: ID 13b1:003f Linksys WUSB6300 802.11a/b/g/n/ac Wireless Adapter [Realtek RTL8812AU]
sudo lshw -C network *-network DISABLED description: Wireless interface physical id: 1 bus info: usb@1:3 logical name: enxc8d719c160f1 serial: c8:d7:19:c1:60:f1 capabilities: ethernet physical wireless configuration: broadcast=yes driver=rtl8812au multicast=yes wireless=unassociated
If you could help me with this I'd appreciate it. I've spent hours digging through forum threads but all of them seem to be for Ubuntu 14, and I'm using Ubuntu 16.04.
|
|
To be honest, I couldn't properly explain because it was mostly blindly following instructions online 
I have enabled my wireless in the past and that didn't work.
I will try that tomorrow and report back. Thanks for the recommendation
|
|
|
|