[PHP] Eclipse + PDT + Mercurial + Win 7 = Very slow. Solution

2012-03-13   

I had this MF problem: I was using latest PDT (3.0.x) bundle, with latest Java on Windows 7 64 bit. When I was working on projects with Mercurial source control I've experienced huge hangs/lag when I was clicking on the project folder/name or right-clicking on it. After hours of frustration I finally found a solution:

  • rename .hg dir to something different for example .hg-tmp
  • refresh the project in Eclipse
  • Create a linked resource ( New -> File  -> Advanced -> Link to file in the file system ). Name it .hg
  • on filesystem: rename .hg-tmp back to .hg
  • refresh the project in Eclipse

Now things should be fine.

I am not sure why exactly above steps have positive effect but it has something to do with .hg dir slowing down Eclipse/PDT (even thou I had no hg plug-in installed in Eclipse (I use external tool -- TortoiseHg)).

[PHP] Новите неща в PHP 5.4 -- I-ва част

2012-03-04   

Изненадващо (поне за мен) онзи ден забелязах, че е излязло PHP 5.4. След всичките проблеми покрай разработката на PHP6 (за това ще има отделна публикация) си мислех, че PHP е обречено да се развива единствено в 5.3.х клона. За щастие, здравият разум "най-сетне" надделя и PHP "core" разработчиците решиха да backport-нат някои от нещата от PHP 6. Поставил съм "най-сетне" в кавички, защото идеята им беше нещата да са излезли Q2/3 на 2011, а се появяват чак сега, но важното, все пак е, че вече са налични.
По-важните неща първо "съвсем" накратко:

  • Добавена е поддръжка за traits (характерности). Те представляват … more / още »

[Android] Downloading Android source as zip

2012-01-27   

I needed the source of Anroid Froyo in order to be able to debug it in Eclipse. On the official download page there  is a description how to download it under Linux (or cygwin) but at the time I did not had either so I tried to find plain, simple, good old zip that contains the entire source but it took me quite some time googling in order to find a site that provides such downloads. In order to save you from wasting time here it is:

http://grepcode.com/project/repository.grepcode.com/java/ext/com.google.android/android/

If you need the source in order to debug it in Eclipse: download appropriate JAR (for example android-2.2_r1.1-sources.jar) , open it with zip and extract it in <android-sdk-dir>\platforms\<android-version>\sources (you may need to create "sources" subdir). Restart Eclipse and debug should work.

[Android] Using newer version of HttpClient on Android (like 4.1.x)

2011-08-20   

[EDIT] 2015-10-15: Now apache provides jar for android (currently 4.3.5.1). Also if you are targeting Android API 23 and newer you can use packages for Android maintained by Marek Sebera (currently 4.4.1.1).

[EDIT] This publication and method are old and deprecated. Please use http://code.google.com/p/httpclientandroidlib/ instead.

If you ended up here that is probably because you hit a bug  in the built-in HttpClient library which is not just old, it is beta quality (httpclient-4.0-beta1.jar). Strangely enough there is no hope that Android team will update it soon (also this is impossible without breaking backward compatibility…).

Fear not, there is a remedy.

Sadly we cannot replace the build-in library nor just add newer version but we can "trick" the system and move the library in another namespace in order to avoid conflict with the built-in lib.

The quick solution: here is an zip file containing all the required files (JARs converted using "ogrelab-" namespace prefix). Jump directly to step 7 in the "thorough" solution bellow.

The thorough solution:

Steps:

1. Download JarJar -- this is the tool which we will use to move the classes in new namespace

2. Download latest HttpClientCommonsLogging and Log4j (you will need "binary" packages) and extract them somewhere

3. Create a temporary dir somewhere like tmp_httpclient for example find following Jars and copy them into the temp dir (versions may differ):

  • commons-logging-1.1.1.jar
  • httpclient-4.1.2.jar
  • httpcore-4.1.2.jar
  • httpmime-4.1.2.jar
  • log4j-1.2.16.jar
Please note: there are additional JARs especially in the HttpClient archive but I don't use them, so I've excluded them from the list. Depending on your situation you may need them at some point so you will have to "convert" them too.
4. Copy jarjar-1.1.jar to the temp dir too … more / още »

[Android] Activity lifecycle explained in details

2011-08-09   

Activity lifecycleUsually one of the biggest obstacles for the newcommers to android programming is the correct understanding of the activity's lifecycle, for example what is the difference in the event's chain when hitting "Back" button compared to activity being closed when phone is rotated. You cannot obtain this information by looking just at the activity lifecycle diagram in the API ref. In the following post I will use sample project that uses logging to demonstrate exactly what happens in the different cases. It is ment to be used as complementary tool for understanding how activities work.

