find

Rails find won't join when args appended...

I'm hoping I'm doing something wrong here and someone can point me in the right direction... I have written a method inside of one of my models, here is the code: def self.find_by_user_id(user_id, *args) self.find(:all, :joins => :case_map, :conditions => ['case_maps.uer_id = ? and case_maps.case_id = cases.id', user_id], ...

how to find files containing a string using egrep

I would like to find the files containing specific string under linux. I tried something like but could not succeed: find . -name *.txt | egrep mystring ...

Piping SQL to mysql via -find -exec

I cannot for the life of me get this. Example of fails, the last line of which adds in sed, which is the ultimate goal: find -maxdepth 1 -name "*.sql" -exec "mysql -D ootp < {}" \; find -maxdepth 1 -name "*.sql" -exec "mysql -D ootp << {}" \; find . -maxdepth 1 -name \"*.sql\" -exec /usr/bin/mysql -D ootp << sed -e 's/ , );/1,1);/g' {} ...

How can I make sure Ruby's Find module will always return absolute paths?

If I run the Find module with a relative directory as a parameter, the files returned by it will be relative ones. Can I do anything to make sure I always have absolute paths ? require "find" Find.find(dir) do |file| # do I need to make it absolute myself? will File#extend_path be enough? end ...

How to find and replace programmatically in ENTIRE Word document

I have a Word document with text in tables and text outside tables. I want to find and replace in all the text, not just the text outside the tables. The content property of the document is just the "main story" and not the tables. I don't want to iterate through all the table objects. I just want to find and replace in all the text, jus...

How do you use the Find method with a generic List class to find a specific instance by name

Hello, I have a system.collections.generic.list(of ListBox) I would like to use the collection classes built-in Find method to find a particular ListBox by the Name of the Listbox I found the following MSDN article http://msdn.microsoft.com/en-us/library/x0b5b5bc.aspx This does not work for me because it does not show how to find a...

Find All URLs on Page Using jQuery

I need to find all the URLs on the page using jQuery. They will be static URLS, by that I mean not within anchor tags. ...

How can I escape the slash character in vi?

When I try to search a string starting with the slash / character in vi, the cursor jumps to the next search result from the previous search. However, I'd like to find the literal slash character. How can this be done? ...

Use find, wc, and sed to count lines

I was trying to use sed to count all the lines based on a particular extension. find -name '*.m' -exec wc -l {} \; | sed ... I was trying to do the following, how would I include sed in this particular line to get the totals. ...

In RegEx, how do you find a line that contains no more than 3 unique characters?

Hey guys, I am looping through a large text file and im looking for lines that contain no more than 3 different characters (those characters, however, can be repeated indefinitely). I am assuming the best way to do this would be some sort of regular expression. All help is appreciated. (I am writing the script in PHP, if that helps) ...

How to select where ID in Array Rails ActiveRecord without exception

When I have array of ids, like ids = [2,3,5] and I perform Comment.find(ids) everything works fine. But when there is id that doesn't exist, I get an exception. This occurs generaly when I get list of IDs that match some filter and than I do something like current_user.comments.find(ids) This time I may have a valid comment ID, ...

How to get all tags that do NOT have posts associated in CakePHP

Hi, I'm doing a blog in CakePHP, so I have two tables in my database that are HABTM related: posts and tags. Because they are HABTM related I also have a poststags table keeping track of relations. I'd like to have a method in my tags_controller that will delete all unused tags. How do I find all tags that are NOT associated with any ...

Best way to find position in the Stream where given byte sequence starts

How do you think what is the best way to find position in the System.Stream where given byte sequence starts (first occurence): public static long FindPosition(Stream stream, byte[] byteSequence) { long position = -1; /// ??? return position; } P.S. The simpliest yet fastest solution is preffered. :) ...

Is it possible to dock the "Find/Replace" window in Eclipse?

I could have sworn I saw it once before in a screencast where someone had the find/replace window docked in their Eclipse environment. However looking through the list of options in "Window > Show" the closest thing I can find is the Search window. I find that I use it quite a bit and with larger monitors these days I figure I could af...

Trying to find groups of letters with regex

Hey everyone, I need to find 1 or more defined groups of characters enclosed in parentheses. If more than one group is present it will be separated with a hyphen. Example: (us) (jp) (jp-us) (jp-us-eu) I've figured out how to find the group if the string only contains one group: /\(us\)|\(jp\)/ However, I am baffled when it comes ...

Finding/Handling stalled PHP scripts

I use Ajax to kick off a PHP script that can take a few hours to run. It's done asynchronously so the PHP script will complete even if the browser is closed. I need to handle any of these PHP scripts that have stalled/hung for whatever reason. What is the best way to go about this? Is there a way to get a process id for the PHP scrip...

Python Script to find instances of a set of strings in a set of files

Hi all, I have a file which I use to centralize all strings used in my application. Lets call it Strings.txt; TITLE="Title" T_AND_C="Accept my terms and conditions please" START_BUTTON="Start" BACK_BUTTON="Back" ... This helps me with I18n, the issue is that my application is now a lot larger and has evolved. As such a lot of these s...

jquery: find element whose id has a particular pattern

I am trying to find a span element who has an id in a particular pattern. Its main use is to find certain elements rendered by an asp.net (aspx) page which is derived from a master page. ...

Search Hex substring in string

Hi all! Well i got a socket that receives binary data and I got that data into an string, containing values and strings values too. (for example "0x04,h,o,m,e,....") How can i search for an hex substring into that string? I.e. i want to search "0x02,0x00,0x01,0x04". I'm asking for a c++ version of python 'fooString.find("\x02\x00\x01...

How to use '-prune' option of 'find' in sh?

I don't quite understand the example given from the 'man find', can anyone give me some examples and explanations? Can I combine regular expression in it? the more detailed question is like this: write a shell script, changeall, which has an interface like "changeall [-r|-R] "string1" "string2". It will find all files with an suffix ...