Usually, when people click on a link, I have onclick bound to it. And then return false.
When people click with "control", they expect a new page to open up. Therefore, I want to ignore the onclick AND/OR detect it. How do I do this?
In R, what is the most efficient way to count the length between 2 values. for example, i have vector x , which are all randomly choose from 1 to 100, how can i find out the length between the first"2" and first"40",
x=(1,2,3,4,5,6,7,40,1,2,3,21,4,1,23,4,43,23,4,12,3,43,5,36,3,45,12,31,3,4,23,41,23,5,53,45,3,7,6,36)
for this vector, the answer should be 5 and 6
I am looking for a way to show my own input view (a UITableView) to enter certain keywords in a UITextView faster than typing them, and also be able to type into this text view the normal way. My solution has a button that causes the keyboard to disappear, revealing the table view underneath it.
Problem is I can't figure out how to make the keyboard go away without resigning first responder, and losing the cursor. Has anyone accomplished this before?
Thanks for any help.
Hi all:
I am working on a C# application that involves using XML schema file as databases for message definitions and XML file as databases for message data.
I was following the example I found:http://msdn.microsoft.com/en-us/library/system.xml.xmldatadocument.dataset%28v=VS.100%29.aspx
I wrote my own xsd and XML file. I used the same approach in the example, read the xsd file and then load
the xml file. But I don't have any "Rows" created for my DataTable. I used debugger to step through my codes. When I am get my DataTable use xmlDataDocument.DataSet.Tables["name of the table"], the Rows property of that tables is 0.
Does anybody know what might cause the DataSet tables not get populated after I loaded the xmlDataDocument with XML file?
Here is a fragment of XSD file:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="test"
targetNamespace="http://tempuri.org/test.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/test.xsd"
xmlns:mstns="http://tempuri.org/test.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:element name="reboot_msg">
<xs:complexType>
<xs:complexContent>
<xs:extension base="header_s">
<xs:sequence>
<xs:element name="que_name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="4"/>
<xs:maxLength value="8"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="priority" type="xs:unsignedShort"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
and here is a fragment of the XML file:
<?xml version="1.0" standalone="yes"?>
<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<reboot_msg>
<message_length>16</message_length>
<message_type>7</message_type>
<message_sequence>0</message_sequence>
<que_name>NONE</que_name>
<priority>5</priority>
</reboot_msg>
It could be the XML and XSD file I created missed something. Please help.
Thanks
Hey all,
I'm practicing Jquery and I've written this simple Jquery statement:
var someText = $("table tr td").text();
Should this not return all text of td elements found within tr's that are found within tables? How do I fix this? Currently when I run this, it says that table tr td is null, but I have a table on the page I'm testing on.
Thanks!
I am designing a web site in which users solve puzzles as quickly as they can. JavaScript is used to time each puzzle, and the number of milliseconds is sent to the server via AJAX when the puzzle is completed. How can I ensure that the time received by the server was not forged by the user?
I don't think a session-based authenticity token (the kind used for forms in Rails) is sufficient because I need to authenticate the source of a value, not just the legitimacy of the request.
Is there a way to cryptographically sign the request? I can't think of anything that couldn't be duplicated by a hacker. Is any JavaScript, by its exposed, client-side nature, subject to tampering? Am I going to have to use something that gets compiled, like Flash? (Yikes.) Or is there some way to hide a secret key? Or something else I haven't thought of?
Update: To clarify, I don't want to penalize people with slow network connections (and network speed should be considered inconsistent), so the timing needs to be 100% client-side (the timer starts only when we know the user can see the puzzle). Also, there is money involved so no amount of "trusting the user" is acceptable.
Hi. This question isn't about popping up an iframe inside a Lightbox; rather, it's about an iframe on a page that can launch its own Lightbox-style box in the page that contains that iframe. I'm thinking this can't be possible, because the iframe contains the contents of the other URL and whatever Lightbox that URL launches has to fit within the iframe. Thanks.
The reason I'm asking is because I'm getting NullPointerException.
I now this is very easy but I'm pretty new programming and find this a bit confusing.
So say I have initialized an object in a class and want to access that same object from another class.
Like now for instance I'm working on a small Chess game, in my model Game class I have an instance of Board, an object. Board, in turn, has an array of Squares. Square[][].
Game has board, board has Square[][].
Now if I want to access the Square[][] through the object board (in Game) of type Board.
Do I just declare a variable with the same name and type or do I have to initialize it again?
Board board OR Board board = new Board();
Note, I have already initialized board in the class Game so if I do it again, won't they be two totally different Board objects?
I have recently become the proud owner of two monitors in my workspace. (Ok not owner, but you know what I mean) and I'd like to use both of them at once.
Problem is, I much much prefer to use a Linux Server console over a desktop environment.
The graphics card on the machine is a GTX295 (don't ask why, it's a long story.) so I essentially have two graphics cards. Each has a DVI output. Is there any way I can get the console to stretch across two screens? Or will I have to install a desktop Ubuntu for this to work?
I'm a real newbie to java, so please excuse me if this is a hopelessly straightforward problem.
I have the following from my java game server:
// Get input from the client
DataInputStream in = new DataInputStream (server.getInputStream());
PrintStream out = new PrintStream(server.getOutputStream());
disconnect=false;
while((line = in.readLine().trim()) != null && !line.equals(".") && !line.equals("") && !disconnect) {
System.out.println("Received "+line);
if(line.equals("h")){
out.println("h"+EOF); // Client handshake
System.out.println("Matched 1");
}else if (line.equals("<policy-file-request/>")) {
out.println("..."+EOF); // Policy file
System.out.println(server.getInetAddress()+": Policy Request");
disconnect=true;
System.out.println("Matched 2");
}else if(line.substring(0,3).equals("GET")||line.substring(0,4).equals("POST")){
out.println("HTTP/1.0 200 OK\nServer: VirtuaRoom v0.9\nContent-Type: text/html\n\n..."); // HTML status page
disconnect=true;
System.out.println("Matched 3");
} else {
System.out.println(server.getInetAddress()+": Unknown command, client disconnected.");
disconnect=true;
System.out.println("Matched else");
}
}
server.close();
First of all, the client sends an "h" packet, and expects the same back (handshake). However, I want it to disconnect the client when an unrecognised packet is received. For some reason, it responds fine to the handshake and HTML status request, but the else clause is never executed when there's an unknown packet.
Thanks
I could have sworn I used a chr() function 40 minutes ago but can't find the file. I know it can go up to 256 so I use this:
std::string chars = "";
chars += (char) 42; //etc
So that's alright, but I really want to access unicode characters. Can I do (w_char) 512? Or maybe something just like the unichr() function in python, I just can't find a way to access any of those characters.
I was looking at the metadata for System.Web.Configuration.CompilationSection, and noticed the following attribute on the TimeSpan BatchTimeout property:
[TimeSpanValidator(MinValueString = "00:00:00",
MaxValueString = "10675199.02:48:05.4775807")]
Could someone explain why this is the allowed max value? TimeSpan itself has an upper limit, so why would there be another value validation, and why this number?
I'm implementing a checking system in Ruby. It runs executables with different tests. If the solution is not correct, it can take forever for it to finish with certain hard tests. That's why I want to limit the execution time to 5 seconds.
I'm using system() function to run executables:
system("./solution");
.NET has a great WaitForExit() method, what about Ruby?.
Is there a way to limit external process' execution time to 5 seconds?
Thanks
I'm having problem loading a json resource from a local rails app with jQuery 1.4.4
The json is valid (based on jsonlint.com) and I can download it properly if I'm requesting it from other sources.
In webkit (Safari), I got this error:
Failed to load resource: cancelled
Response Header on Firebug:
Content-Type application/json; charset=utf-8
Set-Cookie geoloc=toulouse; path=/;
Connection close
Server thin 1.2.7 codename No Hup
jQuery code to load json:
$.getJSON("http://127.0.0.1/search_agenda",
{'edition': edition,
'categories': categories},
function(data){
console.log(data);
}
});
I have a header menu and try to define different CSS classes for each item.
This is what I have:
20 = HMENU
20 {
special = directory
special.value = 107
1 = TMENU
1 {
wrap = <ul class="foo" id="mymenu">|</ul>
expAll = 1
NO = 1
NO.allWrap = <li class="first menu_{field:uid}">|</li> || <li class="menu_{field:uid}">|</li> || <li class="last menu_{field:uid}">|</li>
}
}
But in the HTML output I simply get class="first menu_{field:uid}" and nothing is replaced.
How do I accept data on the backside of a utility app, and then how do I let users modify that data? I've tried all sorts of tutorials, but to no avail. If you need further information let me know. Thanks in advanced.
I'm displaying a popup menu using TrackPopupMenu and would like to know when it is dismissed via clicking outside of it. I've looked through all the menu functions but didn't find anything useful in this regard. Spy++ told me that no window message is sent in this case.
So, is there an easy way to do it without installing a mouse hook? Thanks!
Hello all!
I have an array and variable.
If the variable does not exist in the array it has to be added, otherwise it has to be removed.
Why the following code does not work?
$ar = ["a","b","c"];
$vr = "b";
foreach ($ar as $i => $value) {
if ($value == $vr) {
unset ($ar[$i]);
} else {
$ar[] = $vr;
$ar = array_unique($ar);
}
}
Thanks.