Monday, August 12, 2013

First Kiss with OUYA

The middle of 2012, that was the first time when I met Her. I was a proud builder in the big +Kickstarter land. I just started to walk around after my earlier pledge on an awesome Zombie Running game, the +Zombies, Run! After a few minutes I saw a fairy. I try to reach Her but I can not do that. Yes She was +OUYA with Her tiny silver box-body, slight roundness and sensitive Android soul.

I only dared to watch from a distance for a few days, then I tried to say something. A simple 'Hello!' was my goal but just a few stupid words left my mouth: "Eh, ah, hi!" and She looked at me. This is the heaven. We started to chat each other and after a few days I felt, I need Her presence.

As the days passed, the months passed and my feelings have not left me. December. In 2012. A cold winter, Christmas, near the New Year and She was far from me. Then came January, and then February, March, April, May and June. 2nd day of June. I got a letter. A letter from her with a simple title: #myouyaiscoming

I can not believe. I don't. But it is true. Truer than anything else. The longest month in my life. She arrived at 29th of June, yes, in my house.

A strange feeling struck me like lightning. I got my OUYA, but no TV. I never planned to buy a TV. WTF? Where? How? What? No, I need a TV for that. A month later I got my shiny blinking box. It works. OUYA is alive!

to be continued.

Thursday, April 18, 2013

Google+ Comments on your non-blogger site

