• 26.Jan.15
    Extracting a video clip from the command line shell | rafacas | (0)
    I had to extract a small clip from a very long video and I wanted to do it from the command line (of course!). To do that we will use avconv (it is part of libav, an open source audio and video tools). It is a very fast audio and video converter that can be used to extract a clip from a video. To install it in debian based distros: $ sudo apt-get install libav-tools In RedHat based distros there isn’t any source with a decent RPM package so the simplest way is build it from source. In OS X there is a command called ...
  • 02.Dec.14
    Installing YouCompleteMe on FreeBSD shell | fernape | (2)
    Recently, we had a discussion at work about editors and IDEs. And yes, I think Vim is not only a great editor but also a good IDE with the proper plugins installed. There are several nice plugins out there, but I'm going to talk about YouCompleteMe. YouCompleteMe (in short, YCM), is a completion engine for Vim that uses libclang as a backend to support great C/C++ semantic completion. Unlike other pure Vim plugins, YCM needs a component that has to be compiled before you get semantic completion. Although it is not complicated, I'll show you the steps to successfully install YCM ...
  • 09.Jan.14
    Handling rc.conf(5) with sysrc shell | fernape | (0)
    FreeBSD uses the traditional BSD boot system as opposed to the system used in Linux, i.e SysV. This means that in FreeBSD, we have a directory called /etc/rc.d with a bunch of scripts that bring our system up and running. Alongside these scripts, there is a file used to control some configuration variables used at boot time:/etc/rc.conf Since it is a very sensitive file, an unfortunate mistake while editing it can break havok if our system does not boot the next time. To avoid these kind of situations, there is a tool called sysrc. sysrc provides a way to edit rc.conf(5) safely ...
  • 14.Aug.13
    Mirroring a site shell | fernape | (0)
    I recently had to mirror a website to make a backup. I found this very useful (though not perfect) wget -mk Hope it helps
  • 09.Aug.13
    PKGng: The new package manager of FreeBSD shell | fernape | (0)
    So what's PKGng? pkg is the new package manager of FreeBSD. Packages in FreeBSD used to be managed using several different commands, some of them with overlapping functionality (pkg_delete, pkg_deinstall). The whole system was functional but inefficient. It was also slow due to the underlying infrastructure. Everyone who has ever used pkg_info knows what I am talking about. The new system is much faster due in part to the use of an SQLite database. Some time ago, the task of re-thinking the package manager was taken over by a group FreeBSD developers. Finally, with the upcoming of the 9.1-RELEASE version, pkg was ...
  • 27.Mar.13
    Limit running time to a program shell | pfortuny | (0)
    There is no obvious way to specify that a program should run for no longer than x seconds. The following stackoverflow question solves it in a very perlish-way. Define a helper function doalarm: $ doalarm () { perl -e 'alarm shift; exec @ARGV' "$@"; } # define a helper function And you are done. $ doalarm 300 ./my_prog will run for at most 300 seconds.
  • 12.Mar.13
    Spell checking shell | fernape | (0)
    aspell is a command-line spell checker. It is a replacement for the older ispell. It can be used to manage dictionaries, to check a complete file, or words typed in your terminal, among other uses. We can invoke aspell this way: $ aspell -a --lang=en @(#) International Ispell Version 3.1.20 (but really Aspell 0.60.3) This leaves us with a prompt in which we can type a word. For instance, if we type: @(#) International Ispell Version 3.1.20 (but really Aspell 0.60.3) hello * The asterisk indicates that aspell found the word in the dictionary. On the contrary, if we type: @(#) International Ispell Version 3.1.20 (but really Aspell 0.60.3) rescoe & ...
  • 19.Feb.13
    Use of find with regular expressions automated, scripts, shell | pfortuny | (0)
    I found myself needing to write a clean: rule in a makefile which would wipe out all the auxiliary files generated by latex (among other things). Moreover, the project has some subdirectories in which there might be more of those files. Apart from finding files by date, size, modification time... the find utility can use regular expressions. I am not delving a lot into this (what kind of expressions, etc.), I just wanted to point out two things: That it comes in quite handy. That the regex must match the complete file name as reported by find. The second item is worth noticing. If ...
  • 18.Feb.13
    When you think everything is lost… shell | fernape | (0)
    I have seen people many times doing something like this: $cat binary_file The problem with the above is that usually you end up with a prompt that looks like this: �g`�g���i`�i��k`�kX@l`(l � Whatever you type, you get garbage in your terminal. In this case, what most people do is to despair and close the terminal, losing the information contained in it. reset is a command that gets the terminal back to its normal state. Sometimes everything is so mangled that there is no echo from the terminal. Don't panic, just type reset and press ENTER. If ENTER does not work, try to replace it by ...
  • 25.Oct.12
    utf-8 blues in snow leopard with mutt and vim shell | pfortuny | (0)
    Yes, it looks like a true spam page. But it is the only way to describe my problem. I was trying to set up mutt (yes, I am a bit fed up with and its inability to be controlled with the keyboard alone in any sensible way). seems to work OK with utf-8. However, the included vim does not. Any time you type an accented char and delete it, the text gets mangled (you know, typical off-by-one cursor position). The solution for vim is incredibly stupid: open up vim and write :set encoding=utf-8 (or do that at any ...