7 Haziran 2020 Pazar

A gotcha in ReactDom.hydrate method

It is a common practice to do server side rendering and hydrating DOM on client using reactjs. Perhaps what is not common is rendering different things on server and client side. One example I can think of for that is ads, you probably wouldn't want to render ads on server side.

If you add more things to your dom only on client side, you may notice that some of your elements are omitted by react. That is caused by reactjs thinking some elements you render are some of the previous elements that got rendered before. In order to overcome this problem having a new state variable like isClient and rendering those elements only if isClient true. And you can initialize your state variable as usual:
useEffect(() => { setIsClient(true); }, []); 
It is quite cryptic to solve this issue otherwise since there is no warnings about it.

25 Eylül 2013 Çarşamba

npm ile paket kurarken package.json'a ekleme

bir node.js projesi geliştirirken önce package.json'ı değiştirip sonra npm install demenin çifte iş olduğunu düşünüyorsanız npm install paket --save tam size göre.

18 Şubat 2013 Pazartesi

Parsing html documents which contain script tags without cdata

If you are dealing with html document which has a script tag and some javascript code inside without an opening cdata section and trying to parse it as an xml, i.e. for xpath querying, then you might get in trouble. It's because the code inside script tag becomes against the xml syntax and parser libraries fail while parsing it.

I tried the same thing in python using lxml and elementtree libraries and they gave the same result. Happily, at the last time I was about to lose my hope, beautifulsoup library came to the rescue and did my job. Appearantly they treat html files differently than an xml, which saves a day in my case.

15 Aralık 2012 Cumartesi

Thoughts about Smartfox on iPhone

We have been using smartfox in our isometric 2D social game for a very long time (since the beginning of it in fact). And I wanted to give a review to it for that reason.

 First of all, I only know the iphone client of it, because I've only used it in iphone. So this review is valid for iphone client of smartfox.

 They made iphone client closed source after some version. Because of that if a problem happens, which is likely to happen, you can not debug it. It is like a black box. And for an unknown reason it's crashing a lot. By a lot, I mean really a lot. Checking the crash statistics of our app I can say 90% of the crashes are smartfox related and number of crashes is in thousands.

Seeing so many crashes and with the fact that it is a blackbox thing, I would unfortunately not recommend using SmartFox for your multiplayer project. There is a forum of it but it doesn't seem to help in getting quick help either.

I don't know if there are good open-source multiplayer game servers but if there are, I would strongly suggest using one of them. A multiplayer game server is just a layer of getting commands and sending events or responses to clients after all. Whichever server you are using, most of the work will be your extension, which is the game logic. What SmartFox provides in addition to that is some default game concepts like rooms, users, banning etc. But they should not be so hard to implement. So I would suggest using a lightweight event mechanism for that. It can be even something like now.js or maple.js if you are into node.js.

9 Aralık 2012 Pazar

AppSurfer ve Pratik Sözlük

Birkaç ay önce aklıma Android uygulamalarını webde çalıştıran bir web uygulaması olabilir mi acaba diye bir soru gelmişti. O zamanki aramamda böyle birşey bulamamıştım. Dün ise AppSurfer diye bir sitenin bu hizmeti verdiğini öğrendim. Tam olarak benim düşündüğüm şey olmasa da Android uygulamalarını web sitelerinde çalıştırabiliriyor, kullanıcılara "canlı" bir demo şansı tanıyor AppSurfer. Uygulamalarınızın apk'sini yükleyerek hizmeti aktive edebilir, dilerseniz benim buraya koyduğum gibi widget'ını blogunuza yada web sitenize entegre edebilirsiniz. Güzel düşünülmüş bir servis.

 Aşağıdan Pratik Sözlük uygulamasını canlı canlı test edebilirsiniz :)

 

20 Ekim 2012 Cumartesi

Dropping ios 4.3 support

If you are one of the developers who think ios 4.3 is not worth supporting any more but can't be sure about it at the same time, here comes the latest stats to the rescue. I saw from live stats that currently ios 4.3.x seems to have 3% percentage in active sessions.

I think it is okay to drop 4.3.x support from now on. It's only 3% and it creates a lot of trouble for the developers who want to use ios 5 or 6 features. At the best case, your code is filled with if (IOS_VERSION > 5.0f) statements, at the worst case you get crashes in ios 4.3.x.

If you don't want to lose those guys using ios 4.3.x completely, you might degrade gracefully for them. That is some features will not be supported in ios 4.3 but they will still be able use the app with basic functionality. Try not to crash if you will follow this approach. Otherwise you can get low ratings from them.

But still, even if you drop support for ios 4.3.x, don't forget to follow MVC correctly and try not to abuse UIViewController's. See my previous blog post about it.

1 Ekim 2012 Pazartesi

NSString length for 4-byte characters

If you worked with 4 bytes characters -such as emoji- on ios, you should have noticed that NSString handles those 4-byte characters a little different than expected. Well, I might be missing something but it counts a 4-byte emoji as 2 characters.

Hence, If you need to process a string which contains a 4-byte character, you might need some new methods to calculate the length or offset in that string. I wrote two category methods for this purpose. One finds the length of the string and the other converts an offset calculated by NSString methods to the correct value. Feel free to use them if you need:


Note: NSString counts a 3-byte character as 1 character as expected.