dostaje automatycznie „display: none” w Firefoksie?

Stra­ci­łem nad tym wię­cej cza­su niż chcę się przy­znać; mia­łem dodać mały ele­ment gra­ficz­ny o nazwie pli­ku zspon.png do stro­ny jed­ne­go z Klien­tów i jakimś cudem nie poja­wiał się on nigdy na stro­nie, a Fire­bug poka­zy­wał że ma on „display: none”, choć żad­ne­go CSSa nie przypisywałem.

Oka­za­ło się, że Adblock z fil­tra­mi Filterset.g wyci­na mi obraz­ki któ­re mają w nazwie „spon” :> Wyłą­cze­nie Adbloc­ka na czas deve­lop­men­tu to dobry pomysł, choć ja zosta­wiam włą­czo­ny — jak ktoś będzie go uży­wał to wolę zawcza­su wie­dzieć co mu znik­nie i zmie­nić nazwę pli­ku 🙂 zs-pon.png się wyświetla 😀

[en] How to word wrap text in Graphics2D.drawString in Java

Google wasn’t awful­ly help­ful whi­le I was sear­ching for solu­tion to word wrap­ping a text when dra­wing in Java, so let’s teach Google this: 😉

    private void drawStringRect(Graphics2D graphics, int x1, int y1, int x2, int y2, 
        float interline, String txt) {
        AttributedString as = new AttributedString(txt);
        as.addAttribute(TextAttribute.FOREGROUND, graphics.getPaint());
        as.addAttribute(TextAttribute.FONT, graphics.getFont());
        AttributedCharacterIterator aci = as.getIterator();
        FontRenderContext frc = new FontRenderContext(null, true, false);
        LineBreakMeasurer lbm = new LineBreakMeasurer(aci, frc);
        float width = x2 - x1;

        while (lbm.getPosition()  txt.length()) {
            TextLayout tl = lbm.nextLayout(width);
            y1 += tl.getAscent();
            tl.draw(graphics, x1, y1);
            y1 += tl.getDescent() + tl.getLeading() + (interline - 1.0f) * tl.getAscent();
            if (y1 > y2) {
                break;
            }
        }
    }

Access database (mdb file), format() function and ODBC/PHP

Can You tell a dif­fe­ren­ce between

SELECT *, format(Data_ur, "yyyy-mm-dd") AS Datur FROM Czlonkowie

and

SELECT *, format(Data_ur, 'yyyy-mm-dd') AS Datur FROM Czlonkowie

?

It turns out that when using ODBC to con­nect to Micro­soft Access data­ba­se (in an mdb file), one has to use sin­gle quotes when wri­ting func­tion para­me­ters. The first sta­te­ment runs fine from the Access itself, but when cal­led thro­ugh the ODBC (for instan­ce when using PHP and PDO) it returns emp­ty set (it doesn’t even throw an exception).

The second sta­te­ment (with sin­gle quotes) runs fine thro­ugh ODBC. Worth remembering.

[en] Accessing MSSQL database from Linux using nice GUI

Some­ti­mes Your custo­mer just has that blo­ody hosting with IIS and MSSQL data­ba­se inste­ad of good old Apache+MySQL. I used to use Sql­Bud­dy on Win­dows, but after swit­ching to Linux I had hard time fin­ding a nice GUI fron­tend to MSSQL (Sql­Bud­dy fails to work under Wine).

Along came JDBC 🙂

The­re­’s a real­ly nice uni­ver­sal JDBC GUI fron­tend cal­led Squ­ir­rel­SQL. Just down­lo­ad and java ‑jar installer.jar and select MSSQL plu­gin. Then down­lo­ad jTDS dri­ver and unzip the JAR some­whe­re. Run Squ­ir­rel SQL using its .sh script and double click „Micro­soft MSSQL Server JDBC dri­ver”. Add jtds‑v.e.r.jar to Extra Class Path and chan­ge Class Name to net.sourceforge.jtds.jdbc.Driver and Exam­ple URL to jdbc:jtds:sqlserver://<server_name>.

Then cre­ate new alias, test and… voila! 🙂