Skip to content

Instantly share code, notes, and snippets.

<?php
namespace Api\Factory;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Api\Controller\DbResolver;
use Zend\Authentication\Adapter\DbTable as AuthAdapter;
class AuthAdapterFactory implements FactoryInterface
@mathewka
mathewka / IndexController.php
Created April 15, 2014 05:20
Magento Rest api call from controller with using Oauth
<?php
class Namespace_modulename_IndexController extends Mage_Core_Controller_Front_Action{
public function indexAction() {
//Basic parameters that need to be provided for oAuth authentication
//on Magento
$params = array(
'siteUrl' => 'http://localhost/magento/oauth',
'requestTokenUrl' => 'http://localhost/magento/oauth/initiate',
'accessTokenUrl' => 'http://localhost/magento/oauth/token',
'authorizeUrl' => 'http://localhost/magento/admin/oAuth_authorize',//This URL is used only if we authenticate as Admin user type
@mathewka
mathewka / TestFile.php
Created April 15, 2014 05:26
Zend Jon Table , ZF2 Join table example.
<?php
namespace '''''';
use Zend\Db\TableGateway\AbstractTableGateway;
use Zend\Db\Sql\Select;
class TestFile extends AbstractTableGateway
{
public function __construct($adapter)
@mathewka
mathewka / crossdoamin.php
Created April 15, 2014 05:40
Allow cross domain access
$method = $_SERVER['REQUEST_METHOD'];
if (isset($_SERVER['HTTP_ORIGIN'])) {
drupal_add_http_header('Access-Control-Allow-Origin', $_SERVER['HTTP_ORIGIN']);
}
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
drupal_add_http_header('Access-Control-Allow-Headers', $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
}
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) {
@mathewka
mathewka / install phpunit
Created April 15, 2014 05:41
Install PHPUNIT
First off I'm assuming xampp is installed to C:\xampp
1. Open a command prompt and go to C:\xampp\php
2. Type "pear update-channels" (updates channel definitions)
3. Type "pear upgrade" (upgrades all existing packages and pear)
4. Type "pear channel-discover components.ez.no" (this is needed for PHPUnit)
5. Type "pear channel-discover pear.symfony-project.com" (also needed by PHPUnit)
6. Type "pear channel-discover pear.phpunit.de" (This IS phpunit)
7. Type "pear install --alldeps phpunit/PHPUnit" (installs PHPUnit and all dependencies)
@mathewka
mathewka / craete android phone gap app
Created April 15, 2014 05:42
Create android phone gap apps using command prompt.
1. Install ABT Bundle
2. Download android latest files(android versions) using SDK Manager.
3. Download JDK and set environment variable
4. Download Apache ant and set environment variable
5. Download Phone gap
Create android phone gap apps using command prompt.
@mathewka
mathewka / demo of change dynamic drop down.txt
Created April 15, 2014 05:49
Drupal , demo of change dynamic drop down
<?php
/**
* Implementation of hook_menu().
* Registers a form-based page that you can access at "http://localhost/mypage"
*/
function mymodule_menu(){
return array(
'mypage' => array(
'title' => 'A page to test ajax',
@mathewka
mathewka / googleapi.js
Created April 15, 2014 05:52
Google map Get direction api 8 way point limit
calcRoute : function (batches, directionsService, directionsDisplay) {
var combinedResults;
var unsortedResults = [{}]; // to hold the counter and the results themselves as they come back, to later sort
var directionsResultsReturned = 0;
for (var k = 0; k < batches.length; k++) {
var lastIndex = batches[k].length - 1;
var start = batches[k][0].location;
var end = batches[k][lastIndex].location;
@mathewka
mathewka / getdirections_v3a.js
Created April 15, 2014 05:55
Drupal get directionis module google version3 api with new changes in 8 waypoint limit
/**
* @file
* Javascript functions for getdirections module
*
* @author Bob Hutchinson http://drupal.org/user/52366
* code derived from gmap_direx module
* this is for googlemaps API version 3
* with adaptations from econym.org.uk
*/
@mathewka
mathewka / Installation of PHPUnit
Created April 15, 2014 05:58
Installation of PHPUnit
Installation of PHPUnit.
Open a command prompt and go to C:\xampp\php
Type "php go-pear.phar" (Installs new PEAR)
Type "pear update-channels" (updates channel definitions)
Type "pear upgrade --alldeps" (upgrades all existing packages and pear)
Type "pear channel-discover components.ez.no" (this is needed for PHPUnit)