Skip to content

Instantly share code, notes, and snippets.

@mathewka
mathewka / watermark-image.php
Created April 15, 2014 06:32
Create water mark image
<?php
/*
* PHP function to image-watermark an image
* http://salman-w.blogspot.com/2008/11/watermark-your-images-with-another.html
*
* Writes the given watermark image on the specified image
* and saves the result as another image
*/
define('WATERMARK_OVERLAY_IMAGE', 'watermark.png');
@mathewka
mathewka / website-content-reader.php
Created April 15, 2014 06:31
Data Scraping - Read data from another website.
<?php
class WebContentReader{
public $global_url;
function __construct(){
$this->global_url = array();
// Create connection
$con=mysqli_connect("localhost","root","","dbname");
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
@mathewka
mathewka / uasort.php
Created April 15, 2014 05:59
php uasort
function compare_array($no_of_incidents, $no_of_incidents) {
$incident_count_first = intval($no_of_incidents['1']);
$incident_count_next = intval($no_of_incidents['1']);
if ($incident_count_first == $incident_count_next) {
return 0;
}
return ($incident_count_first > $incident_count_next) ? -1 : 1;
}
@mathewka
mathewka / Installation of composer
Created April 15, 2014 05:58
Installation of composer
Installation of composer
refer the URL (http://getcomposer.org/doc/00-intro.md)
Installation - Windows#
Using the Installer#
This is the easiest way to get Composer set up on your machine.
@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)
@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 / 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 / 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 / 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 / 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)