Posts Tagged thisreallyworks
Spuren: Desktop Search for tidy people
Posted by JohannesTheDeveloper in Happy Hacking on June 4th, 2010
Desktop search engines, like beagle, metatracker, strigi, jindex, etc. provide a comfortable way of jumping to the files you want to work with. They do this by indexing all your files, making a database, and searching that database by your keywords.
Unfortunately, these databases are around a gigabyte in size for me (e.g. tracker, strigi). Context search is overkill for me, because I name my files properly and put them in folders.
Introducing “Spuren”
So I developed a search engine a while ago that works on file names and paths: The keywords a file can be found is the filename and path split by ‘/’,'-’,'_’,’.’,'\’. With the feature of exclusive search terms (starting with ‘-’), and being able to open the found file or its parent folder, that is something you can work with.
Now this tool is available as a indexer and search tray icon program, for Unix only. It quickly produces a tiny database of your files, because it is based on unix tools (find+gzip). The search tool is written in Java.
Try out “spuren”, the content-free desktop search engine. Spuren is German for ‘tracks’. Download it at the bottom of this page.
Spuren provides a KISS combination of the ease of use of Beagle et. al. and the simplicity of find.
Install and Configure
- Download the tar and extract it somewhere, for example in ~/bin/
- Put the directories you want to have indexed in ~/.local/share/spuren/dirs (line by line)
- Put the directory names you want to have skipped in ~/.local/share/spuren/skipdirnames
- Put the file names you want to have skipped in ~/.local/share/spuren/skipfilenames
- Run spuren-mine. This produces ~/.local/share/spuren/db.gz, which contains all indexed file names.
- Run spuren-trayicon (and perhaps make yourself a icon on the desktop or put it into session start preferences).
- Click on the icon and search away
Tipps
- Separate keywords by spaces (search will be slightly faster if you enter the least generic term first)
- You can exclude by prefixing a ‘-’, for example ” houses -skyscrapers “
- The default is to find files that have tags starting with the given keywords. You can prefix with a ‘*’ to find files that have tags containing the given keyword. For example: “houses *scrape”.
- You can jump down to the results by pressing the down key, and up gets you back. Escape closes the search window.
- A double-click launches the file, pressing shift at the same time will open the folder the file is in instead.
- You can rebuild the database by right-clicking the icon. It only takes a minute or two.
- The result folders are abbreviated to 3 chars to save space. You can find the full path and some other info at the bottom of the window
FAQ
- “Java is ugly”: You can switch to the GTK theme or Nimbus LAF. Enable it in the
swing.propertiesfile.
… leave feedback and comments …
Download
- Spuren, release 1.0: spuren-1.0.tar.bz2
- Source for Java program: spuren-1.0-source.tar.bz2
Maven: Colorized
Posted by JohannesTheDeveloper in fun with Linux on January 7th, 2009
Maven was written by people who obviously have no idea on how to create good tui (Text User Interface)-tools. They should sit together with the portage, git or other Linux-devs.
The output is unreadable (not to mention that the startup is slow).
So, what I did was wrap maven in a script that colorizes the output. The result looks like this:

