Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Tuesday, September 30, 2014

Get a list of files changed between two revisions of SVN

If you want to see which specific files where changed between two revisions of SVN, then this is a handy and quick reminder, taken from here:
svn diff --summarize -r {newRevision}:{oldRevision}
You can change the order of {newRevision} and {oldRevision}.

For instance, to get the list of modified files between revisions 60 and 50 we write
svn diff --summarize -r 60:50
This will output a list like this:
 M       path/to/modifiedfile
 A       path/to/newfile
 D       path/to/deletedfile
 .
 .
 .


Bonus:
If you want to see the detailed diff between the versions of modified files, you may remove the --summarize suffix. But the output will be very bland and hard to read. See this post to learn how you can make that output look better.

Wednesday, August 6, 2014

How to delete (and reset) FileZilla preferences in OS X

In order to start with a clean copy of FileZilla (so that, for instance, it allows you to save site passwords again, after once choosing not to!) follow these steps on Mac OS X:

First stop (close) FileZilla. Then navigate to the home directory by typing cd ~. Then locate .filezilla by typing ls -a (optional, obviously!). Remove it by using:
rm -rf ~/.filezilla
Now open FileZilla again!

Thursday, March 6, 2014

One-liner command for changing pdf size

The commands in this post require the GraphicsMagick package (see this for an explanation). GraphicsMagick commands start with gm in front of them.

One use of these programs is to resize pdf files. I found a solution here, which was really helpful. I will repeat and expand on it.

 TLDR Version

Use the following command in terminal:
gm convert -density 300x300 -quality 25  -compress jpeg  originalFile.pdf targetFile.pdf

 Explanation

Now let's see what that command does. First the bare bones:
gm convert  -compress jpeg  originalFile.pdf targetFile.pdf
This command will compress your pdf file for you, but will use default values for the output's density and compression quality. Unfortunately, the resulting output is overly compressed and unusable for most uses.

-compress jpeg defines the type of image compression. Read more about it here.

Adding the -density 300x300 makes sure that the pdf's resolution is satisfactory. Read more about it here.

If the output file's size is till too big, you can either lower the above resolution, or increase the compression level of the pdf (and lower its quality). That is what the -quality 25 command does. The default value is at the higher quality of 75. The number can be anything from 0 (lowest quality) to 100 (highest quality).
Read more about -quality here.

Thursday, February 27, 2014

Symbolic links in Unix-like OSs

In Unix-like systems, if you have a command-line app, and you want to run it, you will have to type its full address in the terminal, like this
/Users/name/myFolder/app
Or you can navigate to its folder with cd /Users/name/myFolder and then use ./app to run it.

Another way would be to move that application to a folder that is in the system's $PATH . But if you don't want to move the application (and assuming you don't want to change your $PATH either), then you can add a shortcut for your application to a folder that is included in $PATH . To see the list of these folders, type
echo $PATH
and then pick one of the folders displayed. For example, /usr/local/bin . Now we will add a symbolic link (like a shortcut) to our application in this folder. This can be done by
ln -s /Users/name/myFolder/app /usr/local/bin

Perfect! now you can run your app by simply typing app in any terminal! (Of course, app should be the specific name of your app.)

Tuesday, February 25, 2014

Package management for Mac

After experimenting with Homebrew, and then MacPorts, I'm finally back to Homebrew again. I have decided that based on its fast package installation, active community, and also the fact that it does not duplicate the packages that are already available.

In case you haven't heard of the above names: Package management systems, like AptGet on Ubuntu, are not readily available on OS X and one needs to choose a third party package manager to tap into the world of Unix-style application packages. Homebrew and Macports are two of the most famous package managers available for OS X.

Wednesday, October 9, 2013

Find multiply-defined labels in a complex Latex project

Slower way
Whenever a label is defined multiple times in Latex, there will be a general warning, and also earlier in the log file the specific instances of the labels will be mentioned.

Nonetheless, you may also directly look in the project files for such duplicate labels if you want to be fancy. Here is a one-liner perl script that will do the job and was originally shared by Walt Mankowski. Run this script in the directory that your latex files reside.
perl -nE 'say $1 if /(\\label[^}]*})/' *.tex | sort | uniq -c | sort -n
You will see a list of the duplicate labels. Then use grep to find those labels. For example if one of the duplicate labels is \label{sec:party_structure}, then you can use this command:
grep "\label{sec:party_structure}" *.tex

Faster way
You can also combine grep and uniq for a faster solution. To see the number of repetitions, try
grep -o \\label{.*} *.tex | uniq -c
or to see only the duplicate labels, try
grep -o \\label{.*} *.tex | uniq -d
This solution was given here.