Using Spotify on your OUYA in landscape

Soooo… You just got your new OUYA, but you’re missing music?

You can use this tutorial to understand how to sideload apps:

http://www.xbmchub.com/blog/2013/06/02/how-to-install-xbmc-to-the-ouya-gaming-console/

  1. In step 6 use http://jeroen.pro/spotify.php
  2. In step 15, use “com.spotify.mobile.android.ui-*-v*.apk”.In which the asterix is the version numbering.
  3. Stop at step 23, and just launch Spotify.

Notice: I made this special download because the version on m.spotify.com is outdated, and looks horrible on your OUYA.

Here are some previews of Spotify running on my OUYA:

Playlist

Playlist

Playing

Playing

Home with sidebar

Home with sidebar

Have fun!

Update: The login screen is in portrait mode, once you are logged in, you will have landscape.

Posted in Uncategorized | 2 Comments

Totals with Munin

If you are addicted to graphs, like me, you will like this one. You will be able to generate the following graph:

It combines the bandwidth statistics of the given servers, and creates a awesome graph for it.

Put the following code below your host-tree:

 Text | 
 
 copy code |
?

1
bandwidth.graph_title Total Bandwidth of all servers in MB/s
2
  bandwidth.totalup.sum [server1]:if_eth0.up [server2]:if_eth0.up [server3]:if_eth0.up [server4]:if_eth0.up
3
  bandwidth.totalup.label Total up bandwidth usage of all servers
4
  bandwidth.totaldown.sum [server1]:if_eth0.down [server2]:if_eth0.down [server3]:if_eth0.down [server4]:if_eth0.down
5
  bandwidth.totaldown.label Total down bandwidth usage of all servers

Replace [server1] – [server4] with your server names, use the server names that you used in your host tree.

Basically it generate 2 lines, upload and download, and uses the “sum” function to get the total of all servers combined,

Posted in Uncategorized | 1 Comment

jQuery Mobile – Google Ads and Google Ads Mobile combined

Some time ago I had to combine Google Ads and Google Ads Mobile on my page, Google Ads for the tablets, Mobile for the mobile devices.

First I added the following HTML/JavaScript before the body tag:

 HTML | 
 
 copy code |
?

01
<div id="adsense_mobile_top" style="display:none;">
02
    <script type="text/javascript"><!--
03
      window.googleAfmcRequest = {
04
        client: 'xxx',
05
        format: 'xxx',
06
        output: 'html',
07
        slotname: 'xxx',
08
      };
09
    //--></script>
10
    <script type="text/javascript"    src="http://pagead2.googlesyndication.com/pagead/show_afmc_ads.js"></script>
11
</div>
12
<div id="adsense_top" style="display:none;">
13
    <script type="text/javascript"><!--
14
        google_ad_client = "xxx";/
15
        google_ad_slot = "xxx";
16
        google_ad_width = xxx;
17
        google_ad_height = xxx;
18
        //-->
19
    </script>
20
    <script type="text/javascript"
21
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
22
    </script>
23
</div>

Make sure you fill in your own Adsense data.

Then I added the following HTML code to the place where I wanted the ad to be:

 HTML | 
 
 copy code |
?

1
<div id="google_ads_top">
2
            <div align="center">
3
            </div>
4
</div>

Then I added the following javascript before the body tag:

 Javascript | 
 
 copy code |
?

01
<script type="text/javascript">
02
function loadAd(){
03
    var mobile = (/iphone|ipad|ipod|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));    
04
    var ads_top = $("#adsense_top").find("iframe");    
05
    if (mobile || ((/android/i.test(navigator.userAgent.toLowerCase())) && (/mobile/i.test(navigator.userAgent.toLowerCase())))) {  
06
        ads_top = $("#adsense_mobile_top").find("iframe");
07
    }
08
    else
09
    {
10
        ads_top.css('position', 'static');
11
    }
12
 
13
    $(ads_top).appendTo("#google_ads_top div");
14
    $("#adsense_top").remove();
15
    $('div').live('pagehide',function(event, ui){
16
        $(ads_top).appendTo("#google_ads_top div");
17
    });
18
}
19
$('div[data-role=page]').live('pageshow', loadAd);
20
</script>

And there you have it, a website that gets a new ad on every pageview, and selects the ad on the kind of device you have.

There are multiple ways to base ads on the kind of device, but I needed a JavaScript solution because I just heavy cache on the pages. PHP selecting won’t work.

Posted in Uncategorized | Leave a comment

Adding advertisements in iUI

Ever tried adding advertisements to a iUI page?

I tried for a couple of hours until I was tired of “thinking the JS way” and went for the easy(and ugly) solution called iframes. I added the following code and it worked perfectly:

 HTML | 
 
 copy code |
?

1
<iframe scrolling="auto" frameborder="0" style="width:100%; min-height: 300px;" src="/ad.html" sandbox="allow-same-origin allow-forms allow-scripts" allowtransparency="true">

In the ad.html you add the advertisement javascript.

iUI fails with advertisements because it doesn’t support document.write, and all ad platforms I know use it. document.write will only work on the homepage, dynamically loaded pages will fail with document.write and will become a white page with only the ad.

Posted in Uncategorized | Leave a comment

Picking a random server with PHP(with server online checking)

Some time ago I was facing a challenge, making a PHP script that randomly picks a server from a server list, to create a load balancing effect. The script expects that the servers are replicated, so that only the server name need to be provided. Resulting resources would be like:

http://alpha.jeroen.pro/static/background.jpg
http://beta.jeroen.pro/static/background.jpg

Continue reading

Posted in Uncategorized | 1 Comment

OpenVPN stats/status page using PHP

Yesterday I was facing a problem that I don’t face many times: Something isn’t widely documented on the internet.

In this case it was about OpenVPN, the status of the server, per client, more specifically. After doing some searching on the internet I figured that OpenVPN isn’t used much, or that only pro’s use it and they write their own code anyway.

The only thing I found was a very basic(and non-working) PHP page from 2005, and a simple PHP script(also from 2005) that parses the logfile and shows the current status. I decided to base my script on that.

Continue reading

Posted in Uncategorized | Leave a comment