This is how to do it:
create the file ~/bin/mvn with the following content (mvn (0 KB))
#!/bin/bash
/usr/bin/mvn $* | sed -e 's/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/[1;32mTests run: \1[0m, Failures: [1;31m\2[0m, Errors: [1;33m\3[0m, Skipped: [1;34m\4[0m/g' \
-e 's/\(\[WARN\].*\)/[1;33m\1[0m/g' \
-e 's/\(\[INFO\].*\)/[1;34m\1[0m/g' \
-e 's/\(\[ERROR\].*\)/[1;31m\1[0m/g'
replace /usr/bin/mvn with wherever your mvn is (find out with which mvn).
Double-check that you get the encoding right, the weird sign should be hexadecimal 1b. Use a editor that supports encodings for copy+paste.
Give your ~/bin/mvn execute permissions (chmod +x ~/bin/mvn)
Try it out: call ~/bin/mvn in one of your maven projects
What is left to do is to register your new mvn-wrapper so it is called everytime.
Add the following line to your ~/.bashrc :
alias mvn=~/bin/mvn
Execute the command you just added in your running shells so you can use it there too.
You are done.
Changing the distributed mvn startup script
Even better, but a little more intrusive (you need root rights):
change the distributed mvn file. It is a bash script actually.
In gentoo:
$ which mvn
/usr/bin/mvn
$ file /usr/bin/mvn
/usr/bin/mvn: symbolic link to `/usr/share/maven-bin-2.0/bin/mvn'
$ file /usr/share/maven-bin-2.0/bin/mvn
/usr/share/maven-bin-2.0/bin/mvn: Bourne shell script text executable
$
Change the last call in that file to:
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "${M2_HOME}"/boot/classworlds-*.jar \
"-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
"-Dmaven.home=${M2_HOME}" \
${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS |
sed -e 's/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/[1;32mTests run: \1[0m, Failures: [1;31m\2[0m, Errors: [1;33m\3[0m, Skipped: [1;34m\4[0m/g' \
-e 's/\(\[WARN\].*\)/[1;33m\1[0m/g' \
-e 's/\(\[INFO\].*\)/[1;34m\1[0m/g' \
-e 's/\(\[ERROR\].*\)/[1;31m\1[0m/g'
That way you have it there directly. Maybe the gentoo devs could add a color use-flag. That’d be fun…
PDF merge/join/split
Posted by JohannesTheDeveloper in Happy Hacking on November 13th, 2008
You always wanted it to be this simple. Now it is.
.
Download:
=> 8KB pdfjoin-nosrc.tar.bz2
14712KB pdfjoin.tar.bz2 (with Ghostscript sources)
I programmed it in Python+Glade+GTK. It uses ghostscript as backend.
Unpack and run “python pdfjoin.py”.
I’ll make a Windows package sometime.
Python: HTML database descriptions from create statements
Posted by JohannesTheDeveloper in Happy Hacking on April 2nd, 2008
This code produces HTML database descriptions from create statements.
Feed into stdin, await from stdout.
For example: python dbdesc.py < DATASCHEME > dbdesc.html
It isn’t perfect nor meant to be, but gives a good starting point for a documentation.
#!/usr/bin/python
import sys
import re
a = ''
for i in sys.stdin.readlines():
a = a + " " + re.sub('--.*', '', i).strip()
a = a.strip().lower()
a = re.sub('\/\*[^*]*\*\/', '', a)
print """
<html>
<head>
<link rel="stylesheet" href="dbdesc.css" />
</head>
<body>
"""
for m in re.findall('create table ([^ (]*)[ (]*([^;]*)[ )]*;', a):
tablename = m[0]
content = m[1]
print "<h2>%s</h2>" % tablename
print """<table class="dbdesc"><thead><tr>
<th class="name">Feldname</th>
<th class="type">Typ</th>
<th class="option">Option</th>
<th class="comment">Bemerkung</th>
</tr></thead>"""
atts = {}
for l in content.split(','):
l = l.strip()
if l == '':
continue
if l.startswith('constraint') or l.startswith('foreign key'):
continue
l = l.split(None, 2)
if len(l)<2:
continue
name = l[0]
if name == 'constraint' or name.__contains__('(') or name.__contains__(')'):
continue
type = l[1]
if len(l)<3:
l.append('')
op = ""
if 'not null' in l[2]: op = op + '!'
if 'primary key' in l[2]: op = op + '1+P'
elif 'unique' in l[2]: op = op + '1'
print """ <tr>
<td class="name">%s</td>
<td class="type">%s</td>
<td class="option">%s</td>
<td class="comment"><!-- TODO: Bemerkungen --></td>
</tr>""" % (name, type, op)
print """ </table> """
print """</html> """
CSS file dbdesc.css
table.dbdesc{ width: 40em; border: 1px solid #080; border-width: 1px 0;}
table.dbdesc th{ border-bottom: 1px solid #080;}
table.dbdesc td{ border: none;}
table.dbdesc td, table.dbdesc th{ width: 15em;}
table.dbdesc th{ font-style: italic; font-weight: normal; }
table.dbdesc td.option{ text-align: center;}
table.dbdesc td.type{ text-transform: uppercase;}
Converter Extension for deskbar
Posted by JohannesTheDeveloper in Happy Hacking on February 14th, 2008
Do you know units? It’s a small forgotten unix program (like cal) that converts units … It tells me it supports 2411 units, 71 prefixes and 33 nonlinear units. Not bad, huh?
So let’s use this in the deskbar-applet. Some friendly neighbor already did this, I updated it to 2.20 new-style classes.
Screenshot: 
Code: converter (py, 6 KB)
Don’t use this anymore. Try this updated version!
Download to your Desktop, then drag and drop it into the deskbar preferences window. Or copy it to ~/.gnome2/deskbar-applet/modules-2.20-compatible.
Don’t forget to enable it in the preferences.
Yaha, you need to install the units program first!
keeping old revisions
Posted by JohannesTheDeveloper in fun with Linux on January 14th, 2008
One might be to lazy to set up or use a revision control system like CVS, SVN or git for small projects or when working on 2-3 simple files.
This script creates a directory “backup”, and places there a archive of the files in the current directory (not recursive) with an increasing number.
e.g. you start it in a Folder “Bsp-3″, it will create “backup/Bsp3-1.tar.bz2″, next time “Bsp3-2.tar.bz2″, etc.
Also cleans up duplicates, so you cannot call it too often!
Small, clean, easy. I love it!
backup-point.sh
DIRNAME=$(basename $PWD)
EXT=tar.bz2
mkdir -p backup
cleanup_unneeded(){
cd backup
FILES=*.tar.bz2
UNIQ=$(md5sum $FILES|sort|uniq --check-chars=32 | cut -d ' ' -f 3-);
for i in $FILES
do
if ! echo "$UNIQ" | grep -wq "$i"
then
echo "deleting unnecessary $i."
rm "$i"
fi
done
cd ..
}
cleanup_unneeded
for((i=1;i<200;i++)); do
FILENAME="backup/$DIRNAME-$i.$EXT"
if ! test -f "$FILENAME"; then
find -maxdepth 1 -type f|xargs tar -cjf "$FILENAME"
echo "backup-point $i made."
cleanup_unneeded
exit
fi
done
echo '200 points reached! Clean up a bit?'
LaTeX: Beamer Theme switcher
Posted by JohannesTheDeveloper in Happy Hacking on June 9th, 2007
LaTeX + beamer package … means cool presentations.
But how to select a theme and a color theme? Which are there anyway?
The first script takes you through a tour how your presentation will look like for each theme.
The second does quite the same thing for the color schemes.
#!/bin/sh
name="switchtheme"
THEMEFILEDIR="/usr/share/texmf/tex/latex/beamer/"
INFILE="presentation.tex"
TMPINFILE="$name.tex"
TMPOUTFILE="$name.pdf"
MAKECMD="pdflatex $TMPINFILE"
DISPLAYCMD="evince $TMPOUTFILE"
THEMELIST=$*
if [ "$THEMELIST" == "" ]; then
THEMELIST=$(ls $THEMEFILEDIR |
grep 'beamertheme[A-Z]' | sed 's/beamertheme\([A-Z].*\)\.sty/\1/')
fi
for theme in $THEMELIST; do
echo $theme
cat $INFILE | sed 's/\\usetheme{[^}]*}/\\usetheme{'$theme'}/g' |
sed 's/\\title{\([^}]*\)}/\\title{\1 - '$theme'}/g' |
cat > $TMPINFILE
$MAKECMD
$DISPLAYCMD
done
rm $TMPOUTFILE $TMPINFILE $name.{out,aux,log,nav,snm,toc}
#!/bin/sh
name="switchcolor"
THEMEFILEDIR="/usr/share/texmf/tex/latex/beamer/"
INFILE="presentation.tex"
TMPINFILE="$name.tex"
TMPOUTFILE="$name.pdf"
MAKECMD="pdflatex $TMPINFILE"
DISPLAYCMD="evince $TMPOUTFILE"
THEMELIST=$*
if [ "$THEMELIST" == "" ]; then
THEMELIST=$(ls $THEMEFILEDIR |
grep 'beamercolortheme' | sed 's/beamercolortheme\(.*\)\.sty/\1/')
fi
for theme in $THEMELIST; do
echo $theme
cat $INFILE | sed 's/\\usecolortheme{[^}]*}/\\usecolortheme{'$theme'}/g' |
sed 's/\\title{\([^}]*\)}/\\title{\1 - '$theme'}/g' |
cat > $TMPINFILE
$MAKECMD
$DISPLAYCMD
done
rm $TMPOUTFILE $TMPINFILE $name.{out,aux,log,nav,snm,toc}
Start it where your tex file lives (plus change the INFILE variable). Your .tex file has to have \usetheme{something} as this will be replaced (not in your file, but a temporary).
You can also give it themes names as parameter, and it will show you only these.
Copy files from Playlist (.pls) to usb stick
Posted by JohannesTheDeveloper in fun with Linux on March 24th, 2007
cat TopRated.pls |
grep -Eo "/mnt/.*"|sed "s/%.\{2\}/*/g"|
while read line; do cp "$line" /mnt/sda1/Music/TopRated/ -v; done
Get a nice pic for your desktop every day
Posted by JohannesTheDeveloper in fun with Linux on November 13th, 2006
Gets a daily picture from a site and sets the softlink “newest” to it.
Needs executable rights on the shellscript and a
The shell script next.sh:
DATE=$(date +%y%m%d)
SERVER=antwrp.gsfc.nasa.gov
URL=http://${SERVER}/apod/ap${DATE}.html
NEWIMG=${DATE}.img
[ -e $NEWIMG ] && exit;
rm -rf *.jpg *.png *.gif
wget --recursive --level=1 $URL --accept jpg,png,gif --no-clobber --no-directories --tries=0
FIRST=$( ls -U *_f.* *_big.* *.jpg *.png *.gif 2>/dev/null|head -n 1 );
if [[ "$FIRST" != "" ]]; then
cp $FIRST $NEWIMG
unlink newest
ln -s $NEWIMG newest
fi
If you want a cronjob for that, use e.g.:
0,30 * * * * cd bgimg/astro/data; sh ../next.sh
Don’t forget to set the background image of your window manager to the link … obviously
Recent Comments