NetBEANS 8 RC1 is out and working on Linux and Windows.
Category: Linux
Chaos
Partially doe to my work but mostly of my personal interest I have read (listen) to this fascinating book about patterns found in chaos. Professionally I am involved in road traffic management works in The Netherlands. Road traffic is a good representation of chaos where many patterns are already discovered but there is still lot of work to be done.
This book gave me good inside about new developing science and I found this book very engaging. I would highly recommend this book to anyone interested in mathematics, physics, population biology and other diverse fields.
Numerical analyses and Gephi
Recently after listening of few great books about number crunching and the latest Linked… I’m fascinated with chaos theories. I have started running my own web-spider to collect data for later analyses. Iwas looking for any visualization tool to produce nice graphs with PHP but I have found something really amazing and free (Open Source). Check it out: Gephi.
Watch the video: Introducing Gephi 0.7 from gephi on Vimeo.
PHP Pear – Mail
Po instalacji paczki Mail wraz z zależnościami możemy uruchomić pierwsze skrypty do wysyłania e-maili.
Przykład podstawowy:
<?php
// Dolaczona paczka Pear Mail
include(‘Mail.php’);
$mail = Mail::factory(“mail”);// W header adres nadawcy i tytul wiadommosci
$headers = array(“From”=>”ja@przyklad.pl”, “Subject”=>”Test Mail”);// Tresc wiadomosci
$body = “To jest test!”;// Wyslylamy do on@przyklad.pl
$mail->send(“dkrysmann@gmail.com”, $headers, $body);
?>
PHP Pear – Instalacja
W kilku z moich aplikacji internetowych zastosowałem biblioteki PEAR. Jedna z nich to Mail do wysyłania e-maili. Zaleta rozwiązania pear jest na przykład to ze tak zwany mail_header jest dobrze skomponowany. W przeszłości stosowałem PHP mail() i zauważyłem ze niektóre serwery pocztowe odzucaly e-maile wysłane z PHP mail()
Instalacja
Zakładam ze masz działający LAMP server, przykłady tu zawarte opieraja sie na Ubuntu – Apache – PHP – MySQL.
Instalacja PEAR:
sudo apt-get install php-pear
Po instalacji możemy sprawdzić czy PEAR jest dostępny za pomoca nastepujacej komendy:
pear
… w rezultacie otrzymamy listę dostępnych opcji.
Teraz możemy zainstalować poszczególne komponenty (klasy) które chcemy zastosować. Za pomoca komendy search mozemy poszukac klasy, na przyklad:
pear search mail
…rezultat:
Retrieving data…0%
….50%..Matched packages, channel pear.php.net:
=======================================
Package Stable/(Latest) Local
Mail 1.2.0 (stable) 1.2.0 Class that provides multiple interfaces for sending emails
Mail_IMAP 1.1.0RC2 (beta) Provides a c-client backend for webmail.
Mail_IMAPv2 0.2.1 (beta) Provides a c-client backend for webmail.
Mail_Mbox 0.6.3 (beta) Read and modify Unix MBOXes
Mail_Mime 1.8.0 (stable) 1.8.0 Mail_Mime provides classes to create MIME messages.
Mail_mimeDecode 1.5.4 (stable) 1.5.4 Provides a class to decode mime messages.
Mail_Queue 1.2.6 (stable) Class for put mails in queue and send them later in background.
Net_Vpopmaild 0.3.2 (beta) Class for accessing Vpopmail’s vpopmaild daemon
Tu warto zauważyć ze niektóre paczki (packages) maja dopisek (stable) a inne (beta). Standardowo można instalować tylko paczki stabilne (stable). Paczki beta maja lub mogą mieć pewne niedociągnięcia i są jeszcze rozwijane. Jeżeli mimo wszystko chcemy skorzystać z paczki o statusie beta należy odpowiednio “nastawic” pear za pomocą komendy:
pear config-set preferred_state beta
Oprócz statusów stable i beta istnieja rowniez paczki o statusie alpha i devel.
Sama instalacja dowolnej paczki odbywa sie za pomoca komendy:
sudo pear install –alldeps Mail
… gdzie opcja –alldeps zapewni nas ze wszystkie paczki które są konieczne do działania paczki która instalujemy tez się zainstalują.
Zrodla: http://pear.php.net
MySQL performance tips
1. Use EXPLAIN to profile the query execution plan
2. Use Slow Query Log (always have it on!)
3. Don’t use DISTINCT when you have or could use GROUP BY
4. Insert performance
1. Batch INSERT and REPLACE
2. Use LOAD DATA instead of INSERT
5. LIMIT m,n may not be as fast as it sounds. Learn how to improve it (if possible): http://www.facebook.com/note.php?note_id=206034210932
6. Don’t use ORDER BY RAND() if you have > ~2K records
7. Use SQL_NO_CACHE when you are SELECTing frequently updated data or large sets of data
8. Avoid wildcards at the start of LIKE queries
9. Avoid correlated subqueries and in select and where clause (try to avoid in)
10. No calculated comparisons — isolate indexed columns
11. ORDER BY and LIMIT work best with equalities and covered indexes
12. Separate text/blobs from metadata, don’t put text/blobs in results if you don’t need them
13. Derived tables (subqueries in the FROM clause) can be useful for retrieving BLOBs without sorting them. (Self-join can speed up a query if 1st part finds the IDs and uses then to fetch the rest)
14. ALTER TABLE…ORDER BY can take data sorted chronologically and re-order it by a different field — this can make queries on that field run faster (maybe this goes in indexing?)
15. Know when to split a complex query and join smaller ones
16. Delete small amounts at a time if you can
17. Make similar queries consistent so cache is used
18. Have good SQL query standards
19. Don’t use deprecated features
20. Turning OR on multiple index fields (<5.0) into UNION may speed things up (with LIMIT), after 5.0 the index_merge should pick stuff up.
21. Don’t use COUNT * on Innodb tables for every search, do it a few times and/or summary tables, or if you need it for the total # of rows, use SQL_CALC_FOUND_ROWS and SELECT FOUND_ROWS()
22. Use INSERT … ON DUPLICATE KEY update (INSERT IGNORE) to avoid having to SELECT
23. use groupwise maximum instead of subqueries
24. Avoid using IN(…) when selecting on indexed fields, It will kill the performance of SELECT query.
Scaling Performance Tips:
1. Use benchmarking
2. isolate workloads don’t let administrative work interfere with customer performance. (ie backups)
3. Debugging sucks, testing rocks!
4. As your data grows, indexing may change (cardinality and selectivity change). Structuring may want to change. Make your schema as modular as your code. Make your code able to scale. Plan and embrace change, and get developers to do the same.
Network Performance Tips:
1. Minimize traffic by fetching only what you need.
1. Paging/chunked data retrieval to limit
2. Don’t use SELECT *
3. Be wary of lots of small quick queries if a longer query can be more efficient
2. Use multi_query if appropriate to reduce round-trips
3. Use stored procedures to avoid bandwidth wastage
OS Performance Tips:
1. Use proper data partitions
1. For Cluster. Start thinking about Cluster *before* you need them
2. Keep the database host as clean as possible. Do you really need a windowing system on that server?
3. Utilize the strengths of the OS
4. pare down cron scripts
5. create a test environment
6. source control schema and config files
7. for LVM innodb backups, restore to a different instance of MySQL so Innodb can roll forward
8. partition appropriately
9. partition your database when you have real data — do not assume you know your dataset until you have real data
MySQL Server Overall Tips:
1. innodb_flush_commit=0 can help slave lag
2. Optimize for data types, use consistent data types. Use PROCEDURE ANALYSE() to help determine the smallest data type for your needs.
3. use optimistic locking, not pessimistic locking. try to use shared lock, not exclusive lock. share mode vs. FOR UPDATE
4. if you can, compress text/blobs
5. compress static data
6. don’t back up static data as often
7. enable and increase the query and buffer caches if appropriate
8. config params — http://docs.cellblue.nl/2007/03/17/easy-mysql-performance-tweaks/ is a good reference
9. Config variables & tips:
1. use one of the supplied config files
2. key_buffer, unix cache (leave some RAM free), per-connection variables, innodb memory variables
3. be aware of global vs. per-connection variables
4. check SHOW STATUS and SHOW VARIABLES (GLOBAL|SESSION in 5.0 and up)
5. be aware of swapping esp. with Linux, “swappiness” (bypass OS filecache for innodb data files, innodb_flush_method=O_DIRECT if possible (this is also OS specific))
6. defragment tables, rebuild indexes, do table maintenance
7. If you use innodb_flush_txn_commit=1, use a battery-backed hardware cache write controller
8. more RAM is good so faster disk speed
9. use 64-bit architectures
10. –skip-name-resolve
11. increase myisam_sort_buffer_size to optimize large inserts (this is a per-connection variable)
12. look up memory tuning parameter for on-insert caching
13. increase temp table size in a data warehousing environment (default is 32Mb) so it doesn’t write to disk (also constrained by max_heap_table_size, default 16Mb)
14. Run in SQL_MODE=STRICT to help identify warnings
15. /tmp dir on battery-backed write cache
16. consider battery-backed RAM for innodb logfiles
17. use –safe-updates for client
18. Redundant data is redundant
Storage Engine Performance Tips:
1. InnoDB ALWAYS keeps the primary key as part of each index, so do not make the primary key very large
2. Utilize different storage engines on master/slave ie, if you need fulltext indexing on a table.
3. BLACKHOLE engine and replication is much faster than FEDERATED tables for things like logs.
4. Know your storage engines and what performs best for your needs, know that different ones exist.
1. ie, use MERGE tables ARCHIVE tables for logs
2. Archive old data — don’t be a pack-rat! 2 common engines for this are ARCHIVE tables and MERGE tables
5. use row-level instead of table-level locking for OLTP workloads
6. try out a few schemas and storage engines in your test environment before picking one.
Database Design Performance Tips:
1. Design sane query schemas. don’t be afraid of table joins, often they are faster than denormalization
2. Don’t use boolean flags
3. Use Indexes
4. Don’t Index Everything
5. Do not duplicate indexes
6. Do not use large columns in indexes if the ratio of SELECTs:INSERTs is low.
7. be careful of redundant columns in an index or across indexes
8. Use a clever key and ORDER BY instead of MAX
9. Normalize first, and denormalize where appropriate.
10. Databases are not spreadsheets, even though Access really really looks like one. Then again, Access isn’t a real database
11. use INET_ATON and INET_NTOA for IP addresses, not char or varchar
12. make it a habit to REVERSE() email addresses, so you can easily search domains (this will help avoid wildcards at the start of LIKE queries if you want to find everyone whose e-mail is in a certain domain)
13. A NULL data type can take more room to store than NOT NULL
14. Choose appropriate character sets & collations — UTF16 will store each character in 2 bytes, whether it needs it or not, latin1 is faster than UTF8.
15. Use Triggers wisely
16. use min_rows and max_rows to specify approximate data size so space can be pre-allocated and reference points can be calculated.
17. Use HASH indexing for indexing across columns with similar data prefixes
18. Use myisam_pack_keys for int data
19. be able to change your schema without ruining functionality of your code
20. segregate tables/databases that benefit from different configuration variables
Other:
1. Hire a MySQL ™ Certified DBA
2. Know that there are many consulting companies out there that can help, as well as MySQL’s Professional Services.
3. Read and post to MySQL Planet at http://www.planetmysql.org
4. Attend the yearly MySQL Conference and Expo or other conferences with MySQL tracks (link to the conference here)
5. Support your local User Group (link to forge page w/user groups here)
[edit] Authored by
Jay Pipes, Sheeri Kritzer, Bill Karwin, Ronald Bradford, Farhan “Frank Mash” Mashraqi, Taso Du Val, Ron Hu, Klinton Lee, Rick James, Alan Kasindorf, Eric Bergen, Kaj Arno, Joel Seligstein, Amy Lee,sameer joshi
Retrieved from “http://forge.mysql.com/wiki/Top10SQLPerformanceTips”
Zapis adresu IP w MySQL
Efektywny zapis adresów IP w bazie danych (MySQL) można zrealizować za pomocą funkcji INET_ATON w MySQL
INET_ATON() Zwraca numeryczna wartość adresu IP
mysql> SELECT INET_ATON(‘209.207.224.40’);
-> 3520061480
Powstała wartość numeryczna należy zachować jako INT(10) UNSIGNED
By odtworzyć adres IP z wartości numerycznej zastosuj INET_NTOA().
INET_NTOA() Zwróć adres IP z wartości numerycznej
mysql> SELECT INET_NTOA(3520061480);
-> ‘209.207.224.40’
http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html
Akcja Uwolnij Laptopa
Akcja Uwolnij Laptopa
Pozbawi? Microsoft dominacji na rynku i uniemożliwi podobne precedensy w przyszłości.
Mam nadzieje ze podobne akcje powstaną dookoła świata. Kilka razy słyszałem o podobnych akcjach jednak wszystkie jakoś zamierają.
DVB-usb tuner w Ubuntu (AF9015)
Jakis czas temu kopi?em tani tuner DVB który nie działał pod Ubuntu 8.10. Schowa?em go do szuflady i zapomniałem o nim do dziś kiedy go znalazłem mając już zainstalowany Ubuntu 9.04. Postanowiłem sprawdzić czy zadziała na najnowszym Ubuntu. Nie zadziałał od razu jak sie można było spodziewać, ale szybko znalazłem strone opisująca jak uruchomi? DVB Tuner Afatech 9015 pod Ubuntu 8.10.
Pozwoliłem sobie zatem streścić opis instalacji tego tunera USB w Ubuntu 9.04.
Należy zainstalować narzędzia służące do kompilacji jeżeli i jeszcze nie mamy:
sudo apt-get install mercurial linux-headers-$(uname -r) build-essential gcc make
później pobieramy plik i przystępujemy do instalacji:
hg clone http://linuxtv.org/hg/~anttip/af9015/archive/tip.tar.gz cd tip.tar.gz make && sudo make install
Po około 7 minutach instalacja była gotowa i można przejść do dalszego ciągu uruchamiania tunera.
Otwórzplik /etc/modules dowolnym edytorem tekstu:
sudo nano /etc/modules
dodaj następująca linie na końcu tego pliku
dvb-usb-af9015
Pobierz ostatnia wersje firmware z tego miejsca:
http://www.otit.fi/~crope/v4l-dvb/af9015/af9015_firmware_cutter/firmware_files/
na dzie? dzisiejszy by?a to wersja 4.95.0
http://www.otit.fi/~crope/v4l-dvb/af9015/af9015_firmware_cutter/firmware_files/4.95.0/dvb-usb-af9015.fw
po pobraniu skopiuj ten plik do pliku /lib/firmware nastepujacym poleceniem:
sudo cp dvb-usb-af9015.fw /lib/firmware
Teraz uruchomiłem podgląd w logu /var/log/messages poleceniem:
tail -f /var/log/messages
podłączyłem tuner do gniazda USB i odczyta?em podobny komunikat:
Jun 10 23:56:38 think2 kernel: [ 352.900670] dvb-usb: found a 'Afatech AF9015 DVB-T USB2.0 stick' in cold state, will try to load a firmware Jun 10 23:56:38 think2 kernel: [ 352.900679] usb 1-8: firmware: requesting dvb-usb-af9015.fw Jun 10 23:56:38 think2 kernel: [ 352.966023] dvb-usb: downloading firmware from file 'dvb-usb-af9015.fw' Jun 10 23:56:39 think2 kernel: [ 353.045240] dvb-usb: found a 'Afatech AF9015 DVB-T USB2.0 stick' in warm state. Jun 10 23:56:39 think2 kernel: [ 353.046656] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer. Jun 10 23:56:39 think2 kernel: [ 353.046999] DVB: registering new adapter (Afatech AF9015 DVB-T USB2.0 stick) Jun 10 23:56:39 think2 kernel: [ 353.483721] af9013: firmware version:4.95.0 Jun 10 23:56:39 think2 kernel: [ 353.486976] DVB: registering adapter 0 frontend 0 (Afatech AF9013 DVB-T)... Jun 10 23:56:39 think2 kernel: [ 353.526282] MT2060: successfully identified (IF1 = 1220) Jun 10 23:56:40 think2 kernel: [ 354.003392] dvb-usb: Afatech AF9015 DVB-T USB2.0 stick successfully initialized and connected. Jun 10 23:56:40 think2 kernel: [ 354.024379] Afatech DVB-T 2: Fixing fullspeed to highspeed interval: 16 -> 8 Jun 10 23:56:40 think2 kernel: [ 354.024850] input: Afatech DVB-T 2 as /devices/pci0000:00/0000:00:1d.7/usb1/1-8/1-8:1.1/input/input11 Jun 10 23:56:40 think2 kernel: [ 354.033411] generic-usb 0003:15A4:9016.0008: input,hidraw6: USB HID v1.01 Keyboard [Afatech DVB-T 2] on usb-0000:00:1d.7-8/input1
Zainstalowałem również program do oglądania telewizji w DVB:
sudo apt-get install dvb-utils me-tv -y
Następnie uruchomi?em me-tv. Pojawiła sie opcja skanowania kanałów co chwile trwało i znaleziono ich 27, w tym kanały radiowe. Niestety tylko 3 publiczne kanały telewizyjne są dostępne w Holandii do odbioru za darmo.
Me TV generuje również rozpiskę programu telewizyjnego jak również możliwość nagrywania programów.
Cokolwiek tylko nie iPhone – HTC Magic
W końcu stałem się posiadaczem najnowszego telefonu z Androidem -HTC Magic zwany tez G2.
Telefon jest wyposażony w kartę pamięci 8 GB Micro-SD. Dalej wśród najważniejszych opcji jest:
WIFI (WPA, WEP)
GPS+
GSM/GPRS EDGE UMTS 3G modem
dotykowy wyświetlacz 320×480 (3,5″)
Bluetooth 2.0
3,5 Mpix camera
Bateria na 420 godzin stanby i 7,5 godzin rozmowy
System operacyjny Android 1.5, 288MB pamięci użytkowej i 512MB systemowej. Do tego pamięć jest rozszerzalna za pomocą kart SDHC.
Telefon nie ma klawiatury dzięki czemu jest mniejszy niż poprzedni model. Klawiatura na ekranie dotykowym działa dobrze.
Za pomocą Android Market można zainstalować mnóstwo najdziwniejszych programów. Pomijając rożne programy z Google z którymi system doskonale się integruje. (Maps, Gmail, Calendar, Sky Map)
Jak dotąd zabrakło mi możliwości przesyłania plików z innych urządzeń za pomocą bluetooth. Nie mogę nawet przesłać książki telefonicznej za pomocą bluetooth. Podobnie podłączenie kabla USB nic nie daje. Do telefonu można się dostać tylko poprzez siec WiFi lub “telefoniczna”.
Po podłączeniu telefonu do komputera za pomocą łącza USB nie można natychmiast dostać się do karty pamięci najpierw należy na telefonie uruchomić ta opcje w notyfikacjach.
Do synchronizacji na przykład muzyki można poza łączem USB posłużyć się programem FTP-Server z Marketu.
Nareszcie prawdziwy telefon on-line, zwłaszcza dla fanatyków Google jest urządzeniem wartym polecenia.
Cokolwiek tylko nie Apple 😉