Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Saturday, February 19, 2011

JavaScript: onMouseOver Event Not Working Properly With Other Events

Programmer Question

Hello,



I have a HTML webpage that contains a 15x15 table and I also have a small square div that follows the mouse when you press and hold the left mouse button on the div.



I have assigned an onmouseover event to the 15x15 table so that when the mouse hovers over a cell, a variable called "gridPlacement" is set the value of the unique id of the table cell the mouse hovered over.



The onmouseover event seems to work fine and instantly as soon as you hover over a cell the variable "gridPlacement" is set to the cell's id.



But when the onmousedown and onmousemove events are triggered (when the mouse presses and holds the left mouse button on the div I mentioned earlier), sometimes when you hover over a cell the variable "gridPlacement" isn't set, and sometimes you have to move your mouse over the cell a few times for it to work.



It seems the onmousedown and onmousemove events seem to have an impact on the onhover event on my 15x15 table.



Does anybody know why this happens and how I can work around this problem?



I hope you understand me, I've tried to explain my problem as best as I can.



Find the answer here

How can I detect window destruction from the main thread?

Programmer Question

Typically, the window procedure for a "main" window class would call PostQuitMessage in response to a WM_DESTROY message.



I would prefer to have the main thread decide when it wants to terminate based on the lifespan of the window(s) it creates. This way, whatever window class I choose to be the main window can have a generic window procedure that doesn't have PostQuitMessage in it.



while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);

if(msg.hwnd == hWnd && msg.message == WM_DESTROY)
{
PostQuitMessage(0);
}
}


The above is my attempt, but the WM_DESTROY message is never posted to the message queue, it seems to be internal to the window procedure.



Is there some way to accomplish this?



Find the answer here

Backbone.js versus Express versus Ext JS ...and JSPP?

Programmer Question

What are the pros and cons of Backbone.js, Express, Ext JS, and JSPP??



Find the answer here

Making similar app as already existing on App Store

Programmer Question

Hi,



Are there some restrictions for making an exact copy (with our own branding) of an app/game that is already there on App Store? i.e. copying the idea



Find the answer here

How to migrate MS access database to Oracle ?

Programmer Question

I am using SQL developer, but while capturing Models step executes, it gives me following error



oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:323)



Can anyone either tell me how to fix this issue or help in with an alternate way to migrate the database.



Find the answer here

Thursday, February 17, 2011

Identifying memory-mapped files

Programmer Question

Hello,



I'm identifying parts of process's virtual memory using VirtualQuery. I identify regions taken by mapped files (MEM_MAPPED), but how to determine actual files (filenames) of files allocated there? I suppose it has something to do with MapView* family of APIs but cant figure it out exactly...



Find the answer here

Log into twitter?

Programmer Question

Ok, basically what I am trying to do is get a boolean if I have logged in or not. I am using the Twitter4j library and they gave me the following three things to look at.



http://twitter4j.org/en/code-examples.html



https://github.com/yusuke/sign-in-with-twitter/blob/master/src/main/java/twitter4j/examples/signin/SigninServlet.java



https://github.com/yusuke/sign-in-with-twitter/blob/master/src/main/java/twitter4j/examples/signin/CallbackServlet.java



I have no idea how to log in and get if I logged in successfully.



Thanks, and I have no code btw... all I did was basically copy code and try different things.



PS. On a separate note how do I learn how to use someone elses library?



Find the answer here

extracting paragraph in python using lxml

Programmer Question

I would like to extract paragraphs in html by python. I used lxml module but it doesn't do exactly what I am looking for.



print html.parse(url).xpath('//p')[1].text_content()

Here is the First Paragraph.

Here is the second Paragraph.

Paragraph Three."




I should add that, in different pages I have different number of paragraph, so would like to make a list and put paragraph into it after that.



Find the answer here

Python super method and calling alternatives

Programmer Question

I see everywhere examples that super-class methods should be called by:



super(SuperClass, instance).method(args)


Is there any disadvantage to doing:



SuperClass.method(instance, args)


TIA, Ian



Find the answer here

Java performance multi-core testing environment

Programmer Question

I am interested in learning as much as i can about tuning a multi-threaded java server on a multi-core machine. I wanted to write some test servers that i could use to test different scenarios. For example thread pool sizing. Unfortunately i don't have access to a large multi-core unix (linux or solaris) machine. I just have duo-core mac laptop.



Are there any good lease options for a dedicated, say 8 to 16 core machine, that i could distribute my java test servers?



Find the answer here

Wednesday, February 16, 2011

How to check if a parameter of an inline function is known at compile time?

Programmer Question

Hello,



I have a performance critical inline function. It generates some data, based on a parameter. I want the compiler to optimize the data generation for all invocations, where the parameter is known at compile-time. The problem is that I can't force the compiler to put the optimized data out of the stack to a static constant, since marking the data static would break the case when parameter is not a compile-time constant. Having constant data on the stack hurts performance. Is there a way to deduce (maybe using templates/boost::enable_if), that the parameter is a compile-time constant and choose appropriate implementation of the data generation?



