linux tools
Monday, September 29, 2008
What I use on xubuntu linux for specific tasks:....
Task | Tool | Date | Ubuntu Package | Comment |
---|---|---|---|---|
pdf annotating | flpsed | Sep 2008 | flpsed | Very basic app that enables load/save of ps and pdf. Multi-line text can be added to the docs. No highlighting option or editing of existing content. |
pdf editing | pdfedit | Sep 2008 | pdfedit | Allows editing of any part of multi-page PDF documents. Can be very slow to use on long documents. New content such as highlighting and single-line text can be added also. |
vector graphics / single-page pdf annotating | inkscape | Sep 2008 | inkscape | Great tool for vector graphics, quick and easy results. Can import a single page of PDF documents. |
xml viewing / formatting | XML Copy Editor | Sep 2008 | xmlcopyeditor | Load and view xml. Validate form and against dtd etc, plus nicely format. Quick and easy. |
diff | meld | Sep 2008 | meld | Excellent visual diff/merge tool. |
text/source editor | SciTE | Sep 2008 | SciTE | Excellent text editor with awareness of many languages and markups. Tabbed view. |
sql where not with nulls
Wednesday, September 24, 2008
Ah ha! Sound confusing? Why yes it is.
Turns out that SQL (and HQL for that matter) don't allow regular operators to run against a null field. Fair enough, it means:
SELECT * FROM myTable WHERE id=6
will evaluate to false if the id is null, so rows with null values won't be returned. Ok.
However, where it gets tricky is in NOT clauses, which also won't return if the value is null. If an operator (other than is null or is not null) is used on a null field, SQL evaluates it to null, which the where clause in turn evaluates to false. So...
SELECT * FROM myTable WHERE NOT id=6
will return rows where id is: 1, 2, 3, 4, 5, 7, 8 etc...
but NOT where id is: 6 or null
The way around it? If the field you are 'NOT' selecting on can be null, then you must include a 'is null' OR match:
SELECT * FROM myTable WHERE (NOT id=6 OR id is null)
javascript scripting tricks
Saturday, September 20, 2008
I often write little javascript scripts to get a job done on the web, and usually using greasemonkey. So, to keep track of the little useful tidbits that I tend to forget cos I use them so infrequently, I'll keep this post updated with them as I remember/come across them.
Adding elements to html
Adding a cell to a table row
var row=document.getElementById('myTable').rows[0]; //or however you find the row
var mycell=row.insertCell(2); //0-based index of the insertion position
mycell.innerHTML="NEW CELL"; //raw html content of the cell
Working with greasemonkey
Greasemonkey differs from writing a script that loads with the page, as actions that you define don't implicitly have access to the functions within the greasemonkey script. So setting up things like onclick won't work. My solution to this used to be to add a script element (defining my functions) to the page using addelement. While this worked, it was very messy and hard to maintain. Here's a much better solution, which involves using an event listener rather than just defining onclick (for example).
This is from consuming experience:
In the orignal html page
<div id="thediv">...</div>
So our greasemonkey script contains
document.getElementById('thediv').addEventListener('click', myFunction, true);
and then anywhere in the greasemonkey script we can define myFunction
function myFunction() {doStuff();...}
Subscribe to:
Posts (Atom)