"The Grid. A digital frontier. I tried to picture clusters of information as they move through the computer. What did they look like? Ships? Motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I’d never see. And then, one day, I got in." — Tron: Legacy

2013-06-23

Konfiguracja Honeywell Dolphin 7800 Android na Ubuntu 12.04

Kolejna ściąga. Jako, że urządzenia nie ma uwzględnionego w SDK Androida, trzeba trochę pogrzebać ręcznie.

2013-05-31

Clojure on Android, quick intro

This time I'll show how to create Android application using Clojure programming language. Clojure is one of the most interesting practical functional languages ​​(in contrast e.g. to Haskell). It's a Lisp, so you can just run it and start hacking. This language makes it easy to play with code and stimulates curiosity.


It's just a very short intro to the configuration and ho to run basic program. For the impatient who want more I recommend a look at the neko library here: https://github.com/alexander-yakushev/neko


2013-05-28

Clojure na Android Intro

Tym razem wstępniak do tworzenia aplikacji na Androida przy użyciu języka programowania Clojure. Clojure to jeden z ciekawszych praktycznych języków funkcyjnych (w przeciwieństwie np. do Haskella). Jako, że to Lisp, można go po prostu uruchomić i zacząć hackować. Język ten ułatwia zabawę z kodem i stymuluje ciekawość. Clojure promuje eksperymentowanie. Z resztą przekonaj się sam. 

To tylko króciutkie intro przedstawiające proces konfiguracji i uruchomienia środowiska. Dla niecierpliwych, którzy chcą więcej polecam zapoznać się z biblioteką neko: https://github.com/alexander-yakushev/neko . 

2013-05-06

Fetching images from any Web page using Clojure

As title says this post will be about downloading images from given page link.  To make this task a little easier I am using Enlive library available here: https://github.com/cgrand/enlive

There are primarily 4 main steps to do this. 
- read page source from given address
- parse it 
- find all <img> tags and store its src (image link) value
- use these links to fetch images directly and store them to disk

Because function that reads image from URL needs full address like: "http://..." I'm adding additional step: 
- check if image URL has a valid root

It means that if image link starts with "/" I must add Web page URL at the beginning.  

This is how it looks like in Clojure. Remember to add 
[enlive "1.1.1"] dependency to project.clj if you're using Leiningen. Also create target directory if it doesn't exist.

2013-05-01

Przyspieszanie skryptów Clojure