Today +Google published a +Google+ based commenting system on +Blogger . This is what I expected so long. I hate when I need to read minified JavaScript but now I could get more stamina to this "awesome" digging. Finally I found the call with parameters :)


  target_id:string,             // id of the container
  Options:object {
    href:string                 // url of the page
    view_type:string            // moderated?
    first_party_property:string // BLOGGER
    width:integer               // wothout units (like px)

The first_party_property property needs to be BLOGGER because when I changed that I got a cool 400 Bad Request error from Google. I don't know if there are any other options but the only one options for view_type that I know is FILTERED_POSTMOD.

Simple way

Of course you use plusone.js in async method. Just patch your script like this:
<script type="text/javascript">
    window.___gcfg = {lang: '{{ site.lang }}'};

    (function() {
      function _getComputedStyle(el, cssprop){
       if (el.currentStyle) {
        // for IE
        return el.currentStyle[cssprop]
       } else if (document.defaultView && document.defaultView.getComputedStyle) {
        // Any other normal brwoser (like Chrome, Firefox)
        return document.defaultView.getComputedStyle(el, "")[cssprop]
       } else {
        // Try get inline style

      var script = document.createElement('script');
      script.type = 'text/javascript';
      script.async = true;
      script.onload = function() {
        if (gapi && gapi['comments'] && gapi.comments['render']) {
          var gPlusComments = document.getElementById('gpluscomments');
              href: gPlusComments.getAttribute('data-href'),
              view_type: gPlusComments.getAttribute('data-viewtype'),
              first_party_property: "BLOGGER",
              width: parseInt(_getComputedStyle(gPlusComments, "width"), 10)
      script.src = '';
      var s = document.getElementsByTagName('script')[0];
      s.parentNode.insertBefore(script, s);

After that you can create a simple div with data- properties like this (for Octopress):
<div id="gpluscomments"
     data-href='{{ site.url }}{{ page.url }}'

So, we need to add a href, view_type, first_party_property and width. First and second come from the div, third is fix (BLOGGER and later site specific string like Google API Client ID) and we can calculate the fourth parameter.

Example (my hungarian blog): [Dev] (with Octopress)

I hope I could help you. Have you got any other solution? Please, share with me.

Wednesday, March 20, 2013

Ingress unpack v1.21.3 aka. Shields?

I'm a little bit curious. So today I planned to dig inside Ingress 1.21.3 apk. First of all I unpacked with a simple method: change extension from .apk to .zip and then unzip.

What I found?

The first which came towards me: Shields (mods)

Now we know 3 types of mods. All of them: Shild
As we can see this image: there are 6 shields + 1 empty (no-shield). upgrade.atlas file tells me:

  1. empty: no shield
  4. RES_SHIELD_RARE: purple

What do you think?

Wednesday, February 20, 2013

Promoted Product Box with Octopress

Sometimes I try to share a book, a bicycle or mobile app. I tired to write the code for that. I use Octopress and I love it. Octopress built over Jekyll (what I used before) with Ruby.

# Author: Balazs Nadasdi <> (
# Outputs a string with a given attribution as a block about a Product Promotion
#  {% product_promo_box %}
#   Title: Name of the product
#   Author: Author (books), Manufacturer, etc
#   Image: Image URL about the product
#   Price: Price of the product
#   PromoPrice: Promotion Price
#   PromoCode: Promotion code
#   Source: Publisher/Seller/Site
#   Url: URL to the product
#   Description: Description of the product (short)
#  {% endproduct_promo_box %}
#  ...
#  <div class="product-box">
#   <a href="URL to the product"
#    title="Name of the product">
#    <img class="product-image"
#      src="Image URL about the product"
#      alt="Name of the product"
#      title="Name of the product">
#   </a>
#   <div class="product-info">
#    <div class="product-title">
#     <a href="URL to the product"
#      title="Name of the product">
#      Name of the product
#     </a>
#    </div>
#    <div class="product-source">
#     <a href="URL to the product"
#      title="Publisher/Seller/Site">
#      Publisher/Seller/Site
#     </a>
#    </div>
#    <div class="product-author">
#     by <span>Author (books), Manufacturer, etc</span>
#    </div>
#    <div class="product-price">
#     Old price: <span class="old">Price of the product</span>;
#     now: <span class="now">Promotion Price</span>
#    </div>
#    <div class="product-promo-code">
#     Promotion code: <span>DEAL</span>
#    </div>
#    <div class="product-description">
#     Description of the product (short)
#    </div>
#   </div>
#  </div>
# Example CSS:
#  .product-box {
#   overflow: hidden;
#   padding-bottom: 1.5em;
#   padding-top: 1.5em;
#  }
#  .product-box img {
#   float: left;
#   max-width: 25%;
#  }
#  .product-box .product-info {
#   margin-left: 28%;
#  }
#  .product-box .product-info .product-title {
#   padding-top: 10px;
#   padding-bottom: 5px;
#   font-size: 1.6em;
#   font-weight: bold;
#  }
#  .product-box .product-info .product-title a {
#   color: hsl(0, 0%, 30%);
#   text-decoration: none;
#  }
#  .product-box .product-info .product-author {
#   font-style: italic;
#  }
#  .product-box .product-info .product-price {
#   padding: 8px 0;
#  }
#  .product-box .product-info .product-price span {
#   padding: 0 5px;
#  }
#  .product-box .product-info .product-price .now {
#   color: hsl(120, 50%, 40%);
#   font-weight: bold;
#   font-size: 1.3em;
#  }
#  .product-box .product-info .product-price .old {
#   font-weight: bold;
#   font-size: 1.em;
#   text-decoration: line-through;
#  }
#  .product-box .product-info .product-promo-code {
#   font-size: 0.8em;
#  }
#  .product-box .product-info .product-promo-code span {
#   color: hsl(230, 50%, 40%);
#   font-weight: bold;
#   font-size: 1.3em;
#  }
#  .product-box .product-info .product-source {
#   font-size: 0.9em;
#   float: right;
#  }
#  .product-box .product-info .product-description {
#   padding-top: 6px;
#   font-size: 0.8em;
#   font-style: italic;
#  }

module Jekyll

 class ProductPromoBox < Liquid::Block
  Title = /^Title: (.*)$/
  Author = /^Author: (.*)$/
  Source = /^Source: (.*)$/
  Url = /^Url: (.*)$/
  Price = /^Price: (.*)$/
  PromoPrice = /^PromoPrice: (.*)$/
  Image = /^Image: (.*)$/
  PromoCode = /^PromoCode: (.*)$/
  Description = /^Description: (.*)$/

  def initialize(tag_name, markup, tokens)
   @by = nil
   @title = nil
   @source = nil
   @url = nil
   @price = nil
   @promoPrice = nil
   @image = nil
   @promoCode = nil
   @description = nil

   tokens[0].split(/\n/).each do |line|
    line = line.strip
    next if (line.length < 1)

    if line =~ Title
     @title = $1
    elsif line =~ Author
     @by = $1
    elsif line =~ Source
     @source = $1
    elsif line =~ Url
     @url = $1
    elsif line =~ Price
     @price = $1
    elsif line =~ PromoPrice
     @promoPrice = $1
    elsif line =~ Image
     @image = $1
    elsif line =~ PromoCode
     @promoCode = $1
    elsif line =~ Description
     @description = $1


  def render(context)
   promo = "";
   promo += "<div class='product-title'>#{with_link(@title, @url)}</div>" unless @title.nil?
   promo += "<div class='product-source'>#{with_link(@source, @url)}</div>" unless @source.nil?
   promo += "<div class='product-author'>by <span>#{@by}</span></div>" unless @by.nil?
   if @promoPrice.nil?
    promo += "<div class='product-price'><span class='now'>#{@price}</span></div>" unless @price.nil?
    promo += "<div class='product-price'>Old price: <span class='old'>#{@price}</span>; now: <span class='now'>#{@promoPrice}</span></div>" unless @price.nil?
   promo += "<div class='product-promo-code'>Promotion code: <span>#{@promoCode}</span></div>" unless @promoCode.nil?
   promo += "<div class='product-description'>#{@description}</div>" unless @description.nil?

   promo = "<div class='product-info'>#{promo}</div>";

   promo = with_link("<img class='product-image' src='#{@image}' alt='#{@title}' title='#{@title}'>", @url, @title) + "#{promo}" unless @image.nil?

   return "<div class='product-box'>#{promo}</div>"

  def with_link(content, url, title = nil)
   return content if url.nil?

   title = content if title.nil?

   title.gsub!(/'/, "&#39;")

   return "<a href='#{url}' title='#{title}'>#{content}</a>"

Liquid::Template.register_tag('product_promo_box', Jekyll::ProductPromoBox)
Gist url

Just put this file into your plugins directory. So when you write a new article about recommended books for instance I put this into the post:

{% product_promo_box %}
  Title: Regular Expressions Cookbook, 2nd Edition
  Author: Jan Goyvaerts, Steven Levithan
  Price: $39.99
  PromoPrice: $19.99
  PromoCode: DEAL
  Source: O'Reilly Media
  Description: Detailed Solutions in Eight Programming Languages
{% endproduct_promo_box %}

some text

{% product_promo_box %}
  Title: Dart: Up and Running
  Author: Kathy Walrath, Seth Ladd
  Price: $14.99
  Source: O'Reilly Media
  Description: A New, Tool-Friendly Language for Structured Web Apps
{% endproduct_promo_box %}

Example (Hungarian language about english books)

Feel free to use or modify :) If you got some nice idea for that please share with us.

Tuesday, January 15, 2013

Node.js - Database connection depends on environments

Image from

I hate when I need to use the same password on all of my computers only because I develop on multiple machines. For instance, I want to connect to the +MySQL database from my +node.js application , but my local configuration differs from the production environment (surprising thing is not it?).

// If DB env does not exists we need to declare
if (typeof process.env.DB == "undefined" || !process.env.DB ) {
  // Clockwork is my personal computer where I code primarily
  process.env.DB = "clockwork";

// If DB env has an unknown value
// override it
if (process.env.DB !== "clockwork" &&
    process.env.DB !== "yitsushisa" &&
    process.env.DB !== "production") {
 process.env.DB = "clockwork";

// configurations
var connections = {
  clockwork: {
    host: "localhost",
    name: "xxxxxx",
    password: "xxxxxxx",
    username: "xxxxxxx"
  yitsushisa: {
    host: "localhost",
    name: "xxxxxxyy",
    password: "xxxxxxx",
    username: "yyyyyyy"
  production: {
    host: "",
    name: "zzzzzzzz",
    password: "xzzzxzxxxz",
    username: "zzxyxxzxyz"

module.exports = (function() {
  return {
    wsdl: {
      priceList: "https://xxxx:xxxx@xxxxxx/ws/pricelist.asmx?WSDL"
    xhr: {
      priceList: "https://xxxxxx:443/ws/pricelist.asmx",
      resources: "https://xxxxxx:443/ws/resources.asmx",
      order:     "https://xxxxxx:443/ws/Order.asmx"
    auth: {
      username: "xxxxxx",
      password: "xxxxxx"
    sql: {
      prefix: "abhu-",
      database: connections[process.env.DB],
      margin: 1.06
// EOF
So I created a simple method to solve it. Now when I call this configuration file then I can point to properties directly.
var configuration = require('../etc/mymodule.js');
The only thing I need to call the main application like this:
DB="production" node app.js parameters
If you have got a better but simple solution, please tell it :)

Sunday, January 13, 2013

Ingress Problem

Image from
(+DeCode Ingress)

Dear +Ingress and +Niantic Project,

I am an agent. I like this game and try to figure out how can this game more fun. My (and a lot of agents too) problem is the resonator strength.

If we unite and build a portal 2 agent and me and our portal will be L4 then a L1 agent can destroy it in a minute. When I got the mail about the attack, our portal is destroyed. L4 vs L1 is not problem, but the 3 vs 1 is a problem. Please upgrade your equations with this factor.

For instance, each resonator in a portal would get an extra multiplier about the agents number. If a portal has 8 resonators with 3 agents then each resonator get a 1.3 multiplier to their health. This would enhance the teamwork. Teamwork is the most epic line in the game but now teamwork is needed only for capturing. If 10 agents build a lot of portals then 1 agent can destroy all of them. I know you need to calculate about new agents but it is not fair.

P.level() = Level of Portal (P.level():3 = Portal L3)
P.agents() = Agents on the portal (P.agents():3 = 3 agents work on this portal)
Rx.level() = Level of Resonator #x (R1.level():6 = Resonator #1 L6)
Rx.portal() = Portal of the Resonator #x
Rx.damage(distance, xmp) = Damage on Resonator #x with an XMP (R1.damage(20, 1):230 = Resonator #1 got 230 unit as damage from 20 meters with a L2 XMP)

Rx.damage(distance, xmp):
  return super.damage(distance, xmp) / (1 + (self.portal().agents()/10))

Or something else. But please give us some respect if we unite. Please make a difference between 1x8xL1 and 2x4xL1 resonators.

Saturday, January 12, 2013

3 ways to be a Healthy Programmer

Image from Dev Bootcamp

Are you healthy? Stand up! Leave your keyboard for a moment!
Few days ago I started to read a book. My best quote from this book was a short but really intense sentence and I started to think again. Think about my past and my current life.
We aren’t born unhealthy — we become unhealthy through a combination of bad habits and environmental pressures

It's true. When I was young, innocent boy, then I tried to do something new, something interesting. I sat at my Commodore C64 and read books about programming. I loved that, but sometimes I left this desk and I went out to the garden and the park.

Now I grew up (a little bit) and I have not forgotten this. Sometimes I stand up and go to the nearest park, walk up and down, sit on a bench and sometimes I run just for fun. It's ok. I love that way but how?

Time To Rest - Pomodoro

If you can't leave your desk because you dug too deep in your code then use tools to manage your time. I tried a lot of methods but the first one that really works for me is The Pomodoro Technique®. Pomodoro users use this technique to manage their working time. I use this to manage my free time. It's cool to manage my work but I don't have problem with my focusing, but I can't leave my desk if I'm working. I set up 25 minutes to work and 5 minutes to pause and after 4 period I got extra 10 minutes. No it's not for me. I tried again with larger numbers. Oh yeah :) This is my recipe.

  1. 1 hour work
  2. 10 minutes pause
  3. 1 hour work
  4. 10 minutes pause
  5. 1 hour work
  6. 10 minutes pause
  7. 1 hour work
  8. 30 minutes pause
And so on. I do it twice a day. This is 8 hours work-time with 2 hours pause. So this is 10 hours. Why is this cool? Because my eyes are not numb and after my rest time I can focus to my work again with clean brain.

Workspace Upgrade

My first and best choice was a ball. A Fit-Ball. I love that awesome chair replacement. I sit on a big, really big ball: 75cm (~29.53 inches). It's bigger than I need to sit but I don't want to sit always. So now I can sit on the top of the ball and my legs can't reach the floor. Or I can semi-stand at my desk. In the first few days it was uncomfortable, but after it was hard to sit in one place for a long time for me.

Why is this cool? Because my back doesn't ache and my legs and my back are working all the times but lower intensity.

Don't be shy, just run

I use a simple method to run. Running is sucks, but what if you need to run away from Zombies? This is the point. I use Zombies, Run! and this awesome app is available on Google Play, the App Store and Windows Phone. What is it? It's a simple running application. You are the Runner 5 and you have a lot of missions. For instance, you need to run to save a lost child. Or need to run to warn the nearest city about an expected zombie attack. You can see how simple. But it's a good game for your health.


Sometimes need a rest, sometimes need to rethink our workspace and upgrade to be the most comfortable. Oh and don't forget to move, move your body. Run, walk, climb, cycle, dance etc.