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
Hi,
I have the following problem. After I uninstall the project - all folder is removing. But it contains the files which shouldn't be deleted. What could you advice me?
Ideally I would haeve the option which will be proposed to the user while uninstall with checkbox if it is necessary to delete this folder or not.
Thank you in advance!
I'm getting really desperate trying to add a UIImageView to UITableViewCell.backgroundView. All my efforts have resulted in this crappy rendering:
It looks like the cell's label's white background is sitting on top of cell's background and covering portions of it.
I tried setting the label's background color to clear, or some other color and it does not have any event. It is always white.
The reason I know it's the text label's background causing this white area is that if I don't do [cell setText:@"Cell text here"]; the white area is gone and I see just the cell's background image.
Here's the code that I'm using. The table view is added in the .xib file and UITableView is added to UIViewController:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [myCollection.items count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger rowIndex = indexPath.row;
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"darkCellBackground.png"]];
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"darkCellBackground.png"]];
}
[cell setText:@"Cell text here"];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
// AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
// [self.navigationController pushViewController:anotherViewController];
// [anotherViewController release];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}
I'm sure I'm doing something wrong but cant quite figure out what.
I have 2 z-index layers in a map application I'm building. I have a problem when I click on the layers to zoom in. The click handler is on the underlying z-index layer and I don't want it to fire when a control in the overlying layer is clicked.
The problem i have is that the event gets raised no matter what but the originalTarget property of the event is not the image in the underlying layer when something on the top layer is clicked. Is there anyway to change this?
What's the best solution for embedding non-web fonts into a page without using Flash and still maintaining cross-browser support? Has anyone used any JavaScript libraries for this? Thanks.
I am writing a perl routine that mounts specific drives at startup. However, when the drives are mounted, they appear in "My Computer" with odd names like "dir$ at 'machinename' (H:)".
Is there a way in perl or C to specify this string (or just the 'dir$' part?) at mount-time?
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?
Not sure if this kind of help is accepted to ask for here, tell me if it isn't.
It has to get done before tomorrow, it's not entirerly finished but it should work somewhat ok by now. I'm trying to use the Eclipse debugger (not very used to it).
I have my top-level or main class, which is Game, in which I have a constructor and a main method. In the main method I create a new "Game", initiating the constructor.
public static void main(String[] args){
Game chess = new Game();
}
public Game(){
Board board = new Board();
That's the first thing the debugger reacts to:
Thread [main] (Suspended)
ClassNotFoundException(Object).<init>() line: 20 [local variables unavailable]
ClassNotFoundException(Throwable).<init>(String, Throwable) line: 217
ClassNotFoundException(Exception).<init>(String, Throwable) line: not available
ClassNotFoundException.<init>(String) line: not available
URLClassLoader$1.run() line: not available
AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method]
Launcher$ExtClassLoader(URLClassLoader).findClass(String) line: not available
Launcher$ExtClassLoader.findClass(String) line: not available
Launcher$ExtClassLoader(ClassLoader).loadClass(String, boolean) line: not available
Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available
Launcher$AppClassLoader.loadClass(String, boolean) line: not available
Launcher$AppClassLoader(ClassLoader).loadClass(String) line: not available
Game.<init>() line: 15
Game.main(String[]) line: 11
Line 11 is the one line in my main method, line 15 is the instantiation of "board".
I've subclassed MKAnnotation so that i can assign objects to annotations and then assign this object to a view controller like so:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
PlaceDetailView *detailView = [[PlaceDetailView alloc] initWithStyle:UITableViewStyleGrouped];
detailView.place = [view.annotation place];
[self.navigationController pushViewController:detailView animated:YES];
[detailView release];
}
This is working great but i'm having the following issues:
If i try and access the place getter method like so view.annotation.place i recieve an error:
Accessing unknown place getter method
If i acces the place getter method like so [view.annotation place] i receive a warning:
place not found in protocol
From my understanding this is because the place object is not defined in the MKAnnotation protocol, although i'm aware of this i'm not sure how to tell the complier that place does exist and it's not calling it blind.
In bootstrap.php, where you set routes, I'm having a hard time getting them to work. I read some documentation a while ago that I can't seem to find again that explains them. Here is one of my examples
Route::set('products', 'products/(type)', array('type' => '.+'))
->defaults(array(
'controller' => 'articles',
'action' => 'view_product',
'page' => 'shock-absorbers',
));
I thought that would mean a request like products/something would load up the articles controller, and the action_view_product method. But I can't get it to work.
Can someone please explain to me exactly how they work, and what all the method parameters are?
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'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'm dealing with a database structure that can be defined as "illogical". It has about 100 different schema's with all different table structures per schema. Only one common factor is a "Version" table in each schema containing about 4 fields. (Thus, there are about 100 Version tables in the database.) There's also another table (view, actually) containing a list of all the schema's in the database that have a version table.
I need a stored procedure that walks through all the schema's and selects all data from the Version table, adding the schema name as a fifth field to the result. Basically, this stored procedure is to return a list of all version records per schema.
My idea: first walk through the schema list to create one new SQL statements that will JOIN all the schema.version tables into one SQL statement. Then I return the result of that query.
How to do this? Or does anyone have a better suggestion?
(No, redesigning the structure is NOT an option.)
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.
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'm in the process of creating an SSIS package on a server (server1) that looks at the data in a sql db on another site (server2) and copies relevant rows across.
The SQL statement required is:
SELECT *
FROM server2.ordersTable
WHERE
OrderID Not In (SELECT OrderID FROM server1.ordersTable
This selects data from server1 which isn't in the table on server2 (based on order id)
I then need to insert the result into a table on server1
How would I approach this? What components do I need etc...?
Hi. We're building a site and wish to build for the same set of browsers Google Apps/Docs and YouTube support. Though not recommended, they seem to be detecting specific browsers/versions vs. features/functionality. What's the best way to support a minimum set of browsers while displaying a message to the users of older browsers to upgrade? What's the minimum set of browsers that the major sites are supporting? 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.