› linux

» About being a Nerd
Tue, 04/07/2009 - 23:41
A quick meta-blog about nothing directly KDE related, but I think those of you who can understand German should see it nonetheless. Hope you don’t mind me spreading it on the planet:
I just stumbled upon a great video about the definition of “being a nerd”. You can watch it here:
http://www.elektrischer-reporter.de/elr/video/115/ (note: it’s in German!)
I have to say that I can identify myself with the message of the video, very nicely done. Must see for anyone! I’ll spread it in my circle of friends so they understand me better when I talk (proudly) about being a geek.
» Shell helper: running KDE unit tests (ctests) the easy way
Thu, 03/26/2009 - 03:09
Unit tests are in my eyes a very important part of programming. KDE uses them, KDevelop does - the PHP plugin I help writing does as well. cmake comes with a ctest program which does quite well to give you a quick glance on which test suite you just broke with your new fance feature :)
But I am very dissatisfied with it. Right now I usually do the following
# lets assume I'm in the source directory cb && ctest # look for failed test suites cd $failed_test_suite_path ./$failed_test_suite.shell | less # search for FAIL cs cd $to_whereever_I_was_before
That’s pretty much for just running a test. Especially all that cding and lessing became very tedious. Tedious is good, because I eventually fix it:
introducing kdetest
I wrote a bash function (with autocompletion!!!) called kdetest. Calling it without any parameter will run all test suites and gives a nice report of failed functions at the end. Here’s an example (run via cs php && kdetest).
kdetest # ... lots of test output --- ALL PASSED TESTS --- ... PASS : Php::TestCompletion::implementMethods() PASS : Php::TestCompletion::inArray() PASS : Php::TestCompletion::cleanupTestCase() 143 passed tests in total --- ALL FAILED TESTS --- FAIL! : Php::TestCompletion::newExtends() Compared values are not the same FAIL! : Php::TestCompletion::updateExtends() '! forbiddenIdentifiers.contains(item->declaration()->identifier().toString())' returned FALSE. () FAIL! : Php::TestCompletion::updateExtends() '! forbiddenIdentifiers.contains(item->declaration()->identifier().toString())' returned FALSE. () FAIL! : Php::TestCompletion::updateExtends() Compared values are not the same FAIL! : Php::TestCompletion::newImplements() Compared values are not the same FAIL! : Php::TestCompletion::updateImplements() Compared values are not the same 6 failed tests in total
usage
kdetest, i.e. without any arguments runs all tests in this directory and belowkdetest path/to/test.shell ...runs that test suite only,...can by any argument the test suite accepts.
autocompletion
kdetest comes with full support for autocompletion of tests and functions, for example:
milian@odin:~/projects/kde4/php$ kdetest TABTAB completion/tests/completiontest.shell duchain/tests/expressionparsertest.shell parser/test/lexertest.shell duchain/tests/duchaintest.shell duchain/tests/usestest.shell milian@odin:~/projects/kde4/php$ kdetest duchain/tests/usestest.shell TABTAB classAndConstWithSameName classSelf interfaceExtendsMultiple staticMemberFunctionCall classAndFunctionWithSameName constAndVariableWithSameName memberFunctionCall staticMemberVariable classConstant constant memberFunctionInString variable classExtends constantInClassMember memberVariable variableTwoDeclarations classImplements functionAndClassWithSameName memberVarInString variableTwoDeclarationsInFunction classImplementsMultiple functionCall newObject varInString classParent interfaceExtends objectWithClassName
the code
You can find the code below, or you can obtain the most up-to-date version on github. Just head over to my shell-helpers repo and peek into the bash_setup_kde4_programming file.
» Building KDevplatform, KDevelop and the PHP plugin from SVN
Fri, 03/06/2009 - 01:21
In a follow up to my last post about the PHP plugin for KDevelop and Quanta I want to detail how I setup my build environment. Since I’m only working on KDevelop I only want to compile that. For all other applications, I use the packages my distribution makes available. Below you this is possible.
Note: I use Kubuntu and hence some commands like aptitude and the package names etc. will have to be adapted to your specific distribution. But the general idea should be the same and the packages should be called at least somewhat similar. You could always take a look at the techbase article on compilation of KDE 4 to get a more general HowTo.
It is generally a very good idea to read some articles on the techbase. Especially in the Getting Started section.
getting the dependencies
First, you’ll need to install some packages to satisfy dependencies and to get a working compile chain (think cmake, gcc and stuff). The following command only lists very few packages but they have a huge list of dependencies which your package manager will take into account automatically. Don’t be suprised by a possibly huge list of packages ;-) So some disk space will be required (though I doubt it’s more than 250MB in total).
Note: You’ll need the KDE 4.2.x versions of the KDE libraries and development packages. When you use Kubuntu, you can follow this article to get up to date packages for the 8.10 release.
# I hope these are all, it's been a time since I did that the last time # please report if anything is missing aptitude install kdelibs5-dev kdebase-workspace-dev \ libqt4-dev build-essential subversion kdesdk-scripts \ bison flex
removing old cruft
To prevent binary compatibility issues that will result in crashes, you have to remove all KDevelop & KDevplatform packages provided by your package maintainer. In karmic it should be enough to remove kdevplatform, and it will remove all dependent packages:
aptitude purge kdevplatform libsublime
setting up your environment
Inspired by the techbase article on improved productivity in KDE4, particularly the bashrc listed there, I’ve come up with the following way to configure my system:
First visit my shell helper git repo on GitHub and download the two files kde4_setup_build_environment.sh and bash_setup_kde4_programming.
set the environment variables
Move the file kde4_setup_build_environment.sh to ~/.kde/env and make it executable. You might want to adapt the paths for the variables KDE_BUILD, KDE_SRC and KDEDIR inside that file to your likings.
This part is required to make sure that compiled programs will act just like normal programs installed globally (e.g. with your package manager) right from the start of your KDE session. I.e. KRunner works fine and custom plugins are found etc.
make your life easier with some bash magic
Now alter your ~/.bashrc and to the bottom of that file add the following line:
. ~/.bash_setup_kde4_programming
NOTE: This assumes that you saved the afore mentioned bash_setup_kde4_programming file to ~/.bash_setup_kde4_programming. You might have to change the path.
NOTE: That file also sources the above script to set the environment variables. I’m not sure it’s required, but it doesn’t hurt. So make sure the path is correct there.
Now to the fun part
Once all that’s done, you have to log out of your bash session to get the environments. Maybe even logout of your KDE session to make it aware of the new paths as well.
checking out KDevplatform, KDevelop and the PHP plugin
Get the latest and greatest directly from SVN (see also Using Subversion with KDE on techbase):
cs # cs is not a typo! see above git clone git://gitorious.org/kdevelop/kdevplatform.git git clone git://gitorious.org/kdevelop/kdevelop.git git clone git://gitorious.org/kdevelop/kdevelop-pg-qt.git git clone git://gitorious.org/kdevelop/php.git git clone git://gitorious.org/kdevelop/php-docs.git
compiling and installing
Now it’s time to compile all that code you just checked out. Hopefully you got all required dependencies. If you need all bells and whistles, you’ll have to install some more packages I’m sure. If you run the code below, take a good look at the output of the cmakekde command (especially at the beginning). It lists not-found dependencies.
Note: cmakekde is supposed to be run from inside your source folder (e.g. cs $FOLDER; cmakekde).
for p in kdevplatform kdevelop kdevelop-pg-qt php php-docs; do cs $p cmakekde done; kbuildsycoca4 # make sure new plugins etc. are found
Pretty easy, hum? Let’s hope everything worked fine :)
staying up to date
That above command is only required once. Everytime after that, you can simply do the following which will make sure you are running the latest and greatest:
for p in kdevplatform kdevelop kdevelop-pg-qt php php-docs; do cs $p git pull --rebase && make install done
The End
Hope I have not forgotten anything and that this (rather lengthy…) HowTo is of some help to a few of you out there. Looking forward to feature requests, bug reports etc.
UPDATE 18/05/10: updated to include kdevelop-pg-qt, introduced for loops in setup snippets
UPDATE 07/05/10: updated to git locations
UPDATE 08/01/10: updated to extragear location of php & php-docs
UPDATE 01/12/09: added php-docs, updated to extragear location of kdevplatform & kdevelop.
UPDATE 17/12/09: updated to kdereview location of php & php-docs
» PHP support for KDevelop 4 (and eventually Quanta+)
Tue, 03/03/2009 - 00:28
Hello Planet KDE!
I want to give you a little insight on the current state of PHP support in KDevelop4:
Me and Nikolaus Sams (nsams) are working diligently on a plugin for PHP support in playground. It’s somewhat stable, i.e. we fix any crashes we stumble upon, but I would call it Alpha state at most. It may eat your babies so to speak. Yet I’m happy to say that at least one user is already using it for production (hi leinir ;-) ).
implemented PHP support
Well, here’s a (not complete) list of features that are already working. Though I have to warn you: no screenshots included ;-) It’s actually all very similar to the C++ screenies you can see on the web.
sematic highlighting
Let’s start with a feature that only very recently was added for PHP - semantic highlighting. Niko moved some language independent parts of the C++ plugin from KDevelop to KDevplatform and now PHP has the same code highlighting features as C++.
I personally love this feature since it makes it even easier to grasp code and it makes the code highlighting more consistent since there is no visual difference between PHP built-in functions/constants and your own.
code completion
Arguably one of the most useful features the DUChain enables us to write is code completion. There’s already full support for:
- PHP built-in functions, classes, constants, superglobals
- user-defined functions, classes, constants, superglobals, variables, etc.
- proper code completion for objects which respects access modifiers (private, public, protected) and differentiates between static/non-static members and methods
- code completion for overridable and implementable functions inside classes
- hints in the argument list of function- and method class
- sane code completion after keywords such as “extends, implements, catch(), new, throw” and some more I think
There’s still some bugs to fix and a few features to implement. But I can easily say that even the current state of code completion makes one wonder how he could use Quanta (from KDE3 times) for such a long time! It’s simply nothing compared to this!
The next feature I hope to add is support for type hinting in function calls. I.e. only show arrays where arrays are requested and the same for objects of a given type. Also no PHP keywords are currently completed at all…
other DUChain/UseBuilder stuff
Thanks to the DUChain you already get lots of information about declarations, such as uses (which files, which lines etc.). Also very neat is the hover popup you might now from C++ which among others shows you phpdoc comments inside your browser. I also plan to integrate the php.net documentation into KDevelop, similar to what is already possible for QtHelp.
inline validation / syntax checking / linting
Another feature which saves lots of time is on-the-fly syntax checking: You won’t have to fire up your web-app inside a browser just to be greated by that pesty “syntax error, unexpected ‘CHAR’ in FILE on line XYZ” message… No! Instead you will see a nice reddish zig-zag line where you made the error and can fix it before heading off to the browser.
But we don’t only do basic syntax checking. We do more than that, thanks again to the power of the (holy?) DUChain. You can spot undeclared variables, function/method/class/constant redeclarations and more. Actually I hope that one day we spot most of the notices, warnings and errors PHP could emit.
tests
We already have a multitude of regression tests which will make sure that we don’t mess up any existing stuff. Lets hope for even more of them :) I love test-driven development.
The End
Well, thats pretty much it for the moment. You can have a look at what we are up to at the Quanta Feature plan on techbase.
If you are a PHP developer and can write C++ with Qt, why not get in touch with us? You can find us both on the KDevelop mailinglist and at least me and leinir are often found in #kdevelop on freenode.
PS:
Let me finish with a quick introduction of myself:
My name is Milian Wolff, I study Physics at the FU Berlin (just finished the 3rd semester). I started learning programming when I was around 14 with PHP. Over the years I became very good in it and the other webdevelopment techniques like Css, JavaScript etc. Recently I started to fullfill my biggest geek dream by learning C++/Qt/KDE and starting to contribute to the KDE project.
Some of you might now my from the LinuxTag in Berlin where I could be found at the Kubuntu-De.org community booth. At least with some of you I had a beer (well, I doubt it was only one). I hope to repeat this tradition in 2009. Every once in a while I can also be spotted at ubuntu-berlin events.
» Attack of the shell helpers
Mon, 03/02/2009 - 02:46
Everyone who uses the command line regularly has a bunch of (at least for him) useful helper scripts. I now took the liberty to put mine on github for general consumption.
You can find them at: http://github.com/milianw/shell-helpers/tree/master
Some of these might be more useful than others, you decide :) Personally, I can’t live without the following:
apupgrade- a shortcut to update your Debian system with one command - no questions asked
openurl- opens a given URL in an already opened browser instance or starts a new browser session. Not only one browser is checked. I use it because firefox is slow to start and konqueror is blazingly fast to start. But when firefox is already open I want to use that.
xerr- shortcut for fast error checking in your Xorg log
clipboard- makes KDE4 Klipper contents available on the CLI (read and write access!)
debug-
shortcut to start a GDB session:
debug APP APP_ARGSis all you have to do. Its basically the same as doing:- $ gdb APP
- > run APP_ARGS
» Take 2: Download script for springerlink.com Ebooks
Tue, 02/24/2009 - 22:58
Seems like quite some people are interested in my bash script for downloading ebooks from http://springerlink.com.
That script has some quirks, the greatest of all that it was written in bash which makes it kind of hard to implement new features. And one which was requested was support for books which span multiple pages on SpringerLink.
So here I present springer_download.py - a Python rewrite which should handle all the old links and some more. This is the very first program I’ve written in Python. And since it has to run on the Zedat servers it’s limited to Python 2.4.x without any fancy shmancy additions (a pity, since I’d love to use urlgrabber or pycurl).
the script
You can find the sources on GitHub: http://milianw.github.com/springer_download/
I plan to put all my future code snippets in public repositories on GitHub. That way you can easily track changes and stay up to date. GitHub also has a nice “download” feature which you can use to get the current version. You can find my profile and my repositories at http://github.com/milianw
Note: This script is intended to be run under Linux or other *nix’es which fulfill the requirements (Python 2.4.x, iconv and pdftk). Windows is not supported.
TODO
- introduce multithreading for faster / simultaneous downloads
- add speed to progressbar
- use progressbar in source-downloader
- use one git-repo per project (makes links work properly)
» Kate linter plugin
Thu, 01/15/2009 - 18:58
Just a quicky: I wrote a little plugin for KTextEditor which supplies you with basic error checking when you save documents. Currently only PHP (via php -l) and JavaScript (via JavaScript Lint) are supported.
» Download script for springerlink.com Ebooks
Sat, 11/08/2008 - 17:28
After a long period of silence I present you the following bash script for downloading books from http://springerlink.com. This is not a way to circumvent their login mechanisms, you will need proper rights to download books. But many students in Germany get free access to those ebooks via their universities. I for example study at the FU Berlin and put the script in my Zedat home folder and start the download process via SSH from home. Afterwards I download the tarball to my home system.
Read on for the script.
» Access klipper clipboard on CLI under KDE4
Wed, 08/13/2008 - 23:12
Here’s a little script you can save in your path and do things like
# paste current clipboard into file clipboard > "some_file" # copy some file into clipboard cat "some_file" | clipboard
Actually I find it rather useful so I thought I will have to share it.
Since KDE4 D-BUS is used throughout KDE and thus in Klipper as well. IMO they should really rework the output of dbus-send or add some more flags (what about --quiet). Well that’s the reason why the script below is somewhat long. But nothing a little bit of bash+awk magic couldn’t cope with:
#!/bin/bash # check for stdin # since we don't want to wait endlessly we set a timeout # a pity `read` only supports seconds and no fractions... read -t 1 stdin if [[ "$stdin" != "" ]]; then # get the rest of stdin stdin=$stdin$(cat) # oh, nice - user input! we set that as current # clipboard content dbus-send --type=method_call --dest=org.kde.klipper \ /klipper org.kde.klipper.klipper.setClipboardContents \ string:"$stdin" exit fi # if we reach this point no user input was given and we # print out the current contents of the clipboard # note: I hate the output of dbus, dcop was much easier in that regard! dbus-send --print-reply --dest=org.kde.klipper /klipper \ org.kde.klipper.klipper.getClipboardContents | awk ' BEGIN { output = ""; } { if ( NR > 1 ) { output = output $0 "\n"; } } END { print substr(output, 12, length(output) - 13); }'
As usually, save the file (attached below) in your $PATH and make it executable.
PS: Thanks to Martin Vidner for his article on D-BUS btw. - it gave me the proper dbus commands.
» recent GeSHi contributions (apache, xorg, apt, performance, ...)
Wed, 06/18/2008 - 22:46
Your favourite syntax highlighter for web applications, GeSHi, recently got some new features and bug fixes. By yours sincerely. A rough summary of what I contributed:
- various performance improvements, i.e. some speed optimizations and reduced memory consumptions (especially peak memory usage is down by roughly 1MB when highlighting
geshi.phpby itself) - minor bugfixes, including one which prevents some nasty PHP notices on PHP 5 systems to contaminate your precious log files
- improved language files: bash, apache
- added language files: GNU Gettext, Xorg configuration and Apt
sources.list
Some of those features were already shipped with the recent 1.0.7.22 release. But the two new language files and the improvements to the existing apache language file are currently only available via SVN. Wait for the next stable release which should be 1.0.8.
To see two pretty examples, read on after the break: