Tuesday, March 4, 2014

Mahara web services - simple guide

Mahara web services can be installed as a plugin. Installation is a easy process. you can find the steps in here https://wiki.mahara.org/index.php/Plugins/Auth/WebServices#Installation_Instructions

extract the zip file and put to folders inside mahara /path/to/mahara/webservice and /path/to/mahara/auth/webservice

login to mahara as admin goto menu extensions -> Plugin administration under Plugin type: auth heading install webservice

code check for https so if you do not have SSL in your site and you want to test the web services you can comment out https check part in the code (NOT recommended for a production server)

for example if you want to use REST go to the folder webservice -> rest inside server.php comment

// you must use HTTPS as token based auth is a hazzard without it
/*if (!is_https()) {
    header("HTTP/1.0 403 Forbidden - HTTPS must be used");

Now you can test web services using the built in Web service test client
click Configuration link near webservice plugin. Enable WebServices master switch. under Manage Service Access Tokens add a user and generate a token. Now click Web service test client tab and select
protocol - REST
Authentication Type - Token
Service - choose the service you selected when generating token.
Select a function and enter token.

You can also use curl from another site to access the webservice like this

$service_url = 'http://yoursite.com/mahara/webservice/rest/server.php';
$token = 'your token';

$curl = curl_init($service_url);

$curl_post_data = array(       

 'wsfunction' => 'mahara_user_get_users', // the function to be called
      'wstoken' => $token //token need to be passed in the url

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
$curl_response = curl_exec($curl);

$info = curl_getinfo($curl);

if ($curl_response === false) {
    $info = curl_getinfo($curl);
    die('error occured during curl exec. Additioanl info: '.var_export($info));

header("Content-type: text/xml");

echo $curl_response;


Sunday, March 2, 2014

Mahara - Sorry, your registration attempt was unsuccessful. This is our fault, not yours. Please try again later.

Fix is to setup email setting in site options. I installed Mahara on a shared hosting. I'm not sure how to setup email setting required for localhost other than giving working SMTP details. Administration -> Site options -> Email settings

Thursday, February 13, 2014

div losing background color/image when resizing the browser window

When you have div width 100% it apply to browser viewpoint only not the max page width. This can be a problem when you have another div with a fixed width length. The fix is to put a min-width with max possible page width.

html, body{margin:0; padding:0;border: 0;outline: 0;}

<!--The problem-->
<div style="margin:0; width:100%; background-color:#060;">
 Header 1

<div style="margin:0 auto; width:1000px; background-color:#03C;">     
 Text Line 1

<br /><br />

<div style="margin:0; width:100%; min-width:1000px; background-color:#060;">
 Header 2

<div style="margin:0 auto; width:1000px; background-color:#03C;">     
 Text Line 2


Don't forget padding widths when calculating min width.

Wednesday, February 12, 2014

Cannot login to Games for Windows LIVE

Login issue for me was caused by two-step verification. you can either disable it temporally till you finish game or you can use a App password that you can find in your Live account under "Security info".

GFWL can be very annoying at times. I had problems with it every time it was required to play a specific game. Wish they at least give a detailed error message without wasting my time for hours looking for fixes.

Thursday, February 6, 2014

HD 7750 cypto coin mining experience

HD 7750 is a entry level card for mining any kind of coin. suitable for casual mining while you do other stuff in the pc. I mine Feathercoin (FTC) as it has a very low difficulty but I think Litecoin will give the same return when converted to Bitcoins. I get around 2.5FTC per day with wemineftc.com pool.

My HD 7750 punch 134 khash/s on Intensity level of 13 in GUIminer-scrypt
GPU clock increased to 825MHz (core speed 800)
Memory clock speed decreased to 700Mhz to reduce temperature. you can change card settings using amd catalyst control center.

It can easily go over 150 Khash/s with more GPU overclocking and increasing the intensity level. I haven't tried to push the card that far since increase core speed make temperature go over the roof.

How to get all results without the first row from a MySQL table

To exclude first row you have to use MySQL limit clause.

select * from table limit 1, 10000000

You can pass 2 values to limit clause first one is the starting row. Row index start with 0 so you have to put 1 to remove first row. Second parameter is the number of result u need to retrieve. Put a number that is larger than max rows of table.

Sunday, September 15, 2013

Disable other_vhosts_access.log in ubuntu

Check the following location for apache2.conf and other-vhost-access-log

Open those files and check for the line with other_vhosts_access.log and comment them out with # sign in front of the line.

Restart Apache.

Monday, April 1, 2013

Fixing MP4 not playing until full video loads in browser

I had a problem where my mp4 videos were not played by video.js player until the video was fully downloaded by the browser. after some searching I found out it was because mp4 file metadata ( moov atom) is on the end of the file and the player cannot locate it for streaming when initially played.

I was saved by this small php library http://code.google.com/p/moovrelocator/
This will read a video and move MOOV-Atom to the front of the mp4 file.

there is a demo in _demo folder. if you get errors finding the paths, try giving direct paths like this in index.php

$inFile = '../../videos/'.$tempv;
// output (processed file)
$outFile = '../../new_videos/'.$tempv;

if you get zend errors try giving direct paths in Moovrelocator.class.php

// atom poc class
require_once 'atom/Atom.class.php';

// bytearray to operate direct on bytes in memory just to simulate Adobe's AS3 Bytearray
require_once 'bytes/Bytearray.class.php';

// transform (taken from php-reader)
require_once 'bytes/Transform.class.php';

you may also want to change your php.ini max execute time and memory use if you are looping through lot of videos in a folder.