jQuery find elements with value = x

If the value is hardcoded in the source of the page using the value attribute then you can $(‘#attached_docs :input[value=”123″]’).remove(); or $(‘#attached_docs :input’).filter(function(){return this.value==’123′}).remove(); demo http://jsfiddle.net/gaby/RcwXh/2/

How to remove trailing whitespaces for multiple files?

You want sed –in-place ‘s/[[:space:]]\+$//’ file That will delete all POSIX standard defined whitespace characters, including vertical tab and form feed. Also, it will only do a replacement if the trailing whitespace actually exists, unlike the other answers that use the zero or more matcher (*). –in-place is simply the long form of -i. I …

Read more

Find and replace words/lines in a file

Any decent text editor has a search&replace facility that supports regular expressions. If however, you have reason to reinvent the wheel in Java, you can do: Path path = Paths.get(“test.txt”); Charset charset = StandardCharsets.UTF_8; String content = new String(Files.readAllBytes(path), charset); content = content.replaceAll(“foo”, “bar”); Files.write(path, content.getBytes(charset)); This only works for Java 7 or newer. If …

Read more

pandas – find first occurrence

idxmax and argmax will return the position of the maximal value or the first position if the maximal value occurs more than once. use idxmax on df.A.ne(‘a’) df.A.ne(‘a’).idxmax() 3 or the numpy equivalent (df.A.values != ‘a’).argmax() 3 However, if A has already been sorted, then we can use searchsorted df.A.searchsorted(‘a’, side=”right”) array([3]) Or the numpy …

Read more

Unix find: multiple file types

$ find . -name ‘*.h’ -o -name ‘*.cpp’ To find this information in the man page, type man find and the search for operators by typing /OPERATORS and hit enter. The . isn’t strictly necessary with GNU find, but is necessary in Unix. The quotes are important in either case, and leaving them out will …

Read more