Before proceeding you may want to download the sample project: Activity Lifecycle Demo. It contains simple logging of the activity and method name in each of the methods related to the lifecycle.

1. "Cold" start

Cold start is the case when the activity was a) started for the first time OR b) started after stopped with hitting "Back" button (the hardware one not <Button> that may exists in some activity's layout).

Logcat will show something like (timestamps will differ):

08-09 17:37:20.500: INFO/TEST(10107): A onCreate
08-09 17:37:20.507: INFO/TEST(10107): A onStart
08-09 17:37:20.507: INFO/TEST(10107): A onResume

Important to note here is that when onCreate(Bundle savedInstanceState) is called savedInstanceState is null. That is because there is no saved state because this is "cold" start (obviously).

2. Hitting "Back" button

08-09 17:50:19.050: INFO/TEST(10107): A onPause
08-09 17:50:19.433: INFO/TEST(10107): A onStop
08-09 17:50:19.433: INFO/TEST(10107): A onDestroy | isFinishing: true

Important to note here is isFinishing: true which means that call to isFinishing() in the onDestroy() returns true, i.e. which happens when: … more / още »

[Android] Identifying the view selected in a ContextMenu (in onContextItemSelected() method)

2011-07-12   

Have you ever needed to popup a ContextMenu by longclicking on some of the UI element (different than item in ListView) for example an ImageView instance? At first glance it seems that this can be acomplished quite easy but in reality there is one big problem: you have only one onContextItemSelected() method in your activity that is called every time a context menu item is selected no matter which View requested the ContextMenu via openContextMenu(). This situation is not a problem if just one View is poping a ContextMenu but sometimes you need to popup ContextMenu from several different views. Let me show an example from a real app:

In this layout I have 4 ImageViews. img1 is called "primary" and all other "secondary". By specification I had to … more / още »

Tangra Framework For PHP 2.3.1 Released

2011-04-07   

I am happy to announce release of version 2.3.1 of Tangra framwork for PHP. It contains mainly new versions of many modules, most noticable -- admin_panel and user_auth _basic which now use Blowfish encryptiion for passwords which improves security.

"Compiler" for PHP files

2011-03-16   

I had this problem: sites created with Tangra Framework needed long time to "boot" because  there are more than 100 chained require_once()s. On my dev server it took between about 500 and 600 milliseconds to complete which sometimes was unacceptable. To make things even worst: when used on Windows machine with XAMPP pages needed about 1200 miliseconds to complete…

Since at least  an year I had this idea: to create a "compiler" which compiles all require_once()s into one big fat file. My idea was to point the compiler to some php file which represents web page and to let it grab recursively all the required_once() files. As a result I needed a compiled version of the web page that does not contain single require_once().

Yesterday I finally decided to try to create such compiler and as of today I finally got what I desired. Comparing profiler data "before" and "after" shows 43% improvement of the compiled PHP web page (510 ms vs 290 ms) which is great. Resulting file was 12211 lines long (with about 30% empty lines). 244 calls to require_once() was eliminated.

[PHP] Slow XAMPP on Windows 7 -- solution

2011-03-16   

Symptoms:

You install brand new latest version of XAMPP on your Windows box, everything works, but PHP pages open very slow (>1 second).

Solution:

Disable your antivirus software for few minutes, restart XAMPP and try again. If there is a significant improvement: the cause is your antivirus software (AV programs usually scan for viruses each accessed file which slows the apache).

If you are using Bitdefender here are the steps to configure it in a way suitable for usage of XAMPP:

  1. Simple solution -- just switch bitdefender to game mode when working with xampp
  2. "Advanced" solution -- go to Antivirus -> Shield -> Advanced Settings -> Exclusions Tab and there add exclusion for httpd.exe (located in your xampp installation/apache/bin/). Then go to Antivirus -> Exclusions and add exclusion for the directory where your php files reside.

Don't forget to restart apache after above steps.

 

[Android] Пуснах версия 2.0 на "МОЕТО ТОТО 2" (Android app)

2011-02-22   

Вчера мисля, че успях да ликвидирам и последния бъг в новата версия на Моето Тото 2 и тя беше публикувана в андроид маркета. Новите неща включват:

  • възможност за записване на генерираните комбинации;
  • възможност за въвеждане и записване на собствени комбинации (чрез доста удобен интерфейс IMNSHO :-) )

Връзки за сваляне:

Moeto Toto 2

За версия 3.0 очаквайте функционалност за сваляне на числата от тиражите по интернет + автоматична проверка за печалби.