11.03.08
Posted in Bash, Projects at 11:47 pm by Guy
I’ve decided to scan some notebooks. After researching a bit, I’ve decided to use DjVu (instead of PDF which I normally use). I’ve chose to use DjVu because it offered great quality with very good compression rate (~26KB per page) in lineart (black and white).
While XSane can natively save a multipage project into PDF it can’t do so for DjVu. So, the solution is to use the PNMs generated by XSane and convert them using the command line tools offered by DjVuLibre to bundle them together to a DjVu file. As you can guess doing this manually is pretty hard work. To make this task easier I’ve written a small bash script to automate the process.
Read the rest of this entry »
Permalink
08.03.08
Posted in PHP at 1:36 am by Guy
While working on a new project using CakePHP, I’ve came across a weird problem. In one of the controllers the the session always came out as invalid, as
always returned false. I tried debugging this weird stuff, and it looked like all the session variables are unset. Using
to get the last error returned “Config doesn’t exist”. After further debugging “Config” turned out to be an internal array that is saved by CakePHP to the session and holds various internal data (some of it is used for validation like user-agent hash). I kept printing more and more debugging data as well as looking at CakePHP’s trac system.
I found an interesting bug (ticket #4217) and it looked very promising, as it almost fully described my problem. Unfortunately, the solution offered didn’t seem to work for me. But it inspired me to try and start the session manually using session_start() instead of using Cake’s startup and activate methods of the Session Component.
I found out that the session_id() returned empty string. Luckily calling session_start() directly from the controller, gave me a lead. The session seemed to work well but a nasty error about headers already been sent showed up.
I little more investigation lead up that I had a trailing newline after my closing PHP tag in that controller file. Deleting this trailing whitespace completely solved the problem. No need anymore to manually start the session. It’s pretty annoying that such a small thing like trailing new line can cause such seemingly unrelated problems in CakePHP’s session handling.
Maybe CakePHP should add a little debug notice when the session doesn’t start because header were already sent. This can be done by modifying the else statement in the __startSession() method in cake/lib/session.php (line 557 in version 1.2.0.6311). I wonder what the reason they had not to inform the developer when such event happens, as I don’t see why someone will deliberately try to start the session after sending the headers, I think it only happens by mistake (at least most of the time).
Permalink
01.03.08
Posted in Bash, Linux, Projects, Tips at 11:12 pm by Guy
This is a small script I wrote today, to automate my backups, which I do on Amazon S3. This is fairly short, yet useful bash script that utilize the s3cmd to do the actual sending of the files.
Read the rest of this entry »
Permalink
23.02.08
Posted in C/C++, Tutorials, vim at 10:27 pm by Guy
I use Vim as my main IDE for C/C++ related development (as well as for almost all other development). If you use (or thinking about using) vim as as an IDE, you better get some good autocompletion functionality. This kind of autocompletion is provided by the OmniComplete, which is available since Vim 7.0. Just having the OmniComplete is a nice thing, but it’s much more helpful if configured properly to work with the libraries you use, such as wxWidgets. In this post I will show you how to get working the OmniComplete for wxWidgets, however, the procedure I will show can be easily adapted to almost all libraries.
Read the rest of this entry »
Permalink
10.02.08
Posted in Greasemonkey, Projects at 11:55 am by Guy
This post can be helpful for students of the Open University of Israel. As a student there, I found it very annoying that the link to the courses’ homepage in the Telem system is a JavaScript link. This prevents it from opening in a new tab, and thus require various workarounds to get back to the homepage in a different tab. So, a little while ago I wrote a little Greasemonkey script to fix it.
// telem.user.js
// version 0.1
// 2008-01-01
// Copyright (c) 2008, Guy Rutenberg
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// ==UserScript==
// @name OpenU's Telem - Fix Home Button
// @namespace http://www.guyrutenberg.org/
// @description Fixes the home button link in the telem system of the OpenU.
// @include http://maagar.openu.ac.il/opus/*
// ==/UserScript==
home = document.getElementById('home');
if (home) {
re = /javascript:find_home_page\('(.*?)','(.*?)',/
match = re.exec(home.href)
home.href = 'http://telem.openu.ac.il/courses/'+match[2]+'/'+match[1]
}
This script changes the link to a regular non-JavaScript link. I’ve tested it for more than a month now, without finding any bugs. However if you find something, or have any suggestion, please comment.
Update: See A Greasemonkey Fix to the Top Menu in Sheilta (Open University), it has a fix for the top menu bar in the Sheilta system
Permalink
01.02.08
Posted in Linux, Tips at 10:50 pm by Guy
Like many Linux users, I use Guarddog as a frontend to my iptables firewall. At some point, I noticed that Guarddog started acting strangely. Every time I restarted my computer, all internet traffic was blocked (both in and out). The only way to fix this situation was to open Guarddog and press “Apply” (without doing any changes). While it was annoying, it didn’t bother me much because I used to restart my computer about once a month. But few days ago, I decided to solve this problem once and for all.
Read the rest of this entry »
Permalink
29.01.08
Posted in Projects, mctext at 10:37 am by Guy
mctext is a new project of mine, focusing on text generation using Markov Chains. This little utility reads a sample text file, preferably a large one, and generates new text based on the semantics given in the sample text.
Read the rest of this entry »
Permalink
18.01.08
Posted in Linux, Tips at 1:20 pm by Guy
Sometimes svn switch fails because unversion files exist in the working copy, and the need to erase them comes up. This is also true when updating to an old revision (usually one that misses directories that exist in the head revision), doing some work (like compiling), and then trying to update back to the head revision. Subversion (SVN) will fail complaining that directories/files already exist.
Read the rest of this entry »
Permalink
04.01.08
Posted in LaTex at 8:28 pm by Guy
When writing a document that contains mathematics, many time the need to add an explanation (e.g. stating the theorem used) is raised. To answer this need I wrote two short LaTeX macros: \explain and \explainup.
Read the rest of this entry »
Permalink
28.12.07
Posted in Projects, Python at 11:28 am by Guy
This is a re-release of a script of mine that helps convert CSS layouts to RTL. I originally released it about a year ago but it was lost when I moved to the new blog. The script, cssrtl.py, utilizes a bunch of regular expressions to translate a given CSS layout to RTL.
Read the rest of this entry »
Permalink
« Previous entries · Next entries »