Concatenate files with progress bar on GNU/Linux

When I download files form rapidshare or other file hosting sites I occasionally download movies that are splited into parts, and to watch the movie they need to be concatenated.

I came up with this bash function which I put in my .bashrc file:

function concat() {
  files=${@:1:$(($#-1))}
  cat $files | pv -s $(du -cb $files | tail -n1 | cut -d $'\t' -f1) > ${@: -1}
}

If you have files like Movie.avi.001…Movie.avi.020, to concatenate these files just type:

concat Movie.avi.* Movie.avi

And you’ll see progress bar when output file is created.

, ,

Leave a comment

Convert pdf to jpg for free on windows using open source tools

To convert pdf to jpg on windows you can use existing open source tools ImageMagic and GhostScript.

Get and Install latest ImageMagic from:

http://www.imagemagick.org/script/binary-releases.php#windows

Ensure that you install with OLE support (for scripting with VBScript)

Get and install latest GPL version of Ghostcript from sourceforge

http://sourceforge.net/projects/ghostscript/files/GPL%20Ghostscript/

Unfortunately there is no GUI for ImageMagic but you can use script below, just save it in pdf2jpg.vbs – to run the script just drag all pdf files that you want to convert on script icon. The resulting images will have the same name but with jpg extension and they will be placed in the same directory as pdf files.

Set imageMagick = CreateObject("ImageMagickObject.MagickImage.1")
For Each name in Wscript.Arguments
       pdf = Replace(name, ".pdf", ".jpg")
       imageMagick.Convert name, "-resize", 650, "-quality", 80, pdf
next

With ImageMagic you can do lots of cool stuff like create, edit, compose, convert bitmap images, scale, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

For more information see command line and COM+ ImageMagickObject documentations.

Instead of VBScript you can use other languages.

, ,

1 Comment

[Ruby] Wyświetlanie definicji ze “Słownika Wyrazów Obcych Kopalinskiego”

To jest kod skryptu w Ruby do wyświetlania definicji ze “Słownika Wyrazów Obcych Kopalińskiego”. Pobierz plik kopalinski.rb.

Żeby użyć tego skryptu musisz mieć zainstalowanego Ruby-ego.

W terminalu wpisz:

kopalinski.rb Słownik

Skrypt wyświetli definicje słowa “Słownik”. Jeśli w słowniku Kopalińskiego nie ma jakiegoś słowa skrypt nie wyświetla nic.

,

3 Comments

JQuery Terminal Emulator Plugin

My new project JQuery Terminal Emulator. It’s a plug-in which can be used to add Command Line interface to your application. You can use it to easily create server configuration tool or can be help in debugging or testing server side of AJAX applications. You can put lots of options in one place.

You can create command line interface to JSON-RPC in one line of code. Just set the path to rpc service.

$(document.documentElement).terminal("json-rpc-service.php");

If you want to use authentication.

$(document.documentElement).terminal("json-rpc-service.php", {
    login:true
});

And when user type user and password it will call login rpc method, get the token and pass that token to all methods on the server when user type command. So when user type for example add-user foo foo@bar.com it will call json-rpc add-user with parameters [token, “foo”, “foo@bar.com”].

, , ,

1 Comment

Really strange thing with Fedora

Recently I’ve create icons for GTK and I’ve notice strange thing. If you put this comment:

<!--
    icon is vector   for gtk

    Copyright  (c)

    You should have received a copy  the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/<.

-->

In svg file between xml prolog and svg root node, the file will not display in Nautilus. The same things is with icons.

here is link to example file.

This was tested on Fedora 14 64bit liveCD on VirtualBox

, , ,

Leave a comment

Best internet ad ever

I found this ad on osnews.pl web page. It’s in my opinion best advertising ever. This is ad from from polish firm that specialize in security training courses.

security training courses ad

The link in this ad lead to this page

,

Leave a comment

Python one liner for css file compression

I need a script to compress css file, and I wrote this python one liner to do this. It removes unnecessary white space and strip comments.

python -c 'import re,sys;print re.sub("\s*([{};,:])\s*", "\\1",
re.sub("/\*.*?\*/", "", re.sub("\s+", " ", sys.stdin.read())))'

,

Leave a comment

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: