Caution: my English is far from perfect. (Русский тоже не всегда хорош).

Saturday 13 December 2008

Винни-Пых

Читал сейчас в википедии статью про Винни-Пуха. В частности, там рассказывается про звучание имени на разных языках. Например, в английском языке «h» в имени Pooh не произносится, это имя рифмуется постоянно с who или do.

В белорусском переводе некоего Виталя Воронова — Віня-Пых. Вторая часть имени переведена как «Пых», якобы потому, что это созвучно с белорусскими словами пыха (высокомерие и гордость) и запыхацца.

Sunday 7 December 2008

Как скрыть рекламу в Live Journal

Я читаю несклько блогов в Live Journal и мне мешает громадный рекламный баннер на пол экрана, который Live Journal вставляет в блоги бесплатных аккаунтов.

AdBlock плагин к Firefox в данном случае не помог, он скрывает картинку, но тогда остается большое белое пространство, что не намного лучше картнинки.

В Google быстро нашлось решение.

Для Firefox

Создаем файл userContent.css:


/* Removes LJ Ads from pages. */
/* Code From ambience8 */

@-moz-document domain("livejournal.com") {

div.adv {display: none !important; visibility: hidden !important;}
div.ljad {display: none !important; visibility: hidden !important;}
div.ljadleaderboard-bottom {display: none !important; visibility: hidden !important;}
div.ljadleaderboard {display: none !important; visibility: hidden !important;}
div.ljadwrapper-journal-after-post-c {display: none !important; visibility: hidden !important;}
div.ljadwrapper-app-home {display: none !important; visibility: hidden !important;}
div.ljadmedrect {display: none !important; visibility: hidden !important;}

}
Этот файл нужно положить в директорию chrome вашего профиля. На Widows XP это будет C:\Documents and Settings\<Имя Пользователя>\Application Data\Mozilla\Firefox\Profiles\xxxxxxxx.default\chrome\userContent.css. В Windows Vista: C:\Users\<Имя Пользователя>\AppData\Roaming\Mozilla\Firefox\Profiles\xxxxxxxx.default\chrome\userContent.css

Теперь перезапускаем Firefox. В результате реклама в блогах Live Journal должна исчезнуть.

Для Internet Explorer

Создаем файл userContent.css:

/* Removes LJ Ads from pages. */
/* Code From ambience8 */

div.adv {display: none !important; visibility: hidden !important;}
div.ljad {display: none !important; visibility: hidden !important;}
div.ljadleaderboard-bottom {display: none !important; visibility: hidden !important;}
div.ljadleaderboard {display: none !important; visibility: hidden !important;}
div.ljadwrapper-journal-after-post-c {display: none !important; visibility: hidden !important;}
div.ljadwrapper-app-home {display: none !important; visibility: hidden !important;}
div.ljadmedrect {display: none !important; visibility: hidden !important;}

В меню Internet Explorer выбираем Tools -> Internet Options -> General -> Accessibility -> User style sheet. Здесь указываем путь к созданному файлу.

Как можно заметить из кода, решение для Internet Explorer будет скрывать элемены div с классом adv на любых страницах, а не только в livejournal.com, так что... это не страшно :)

Источник: http://wiki.noljads.com/Hiding_LiveJournal_ads_with_user_stylesheets

Friday 5 December 2008

Hunchentoot on ECL

It was reported that all Hunchentoot dependencies are already ported to ECL and a patch exists for Hunchentoot itself to make it running on ECL.

I am glad to hear this, because ECL is the only free Common Lisp on Windows with multithreading support (at the same time an active work on multithreading for CLISP is in progress, Clozure CL has beta port for Windows, and a lot of work was also done for threading in SBCL Windows port, although the work is not finished).

I tried Hunchentoot on ECL and for those who are interested too, I reproduce here the steps I took. My environment: Windows XP + Microsoft Visual Studio.

  1. You need the latest versions of Hunchentoot and all the dependencies. If you are lazy, you may get all them at once from this archive I prepared.
  2. Apply the patch from this post (already done in my archive): save the port-ecl.lisp to the hunchentoot directory and add #+:ecl (:file "port-ecl") to hunchentoot.asd as here.
  3. Checkout fresh ECL from CVS:
      cvs -z3 -d:pserver:anonymous@ecls.cvs.sourceforge.net:/cvsroot/ecls checkout ecl
    
    I recommend fresh checkout because I had problems building ECL from sources already existing on my computer after update with cvs update -dAP.
  4. Configure ECL. Open ecl\msvc\Makefile and set
    ECL_THREADS  = 1
    ECL_UNICODE  = 1
    ECL_ASDF     = 1
    ECL_SOCKETS  = 1
    
  5. Build ECL. Run Visual Studio command prompt: menu Start->All Programs -> Microsoft Visual Studio 2005 -> Visual Studio Tools -> Visual Studio 2005 Command Prompt. This script sets up environment variables so that C compiler cl.exe, nmake.exe and other things are in your PATH, all includes and libraries are available, etc. In this console window type:
     > cd <DIR_WITH_ECL_SOURCES>\ecl\msvc
     > nmake
    
    After the build completes, copy resulting binaries somewhere:
      > nmake install prefix=c:\somewhere\ecl
    Now you have working ECL, lets test it:
    > c:\somewhere\ecl\ecl.exe
    ECL (Embeddable Common-Lisp) 0.9l (CVS 2008-07-12 18:54)
    Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
    Copyright (C) 1993 Giuseppe Attardi
    Copyright (C) 2000 Juan J. Garcia-Ripoll
    ECL is free software, and you are welcome to redistribute it
    under certain conditions; see file 'Copyright' for details.
    Type :h for Help.  Top level.
    > (+ 2 2)
    4
    > (quit)
    
    Works.

    Do not close the Visual Studio command prompt, we will need it soon.

  6. As Hunchentoot uses ASDF, we need Hunchentoot with all its dependencies to be registered in ASDF:*CENTRAL-REGISTY*. For this I have a special lisp file, setup-asdf-registry.lisp (already included in the archive from the step 1):
    ;; this file must be stored in the same directory
    ;; where all the lisp libraries are stored 
    ;; (but libraries, of course, have their own subdirectories)
    
    (require 'asdf)
    
    (flet
        ((reg (relative-lib-dir)
           (let ((lib-dir
                  (directory-namestring 
                   (merge-pathnames relative-lib-dir
                                    (load-time-value
                                     (or #.*compile-file-pathname* 
                                         *load-pathname*))))))
             (pushnew lib-dir
                      asdf:*central-registry*
                      :test #'equalp))))
      (reg "alexandria\\")
      (reg "asdf-binary-locations\\")
      (reg "babel_0.2.0\\")
      (reg "cffi-080926\\")
      (reg "chunga-0.4.3\\")
      (reg "cl-base64-3.3.2\\")
      (reg "cl-fad-0.6.2\\") 
      (reg "cl-ppcre-2.0.1\\")
      (reg "cl-who-0.11.0\\")
      (reg "cl+ssl\\")
      (reg "flexi-streams-1.0.7\\")
      (reg "hunchentoot-0.15.7\\")
      (reg "md5-1.8.5\\")
      (reg "rfc2388\\")
      (reg "trivial-features_0.1\\")
      (reg "trivial-gray-streams\\")
      (reg "url-rewrite-0.1.1\\"))
    
    (asdf:operate 'asdf:load-op :asdf-binary-locations) 
  7. Compile and load Hunchentoot. For this go back to the Visual Studio command prompt.
    > c:\somewhere\ecl\ecl.exe  
    > (load "c:/archive-from-the-step-1/setup-asdf-registry.lisp") 
    > (pushnew :hunchentoot-no-ssl *features*)
    > (asdf:operate 'asdf:load-op :hunchentoot-test)
    
    ECL must be started from Visual Studio command prompt because it uses C compiler when compiling Lisp. (pushnew :hunchentoot-no-ssl *features*) is only necessary if you do not have OpenSSL installed (get it here for Win32).
  8. Start Hunchentoot:
    > (hunchentoot:start-server :port 4242) 
    

Now you may open http://localhost:4242/hunchentoot/test and see Hunchentoot test site.

At the moment of this post writing, almost all examples from the test site work, except for two: "UTF-8 demo (writing UTF-8 characters directly to the stream)" and "UTF-8 demo (returning a string)". The reason is already found and I am sure it will be fixed very soon.

Wednesday 3 December 2008

Simpler Clojure/SLIME Embedding

Thanks to Craig McDaniel's hint, I know a simpler way to embed Clojure/SLIME than I used before. Since Clojure svn revision 1127, macro clojure.main/with-bindings makes the embedding as trivial as this jsp page.

Blog Archive