simulation

How to simulate a corrupt state exception in .NET 4?

℡╲_俬逩灬. 提交于 2019-11-27 23:05:27
Well, in .NET 4 Microsoft added the HandleProcessCorruptedStateExceptions attribute: HandleProcessCorruptedStateExceptionsAttribute Class I want to test this feature. How can I bring my application to a "corrupt state"? Screwing up the garbage collected heap is always a good way: using System; using System.Runtime.InteropServices; class Program { unsafe static void Main(string[] args) { var obj = new byte[1]; var pin = GCHandle.Alloc(obj, GCHandleType.Pinned); byte* p = (byte*)pin.AddrOfPinnedObject(); for (int ix = 0; ix < 256; ++ix) *p-- = 0; GC.Collect(); // kaboom } } Just dereference a

Simulating keystrokes in python using pywin32

前提是你 提交于 2019-11-27 16:54:31
问题 I am looking to simulate keystrokes in python 3.2 in windows 7 to be sent to a GUI.I have python win32 module installed on my pc.The order is alt+t+r+name+enter.What would be the best way of sending these keystrokes to the active window?any sample code would be of a great help. Thanking you. (I have seen some module called sendkeys but can that be used with pywin32?i am not allowed to install any other modules) 回答1: I know this may not be perfect. We have a testing application using python 2

source of historical stock data [closed]

会有一股神秘感。 提交于 2019-11-27 16:33:09
I'm trying to make a stock market simulator (perhaps eventually growing into a predicting AI), but I'm having trouble finding data to use. I'm looking for a (hopefully free) source of historical stock market data. Ideally, it would be a very fine-grained (second or minute interval) data set with price and volume of every symbol on NASDAQ and NYSE (and perhaps others if I get adventurous). Does anyone know of a source for such info? I found this question which indicates Yahoo offers historical data in CSV format, but I've been unable to find out how to get it in a cursory examination of the

Recursion in Python? RuntimeError: maximum recursion depth exceeded while calling a Python object [duplicate]

社会主义新天地 提交于 2019-11-27 16:23:45
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Maximum recursion depth? I have another problem with my code. I'm wrtiting my first program in Vpython and I have to make a simulation of mixing two gases. First i had a problem with borders, but now when the balls(that represents the gas particles) stay within the borders there is sth different wrong. After a few seconds i get an error, which is shown below the source code of my function. Code: def

Three.js Retrieve data from WebGLRenderTarget (water sim)

…衆ロ難τιáo~ 提交于 2019-11-27 13:29:34
问题 I am trying to port this (http://madebyevan.com/webgl-water/‎) over to THREE. I think I'm getting close (just want the simulation for now, don't care about caustics/refraction yet). I'd like to get it working with shaders for the GPU boost. Here's my current THREE setup using shaders: http://jsfiddle.net/EqLL9/2/ (the second smaller plane is for debugging what's currently in the WebGLRenderTarget) What I'm struggling with is reading data back from the WebGLRenderTarget (rtTexture in my

numpy array of objects

可紊 提交于 2019-11-27 10:34:06
问题 I'm trying to implement a simulation for a lattice model (lattice boltzmann) in Python. Each site of the lattice has a number of properties, and interact with neighboring sites according to certain rules. I figured that it might be clever to make a class with all the properties and make a grid of instances of that class. (As I'm inexperienced with Python, this might not be a good idea at all, so feel free to comment on my approach.) Here is a toy example of what I'm doing class site: def _

Suggestions for Python debugging tools? [closed]

不羁岁月 提交于 2019-11-27 09:25:17
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . Yesterday I made a simulation using Python. I had a few difficulties with variables and debugging . Is there any software for Python, which provides a decent debugger? Related question: What is the best way to debug my Python code? 回答1: Don't forget about post-mortem debugging! After an exception is thrown, the

What's the difference between emulation and simulation? [duplicate]

天大地大妈咪最大 提交于 2019-11-27 09:00:19
问题 Possible Duplicate: Simulator or Emulator? What is the difference? In simple understandable terms, what is the difference between the two terms? [I have already looked at this, this and this] 回答1: (Using as an example your first link) You want to duplicate the behavior of an old HP calculator, there are two options: You write new program that draws the calculator's display and keys, and when the user clicks on the keys, your programs does what the old calculator did. This is a Simulator You

How to simulate a mouse movement

≡放荡痞女 提交于 2019-11-27 07:07:49
How can I simulate a mouse event causing the pointer to move 500 pixels to the left, then click using C++. How would I do something like this? Here's some modified Win32 code I had lying around: #define WIN32_LEAN_AND_MEAN #define _WIN32_WINNT 0x0500 #include <stdio.h> #include <stdlib.h> #include <time.h> #include <conio.h> #include <string.h> #include <windows.h> #define X 123 #define Y 123 #define SCREEN_WIDTH 1024 #define SCREEN_HEIGHT 800 void MouseSetup(INPUT *buffer) { buffer->type = INPUT_MOUSE; buffer->mi.dx = (0 * (0xFFFF / SCREEN_WIDTH)); buffer->mi.dy = (0 * (0xFFFF / SCREEN_HEIGHT

How to simulate a corrupt state exception in .NET 4?

♀尐吖头ヾ 提交于 2019-11-26 21:18:02
问题 Well, in .NET 4 Microsoft added the HandleProcessCorruptedStateExceptions attribute: HandleProcessCorruptedStateExceptionsAttribute Class I want to test this feature. How can I bring my application to a "corrupt state"? 回答1: Screwing up the garbage collected heap is always a good way: using System; using System.Runtime.InteropServices; class Program { unsafe static void Main(string[] args) { var obj = new byte[1]; var pin = GCHandle.Alloc(obj, GCHandleType.Pinned); byte* p = (byte*)pin