Friday, August 30, 2013

Adblocking and the free web

Recently I was made aware of HeidiSQL, and besides being an awesome program, it had an even awesomer way to tackle adblockers. With your adblocker off, you see ads, with your adblocker on, it displays a message explaining how free things are powered by ads. I loved it, and asked the creator to tell me how, here's my version of his code.

  1. Find the DOM id of your ad, for me, that was 'aswift_0'
  2. insert a div before the ad
       <div id = "senseReplace" style="width:728px;" top="50%"> </div>  
  3. I also put a div around the ad that I resize to make space for the replacement message.
  4. Ad the following javascript (to your head):
     <script type="text/javascript">  
     <!--  
       function sensePage() {  
         if (!document.getElementById('aswift_0')) {  
           s = '<center><p class="senseText" style="border: 1px solid red; background: #cf9; padding: 1em; margin: 0; text-align:left; font-style:italic;">'+  
           'Adblocker activated? No problem. But please note that <b>pente.org</b> balances its '+  
           'expenses with ads. Perhaps you can consider making an exception for this site <b>or</b> <a href="/gameServer/donations">donate</a> instead?'+ '</p>'+ '</center>';   
           document.getElementById('senseReplace').innerHTML = s;  
           document.getElementById('bannerAd').setAttribute("style","width:1px; height:1px;");  
           document.getElementById('senseReplace').setAttribute("style","width:728px;");  
         } else {  
           document.getElementById('senseReplace').setAttribute("style","width:1px; height:1px;");  
           document.getElementById('bannerAd').setAttribute("style","width:728px; height:90px;");  
         }  
       }  
     //-->  
     </script>  
  5. I call my javascript function after the ad placement, but was told to call it with the  "window.onload" or "body.onload" event
Happy coding!

Tuesday, June 4, 2013

LTE on Orange Switzerland

Orange announced it flipped the LTE switch to "on" in 10 Swiss cities, but sadly, iPhone 5 owners have to wait until apple releases a carrier update that enables our iPhone 5 to connect to it.
I didn't want to wait that long and here are the instructions I followed.
  1. patch the commcenter on your phone (to accept unsigned ipcc files).
  2. Enable iTunes to process ipcc files of your choice.
  3. Then follow instructions here to alter your orange ipcc file, I used the swisscom ipcc to alter mine. Or, download the file I cooked together here, and apply that. Reboot shouldn't be necessary but an Airplane mode on-off should do the trick.
  4. If you don't see a LTE icon on your phone, that probably means you are not in a LTE- covered area.
  5. Enjoy.  

Tuesday, January 29, 2013

pente.org on iOS - my first app

I enjoy a game, if not daily then at least weekly, of pente at pente.org and ever since I owned my first iPod touch, I wanted to play pente on it. There are some nice games out there, but sadly with a weak AI or no multi-player. And someone decided it was not cool to run Java in mobile Safari, so playing on the web was also no option.

I wanted to code it for a while and after much laziness I finally got around to it, so here it is: iTunes link
Pente Live lets you play turn-based games at pente.org. No longer are you bound your computer to play pente versus other players. This app supports *all* games available at pente.org.

Features:
- Supports Pente, Connect6, Gomoku, Keryo-Pente, D-Pente, G-Pente, Poof-Pente, Boat-Pente. Turn-based games only.
- Play rated or unrated.
- Touch to zoom the board, then pan the zoomed board.
- Send invitations from your iPhone.
- Accept or decline invitations from your iPhone.
- Slide to cancel sent invitations.
- Slide to resign games.

Once it takes off, I will put in some more effort to support messages, notifications, an iPhone5 and iPad UI. And if it's ultimately possible, real-time game play.  Enjoy!