diff

Filtering a diff with a regular expression

有些话、适合烂在心里 提交于 2019-11-26 17:12:44
问题 It seems that it would be extremely handy to be able to filter a diff so that trivial changes are not displayed. I would like to write a regular expression which would be run on the line and then pass it another string that uses the captured arguments to generate a canonical form. If the lines before and after produce the same output, then they would be removed from the diff. For example, I am working on a PHP code base where a significant number of array accesses are written as my_array[my

Anyone have a diff algorithm for rendered HTML? [closed]

二次信任 提交于 2019-11-26 16:59:50
I'm interested in seeing a good diff algorithm, possibly in Javascript, for rendering a side-by-side diff of two HTML pages. The idea would be that the diff would show the differences of the rendered HTML. To clarify, I want to be able to see the side-by-side diffs as rendered output. So if I delete a paragraph, the side by side view would know to space things correctly. @Josh exactly. Though maybe it would show the deleted text in red or something. The idea is that if I use a WYSIWYG editor for my HTML content, I don't want to have to switch to HTML to do diffs. I want to do it with two

diff two big files in Python

佐手、 提交于 2019-11-26 16:32:46
问题 I have two big text files, near 2GB each. I need something like diff f1.txt f2.txt . Is there any way to do this task fast in python? Standard difflib is too slow. I assume there is faster way, because difflib is fully implemented in Python. 回答1: How about using difflib in way that you script can handle big files? Don't load the files in memory, but iterate through the files of the files and diff in chunks. For e.g 100 lines at a time. import difflib d = difflib.Differ() f1 = open('bigfile1')

Where does the excerpt in the git diff hunk header come from?

一笑奈何 提交于 2019-11-26 16:24:48
问题 When I use git diff on a C# file, I see something like this: diff --git a/foo.cs b/foo.cs index ff61664..dd8a3e3 100644 --- a/foo.cs +++ b/foo.cs @@ -15,6 +15,7 @@ static void Main(string[] args) string name = Console.ReadLine(); } Console.WriteLine("Hello {0}!", name); + Console.WriteLine("Goodbye"); } } } The hunk header line contains the first line of the current method ( static void Main(string[] args) ), which is great. However it doesn't seem to be very reliable... I see many cases

Getting a diff of two json-objects

柔情痞子 提交于 2019-11-26 16:13:47
问题 Scenario: I want a function that compares two JSON-objects, and returns a JSON-object with a list of the differences and if possible more data such as coverage metrics. var madrid = '{"type":"team","description":"Good","trophies":[{"ucl":"10"}, {"copa":"5"}]}'; var barca = '{"type":"team","description":"Bad","trophies":[{"ucl":"3"}]}'; If i ran compare(madrid, barca) the returned object could look something like: {"description" : "Bad", "trophies":[{"ucl":"3"}, {"copa":"5"}]}; Or something

R how can I calculate difference between rows in a data frame

吃可爱长大的小学妹 提交于 2019-11-26 16:13:34
问题 Here is a simple example of my problem: > df <- data.frame(ID=1:10,Score=4*10:1) > df ID Score 1 1 40 2 2 36 3 3 32 4 4 28 5 5 24 6 6 20 7 7 16 8 8 12 9 9 8 10 10 4 > diff(df) Error in r[i1] - r[-length(r):-(length(r) - lag + 1L)] : non-numeric argument to binary operator Can anyone tell me why this error occurs? 回答1: diff wants a matrix or a vector rather than a data frame. Try data.frame(diff(as.matrix(df))) 回答2: Perhaps you are looking for something like this: > tail(df, -1) - head(df, -1)

Why would Vim add a new line at the end of a file?

僤鯓⒐⒋嵵緔 提交于 2019-11-26 16:12:14
问题 I work with wordpress a lot, and sometimes I changed wordpress core files temporarily in order to understand what is going on, especially when debugging. Today I got a little surprise. When I was ready to commit my changes to my git repository, I noticed that git status was marking one of wordpress' files as not staged for commit. I remember I had reverted all the changes I did to that file before closing it, so I decided to use diff to see what had changed. I compared the file on my project

diff a ruby string or array

时光怂恿深爱的人放手 提交于 2019-11-26 16:01:45
How do I do a diff of two strings or arrays in Ruby? Brian Mitchell diff.rb is what you want, which is available at http://users.cybercity.dk/~dsl8950/ruby/diff.html via internet archive: http://web.archive.org/web/20140421214841/http://users.cybercity.dk:80/~dsl8950/ruby/diff.html For arrays, use the minus operator. For example: >> foo = [1, 2, 3] => [1, 2, 3] >> goo = [2, 3, 4] => [2, 3, 4] >> foo - goo => [1] Here the last line removes everything from foo that is also in goo, leaving just the element 1. I don't know how to do this for two strings, but until somebody who knows posts about it

Git: How can I find a commit that most closely matches a directory?

前提是你 提交于 2019-11-26 15:39:44
问题 Someone took a version (unknown to me) of Moodle, applied many changes within a directory, and released it (tree here). How can I determine which commit of the original project was most likely edited to form this tree? this would allow me to form a branch at the appropriate commit with this patch. Surely it came from either the 1.8 or 1.9 branches, probably from a release tag, but diffing between particular commits doesn't help me much. Postmortem Update: knittl's answer got me as close as I

Ignore *all* whitespace changes with git-diff between commits

半城伤御伤魂 提交于 2019-11-26 15:27:59
问题 I'm going through a codebase and fixing whitespace oddities and generally correcting indentation and such things, and I want to make sure I haven't inadvertently made any other changes, so I'm doing git diff -w to display differences in all changed files while ignoring whitespace differences. The problem is that this is not actually ignoring all whitespace differences—at least what I consider to be merely whitespace differences. For instance, in the following output from git diff -w , -"Links