Disclaimer



This question is not the same as How to use different overload of an inline function, depending on a compile time parameter?. This is more generic problem.



Find the answer here

Monday, February 14, 2011

Running a Unix Executable Objective-C file in Java (OS X)

Programmer Question

I've seen this question asked before and tried following the solutions posted. Unfortunately, they aren't working. I'm trying to make a simple Java program that can run a compiled Objective-C program (Unix Executable file) with an input parameter. Below are the attempts at Java I have tried that don't seem to be working:



String[] cmd = {"/bin/bash", fullFilePath, Param};
Runtime.getRuntime().exec(cmd);


This is generating a Processor error of 126 for "Command invoked cannot execute". I've tried other variations that don't work as well such as:



String[] cmd = {"/bin/bash fullFilePath \"Param\""};
String[] cmd = {"/usr/bin/open fullFilePath \"Param\""};


Any suggestions or ideas on how I can get this to work? I just need to run the compiled Objective-C program in Java with the parameter. I figured it wouldn't be this hard. Thanks in advance, and if you need more information just ask.



Find the answer here

What's a good Flask/Python/WSGI analog to the PHP Apache shared memory stores like apc_store/apc_fetch?

Programmer Question

I've done a couple of years of large-scale game server development in PHP. A load balancer delegates incoming requests to one server in a cluster. In the name of better performance, we began caching all static data (essentially the game world's model objects) on each of the instances in that cluster, directly in Apache shared memory, using apc_store and apc_fetch.



For a number of reasons, we're now beginning to develop a similar game framework in Python, using the Flask microframework. At first glance, this instance's memory store is the one piece that doesn't appear to translate directly to Python/Flask. We're presently considering running Memcached locally on each instance (to avoid streaming fairly large model objects over-the-wire from our main Memcached cluster.)



What can we use instead?



Find the answer here

Regular Expression Help

Programmer Question

Trying to match a strings in notepad++ with a regular expression.



The string I'm trying to match is formatted like this:



^*^1st Choice Housing. Inc~*~


The carets and tildes serve as the delimiters around the name.



Here's the regular expression I'm trying to use to match any string between the delimiters



\^\*\^([A-Za-z0-9-.]+)\~\*\~


Notepad++ says 0 matches. What is wrong with my regular expression?



If I use:



\^\*\^1st Choice Housing. Inc\~\*\~


It matches.



Find the answer here

Sunday, February 13, 2011

Python always thinks my string is the highest possible number

Programmer Question

if month == 1 or 10:
month1 = 0
if month == 2 or 3 or 11:
month1 = 3
if month == 4 or 7:
month1 = 6
if month == 5:
month1 = 1
if month == 6:
month1 = 4
if month == 8:
month1 = 2
if month == 9 or 12:
month1 = 5


This code always returns month1 5. I'm quite new at programming, what am I doing wrong? (I guess it involves the fact that 12 is the highest number. But == means equals right?)



Find the answer here

Saturday, February 12, 2011

Can't get 1440x900 resolution with GRUB2 although vbeinfo says it's available

Programmer Question

I'm trying to use GRUB2 in graphical mode with 1440x900 resolution, but the result is always garbled nonsense: the highest resolution I can get is 1280x800.



Word is from googling that long as vbeinfo lists a resolution, GRUB2 can use it. This doesn't seem to be true: vbeinfo says that 1440x900 is available but it doesn't work.



Testing it from the GRUB2 command line:



set gxfmode=1440x900
terminal_output gfxterm
# -> garbled nonsense

# back to trusty 640x480
terminal_output console


The graphics card is an Intel GM965.



Find the answer here

Is it a real date, February 29, 2011 is not a real date

Programmer Question

Does PHP have a function that could help find out if a date is a real date. For example February 29, 2011 is not a real because this year February has only 28 days. This is the sort of "real date" I'm asking about. Does PHP have something to help?



Find the answer here

Strengths of Shell Scripting compared to Python

Programmer Question

I tried to learn shell(bash) scripting few times but was driven away by the syntax. Then I found Python and was able to do most of the things a shell script can do in Python. I am now not sure whether I should invest my time in learning shell scripting anymore. So I want to ask



What are strengths of shell scripting that make it an indispensable tool as compared to Python?



I am not a system administration by profession but am interested in setting up Linux systems for home users and hence think learning shell scripting can become necessary.



Find the answer here

How do I add new buttons to an existing form?

Programmer Question

Hi,



I want to add new buttons to an existing form.



I want one button that, when clicked, saves the filled in values and reloads the same form.



The second button should save the filled in values and redirect to another form.



How do I add new buttons to the form and provide actions to take for each button?



Find the answer here

Problem in showing progress bar while executing insert statement in android

Programmer Question

Hi,



Problem in showing progress bar while executing insert statement in android. While
calling this try block its showing blank screen. Not even xml is called while executing this statement.



try {
while ((str = in.readLine()) != null) {
try {
db.execSQL(str);
} catch (Exception e) {

}
}


Thanks,
Yuvaraj



Find the answer here

LinkWithin

Related Posts with Thumbnails