Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Checks for a partial match in the geocode response
*
* @return boolean
*/
public function isPartialResponse() {
if (isset($this->geocodeResponse['results'][0]['partial_match']) && $this->geocodeResponse['results'][0]['partial_match'] == 'true')
return true;
<?php
/**
* Existence of Composition class requires that an external object of
* class B is passed in on construction
*
* UML Explanation - The object at this role contains the object at the opposite role.
*
* Alternatively stated, an object of class Composition cannot be created without
* an object of class B (in this case through dependency injection)
<?php
<?php
abstract class OnTheBookShelf
{
abstract function getBookInfo($previousBook);
abstract function getBookCount();
abstract function setBookCount($new_count);
abstract function addBook($oneBook);
<?php
class MovieTheater {
private $objectBoxOffice;
private $objectMovie;
public function __construct(BoxOffice $boxOffice)
{
// using composition
$this->objectBoxOffice = $boxOffice;
@puiutucutu
puiutucutu / curl.php
Created October 1, 2015 15:36 — forked from f0t0n/curl.php
Using php curl with CURLOPT_USERAGENT option
<?php
$username='h2odev';
$password='likewater';
$location='http://h2odev.law.harvard.edu/playlists/151';
$baseUrl = 'http://h2odev.law.harvard.edu/';
$currDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$userAgent = require($currDir . 'cuseragent.php');
$ch = curl_init ();
@puiutucutu
puiutucutu / add-option-to-dropdown.js
Created October 6, 2015 18:27 — forked from paulund/add-option-to-dropdown.js
Add and Remove Options in Select using jQuery
$("#selectBox").append('<option value="option6">option6</option>');
@puiutucutu
puiutucutu / jQuery-snippets.js
Last active October 8, 2015 12:58
jQuery Ajax
var requestAJAX = jQuery.ajax({
method: 'POST',
url: 'data-export.php',
dataType: 'html',
data: { nameOfArrayPassedToServer : arrayNameInJS }
});
requestAJAX.done(function(response) {
console.log(response);
jQuery('body').on('click', '.close', function() {
// get parent id
var parent = $(this).parent();
var parentId = parent[0].id;
// hide error
toggleBootstrapHidden('#' + parentId, 'hide');
});
@puiutucutu
puiutucutu / jquery iife.js
Created October 13, 2015 20:02
jquery iife
(function ($) {
'use strict';
var dismiss = '[data-dismiss="alert"]'
var Alert = function (el) {
$(el).on('click', dismiss, this.close)
var $parent = $(this).closest('.alert')