find

Howto - JavaScript Replace which finds all instances not just the first

I have the following function: listorder = listorder.replace('projectlist-',''); Problem with this is it only finds and replace the first instance and there are many. How can this be updated to Find/Replace All instances in the string? Thanks ...

Rails: using find method to access joined tables for polymorphic relationships

Ok, I have a generic TimeSlot model that deals with a start_at and an end_at for time spans. A couple models derive from this but I'm referring to one in this question: AppointmentBlock which is a collection of Appointments. I want to validate an AppointmentBlock such that no other AppointmentBlocks have been scheduled for a particular E...

Can you tell me about a decent ruby gem that I can use for complex joins?

Piggy backing off another question I posted, I have a complex find() that changes whether or not a certain id is nil or not. See here: if self.id.nil? blocks = AppointmentBlock.find(:first, :conditions => ['appointment_blocks.employee_id = ? and ' + '(time_slots.start_at between ? and ? or time_slots.end_at bet...

Running a Model::find in for loop in cakephp v1.3

Hi all, How can I achieve the following result in cakephp: In my application a Topic is related to category, category is related to city and city is finally related to state in other words: topic belongs to category, category belongs to city , city belongs to state.. Now in the Topic controller's index action I want to find out all t...

Rails: find_by, conserving leading whitespaces

Hi, when I do the following def somefunction @texts = A.find_all_by_someid(someid) respond_to do |format| format.xml { render :xml => @texts } end end it gets the string from the db correctly, except if the string has leading whitespaces, it seems they are trimmed. Note: the whitespaces are there in the db...

How can I make named_scope in Rails return one value instead of an array?

I want to write a named scope to get a record from its id. For example, I have a model called Event, and I want to simulate Event.find(id) with use of named_scope for future flexibility. I used this code in my model: named_scope :from_id, lambda { |id| {:conditions => ['id= ?', id] } } and I call it from my controller like Event.fr...

jquery .find to get the text in a <li>

So I have a series of 2 nested ul's. When you click on the text (which is in an a tag) in the li, my page makes that editable and adds a save button. clicking the save button needs to give me back the new text inside that li and the id of that li. The id is not a problem. I'm trying to use jQuery's .find to select that anchor tag (wh...

File::Find and $_ in nested subroutines.

When running the following code, the filenames of all files below C:\Test are printed. Why doesn't it print just Hello (n times, depending on how many files are processed)? Does this imply that I cannot rely on shift to reliably assign to $_? Imagine a coworker implements the wtf function and doesn't know that it's called from a File::...

tarring find results on hp-ux

$ find /tmp/a1 /tmp/a1 /tmp/a1/b2 /tmp/a1/b1 /tmp/a1/b1/x1 simply trying find /tmp/a1 -exec tar -cvf dirall.tar {} \; simply doesn't work any help ...

Ruby find method with select

I can't seem to get this one right at the moment. I want distinct records but I need other attributes to come along with the results of the find method. Current nonworking code is: Visit.find(:all, :select => "user_id, DISTINCT cookie") ...

jquery to grab link and text based on class

Hi all, I'm trying to use jquery to grab the entire link depending on it's class. Here's my code: <ul class="vm_catTigra"> <li><a class="mainlevel" href="/index.php&amp;category_id=6">AAAAA</a></li> <li><a class="mainlevel" href="/index.php&amp;category_id=10">BBBBB</a></li> <li><a class="sublevel" href="/index.php&amp;category...

Searching NSString in XML database, Iphone

My project is like a classifieds kind of stuff.. I have a search text box in the first page. When the user enters some text in that, i need to compare that text to the XML file from where all the data are being recieved, and should list out all the advertisements in the Table View (next page).. I had did this kind of search in sql dat...

jQuery prevAll displaying text in backward ordering

hi all, I'm trying to use jQuery to get all the paragraphs before the first h2 tag in my content. Here's the code I'm using: $(".content").find("h2:first").prevAll().text() Which is grabbing the content, although it's displaying it in backwards order. Example content: <div class="content"> <p>paragraph 1</p> <p>paragraph 2</p> ...

grails find first

I know this is simple question but taking more time How to find first record from table in grails . I need to get only the first record with out knowing the id number . Is there any method like find :first in grails ? thanks in advance . ...

Is there a problem with the Gnuwin32 port of "find"?

Is there a problem with the Gnuwin32 port of "find"? It sort of works on my Windows XP command line, but I get blank stares when I try using file name pattern matching function. It's from "findutils-4.2.20" package. Had to rename to "gfind.exe" so Windows wouldn't confuse with CMD.EXE's "find". Some samples from my Windows console: C...

search a string in a file as ignoring the lines beginning with #

I want to find a string such as "qwertty=" in a file with "awk" or "grep" but I don't want to see the lines with #. Please see the example grep -ni "qwertty" /aaa/bbb 798:# * qwertty - enable/disable 1222:#qwertty=1 1223:qwertty=2 1224:#qwertty=3 I want to find the line 1223. What should be the search query for this purpose? ...

Find items with belongs_to associations in Rails?

Hi Everyone, I have a model called Kase each "Case" is assigned to a contact person via the following code: class Kase < ActiveRecord::Base validates_presence_of :jobno has_many :notes, :order => "created_at DESC" belongs_to :company # foreign key: company_id belongs_to :person # foreign key in join table belongs_to :survey...

Java - Could not find the main class?

I'm having a hard-time with a Java error. I'm getting this when double-clicking on my compiled project Jar file in order to run it: Could not find the main class: testPackage.testFrame. Program will exit. However, my main class is cleary defined in the project properties. Furthermore, everything works fine when I run the project direc...

Saving substrings using Regular Expressions

I'm new to regular expressions in Java (or any language, for that matter) and I'm wanting to do a find using them. The tricky part that I don't understand how to do is replace something inside the string that matches. For example, if the line I'm looking for is Person item6 [can {item thing [wrap]}] I'm able to write a regex that fin...

can't find variable: $j

Ahh i'm stuck again. helpp why do i encounter this "can't find variable: $j" when i use this method function myMethod(htmlObject) { var buttonTags = $j("button",htmlObject); ... } Sorry for askin silly questions again. running outta time =\ THANKS FOR THEHELP! ...