Z pewnością wiele osób stroni/unika używania Javy lub innego języka opartego o JVM do uruchamiania skryptów ze względu na bardzo powolny czas startu. Przede wszystkim dotyczy to programistów Clojure, którego rozgrzewka jest, można powiedzieć, baaaaardzo długa jak na wymagania małych skryptów i wręcz przekreśla jakiekolwiek pożyteczne zastosowanie. Jest jednak na to sposób. Trzeba zaprzęgnąć do roboty program o nazwie Drip ( dostępny na: https://github.com/flatland/drip ).

Drip po pierwszym uruchomieniu, które trwa podobnie długo jak zwykłe uruchomienie programu przy pomocy polecenia java, ładuje świeże środowisko Java do pamięci i do takiego czystego środowiska zapodaje program, który uruchamia się niemal natychmiast.

2013-03-05

Android 4.0 na PC

Kolejna ściąga. Tym razem szybka konfiguracja Androida przy użyciu VirtualBox.

Jeżeli ktoś już bawił się w tworzenie aplikacji, to wie, że czas startu emulatora dołączanego do androidowego SDK może przysporzyć człowieka o kolejne siwe włosy. Potrzebowałem ostatnio na gwałt czegoś, co zastąpi mi w deweloperce tablet. Czemuż to? Otóż, po kilku reinstalacjach systemu, głównie po to by przetestować różne ROMy zaczął szwankować Bluetooth. Przez kilku tygodni, mimo kilku wycieczek ze śrubokrętem i czyszczenia elektroniki Bluetooth nie działał. Do wczoraj... Gdy zakupiłem adapter Bluetooth i znalazłem odpowiednią wersję pod maszynę wirtualną, która w miarę działa, nagle tabletowy odpowiednik ożył. Jak na złość. Ręce opadają... No nic, 20 PLN to nic takiego, a już nie wierzę, że pewnego dnia znów BT w tablecie odmówi posłuszeństwa. Wybrałem więc opcję dalszej pracy bez tabletu. 

Obr. 1. Ekran blokady.

Jedyną bezproblemowo działającą (z kilu testowanych) wersją Androida okazała się wersja 4.0 na eeepc. Dokładnie to obraz android-x86-4.0-RC2-eeepc.iso ze strony http://www.android-x86.org/download. Jako jedyny bezproblemowo obsługuje sieć i Bluetooth. Wersja 2.2 miała problemy z konfiguracją sieci, a za to dział Bluetooth. W wersji ostatniej (4.2) natomiast jest odwrotnie.


Po ściągnięciu VirtualBox należy także ściągnąć dodatkową paczkę narzędzi: VM VirtualBox Extension Pack. Należy pamiętać by wersje VirtualBox i paczki narzędziowej były takie same. 


Dla instalacji maszyny stacjonarnie, bez opcji LiveCD zarezerwowałem 1.5GB przestrzeni dyskowej, podłączyłem 2 rdzenie procesora. Jako, że moja aplikacja domyślnie działa w orientacji pionowej trzeba było też edytować kilka plików konfiguracyjnych. W Menu wyboru wybrać VESA Mode by uruchomić lub Install to disk by zainstalować na stałe. Jeżeli to drugie, to najpierw zainstalować GRUB, a pod koniec instalacji jeżeli instalator zapyta się czy zamontować /system do odczytu i zapisu potwierdzić Yes. Umniejszy to później liczbę problemów z edytowaniem plików Androida.

2013-02-12

Clojure i Emacs z wtyczką nREPL na Windows

Kolejna ściąga w notatniku. Tym razem instalacja Emacsa na Windows z wtyczką nREPL ( https://github.com/clojure/tools.nrepl ). nREPL jest aktywnie rozwijanym zamiennikiem do niewspieranego już SLIME i wtyczki swank-clojure, których instalację opisałem w poprzednim wpisie dot. Emacs. Oczywiście jak najbardziej poprzednie dodatki działają i sprawują się dość dobrze, ale lepiej wyjść z zasady i dmuchać na zimne, bo pewnego dnia przestaną one działać.

Przy instalacji może się przydać narzędzie do edycji zmiennej systemowej PATH: Redmond Path ( http://download.cnet.com/Redmond-Path/3000-2094_4-10811594.html ). Przyda się także narzędzie do pobierania danych z linii poleceń : curl lub wget. Jako, że curl jest już w paczce Git ( http://git-scm.com/downloads ), którego używam, trzeba się postarać, by katalog bin z Gita był uwzględniony w PATH.

Emacsa dla Windows można pobrać z : http://ftp.gnu.org/pub/gnu/emacs/windows/ . Należy wybrać możliwie najnowszą wersję. Oczywiście najlepiej rozpakować pobrane archiwum do katalogu głównego na jakimś dysku i nie używać w nazwie spacji. Dotyczy to wszystkiego co tutaj wykonuję. U siebie daję go do C:\Emacs. Dodaję do PATH także katalog C:\Emacs\bin.

2013-01-26

Smalltalk and Seaside part 4.

(c) Robert Tinney
This time this blog post is in English. I decided to change language when I saw link to my blog at Seaside.st. The other reason is that Google's translator just sucks. I hope to suck less.

Post 4 is the last post from the series about HTML parsing and presenting results in form of a web page using Smalltalk and Seaside. All these posts about Smalltalk were my attempt to find out for myself what this language is really about. A year ago I didn't even know about it's existence. My programming world till that time was wrapped mainly in C/C++ and Java. So I thought I'll try some of it in action and that the best way to grab a bit of it is to try it in practice and to solidify that experience on a blog. Well, actually Smalltalk was the main reason for this blog to show up. At the same time I also found Clojure. Both of these as languages just blown my C/Java mind away. Smalltalk is impossibly simple language and has a very helpful IDE (a REAL IDE not just some editor with syntax highlighter and fancy keyboard shortcuts that spit out code or strictly said: vomit code at you). Seaside is also one of the most brilliant ideas I've seen. To efficiently build apps with Seaside actually all you need is a basic knowledge of HTML and CSS and surprisingly no JavaScript - I didn't need it through the whole creation process. Less is better. ;) I find the idea about Smalltalk application image far superior than Java libraries and whats more, easier way to share applications than using jars. For example, I don't have to do anything with my application if I want run it on Android - just copy and run ( thanks to this project: http://code.google.com/p/squeakvm-tablet/ ). Can you do it in Java? You can't!

So lets get back to play. Last time I left, my blog comments reader was in the state where i had to manually add entries to collection, comments were looking ugly, there was no way to remove entry form collection, etc...

This time I wont show any code here (as a text). I decided to share whole one-click Pharo image where you can experiment with. Ill just describe what my objects do.

First, I'll show you the final look:

Well, at least it is not as scary looking as last one...

The minus sign removes entry , + button displays DPDialog, and U button updates comments.
DPDialog looks like this:

Some code:

A you can see its a jQuery dialog, simple, nothing fancy. Code under submitButton checks if user entered a valid URL (its valid if it can be read from). If its OK then DPRoot class adds blog entry to its internal list and then tries to parse comments from given URL.

CSS code is kept within object called DPCSSLibrary. Adding library is simple, just follow this: http://book.seaside.st/book/in-action/serving-files/filelibraries/creating .

Here is the graphical description of how tabs bar is created:


Updated DPComment rendering method:
This method checks if its instance variable (DPComments object sets it when creating new DPComment) is false or true naming div element accordingly, so its later possible to apply a proper CSS code.

Whole application as One-click archive: https://dl.dropbox.com/u/71388328/DP-OneClick.zip