Nov 29 2008

dostaje automatycznie “display: none” w Firefoksie?

Napisał(a) Grzegorz w kategorii Informatyka, Krótkie, Porady

Straciłem nad tym więcej czasu niż chcę się przyznać; miałem dodać mały element graficzny o nazwie pliku zspon.png do strony jednego z Klientów i jakimś cudem nie pojawiał się on nigdy na stronie, a Firebug pokazywał że ma on “display: none”, choć żadnego CSSa nie przypisywałem.

Okazało się, że Adblock z filtrami Filterset.g wycina mi obrazki które mają w nazwie “spon” :> Wyłączenie Adblocka na czas developmentu to dobry pomysł, choć ja zostawiam włączony - jak ktoś będzie go używał to wolę zawczasu wiedzieć co mu zniknie i zmienić nazwę pliku :) zs-pon.png się wyświetla :D

Brak komentarzy

Nov 27 2008

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

Napisał(a) Grzegorz w kategorii English, Informatyka, Krótkie, Porady

Google wasn’t awfully helpful while I was searching for solution to word wrapping a text when drawing 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;
            }
        }
    }

Brak komentarzy

Nov 07 2008

Uwaga karmiące mamy!

Napisał(a) Grzegorz w kategorii Humor, Krótkie

Szczeciński sąd zakazał pokazywania piersi dzieciom w związku z czym należy je teraz karmić butelką lub ostatecznie z zawiązanymi oczami.

Brak komentarzy

Sep 02 2008

[en] NetBeans 6.5 and JiBX problems solved

Napisał(a) Grzegorz w kategorii English, Informatyka, Krótkie, Porady

After upgrading NetBeans to 6.5 the -post-compile task I added so JiBX bindings are compiled stopped working for me throwing an exception about bindings not found at runtime.

The solution to this is to disable “Compile on Save” feature in project properties.

Brak komentarzy

Jul 03 2008

[en] Installing SilverStripe on IIS server

Napisał(a) Grzegorz w kategorii English, Informatyka

UPDATE 2009-02-17: As Sigurd from SilverStripe team states in a comment, You shouldn’t need to follow my “howto” - at least if You’re using IIS 7. Since I wrote this “howto”, SilverStripe website has been improved to include installation instructions on IIS so please give it a try before proceeding with my old instructions.

1. Install ISAPI/Rewrite. I have no idea how to do it since it was already installed at my provider’s server, but there probably is a limited free version that is enough.
2. Download SilverStripe archive and extract it to Your server.
3. Go to Your server’s URL and fill in installer details as usual.
4. After rewritetest fails, create httpd.ini file in SilverStripe root directory and make its contents like that (what it basically does with ISAPI/Rewrite is to mimic Apache’s mod_rewrite):

[ISAPI_Rewrite] RewriteEngine On

RewriteCond URL (?!.*gif|.*jpg|.*png|.*swf|.*xml|.*css|.*flv|.*js|.*php).*
RewriteCond URL (?!.*\?).*
RewriteRule (.*) /sapphire/main.php\?url=$1 [I,L]

RewriteCond URL (?!.*gif|.*jpg|.*png|.*swf|.*xml|.*css|.*flv|.*js|.*php).*
RewriteCond URL .*\?.*
RewriteRule (.*)\?(.*) /sapphire/main.php\?url=$1&$2 [I,L]

5. Click “click here to proceed anyway” link and You should be redirected to an ugly looking “successfully installed” page.
6. Now edit /sapphire/core/control/Director.php file and change

$s = (isset($_SERVER[’SSL’]) || isset($_SERVER[’HTTPS’])) ? ’s’ : ”;

line to

$s = (isset($_SERVER[’SSL’]) || (isset($_SERVER[’HTTPS’]) && $_SERVER[’HTTPS’] == ‘on’)) ? ’s’ : ”;

7. Refresh the “successfully installed” page and if it looks pretty now, You know You correctly did step 6.
8. Click “Click here to delete the install files.” link so You don’t have a security hole.
9. Now edit /sapphire/main.php file and at the very beginning add these lines:

if (!isset($_SERVER[’REQUEST_URI’])) {
$_SERVER[’REQUEST_URI’] = $_SERVER[’SCRIPT_NAME’];
}

10. Following are hacks I needed to add so i18n works on IIS. If You don’t use i18n, You’ll probably be fine without these hacks. This method is in sapphire/core/i18n.php file:

protected static function get_owner_module($name) {
if (substr($name,-3) == ‘.ss’) {
global $_TEMPLATE_MANIFEST;
$path = current($_TEMPLATE_MANIFEST[substr($name,0,-3)]);
// hacks for IIS start –>
$path = str_replace(’\sapphire/..’, ”, $path);
$path = str_replace(’C:’, ”, $path);
$path = str_replace(’\', ‘/’, $path);
$bf = Director::baseFolder();
$bf = str_replace(’C:’, ”, $bf);
$bf = str_replace(’\', ‘/’, $bf);
// <– end hacks
ereg($bf . ‘/([^/]+)/’,$path,$module);
} else {
global $_CLASS_MANIFEST;
$path = $_CLASS_MANIFEST[$name];
// hacks for IIS start –>
$path = str_replace(’\sapphire/..’, ”, $path);
$path = str_replace(’C:’, ”, $path);
$path = str_replace(’\', ‘/’, $path);
$bf = Director::baseFolder();
$bf = str_replace(’C:’, ”, $bf);
$bf = str_replace(’\', ‘/’, $bf);
// <– end hacks
ereg($bf . ‘/([^/]+)/’,$path,$module);
}
return $module[1];
}

11. Enjoy :)
12. If You can’t enjoy for some reason, try checking out this thread at SilverStripe forum where most of the above info is found.

Komentarze: 2

« Poprzednie - Następne »