Skip to content

Instantly share code, notes, and snippets.

View gajus's full-sized avatar

Gajus Kuizinas gajus

View GitHub Profile
describe('Product', function () {
it('must calculate its gross price by adding the VAT', function () {
var product = Product.create('A', 10);
expect(product.grossPrice()).toEqual(12);
});
});
describe('A Cart with a several different products', function () {
var cart;
beforeEach(function () {
cart = Cart.create();
});
it('must have a #grossPriceSum() of the contained products', function () {
var product = Product.create('A', 10),
book = Book.create('B', 100);
// The hash (#) and dot (.) symbols are a convention to mark if a method
// is called on an individual object or on the prototype. ".create" is
// called on the Cart prototype. #add are called on the derived objects.
describe('Cart', function () {
var cart;
beforeEach(function () {
cart = Cart.create();
});
describe('.create', function () {
describe('Seminar', function () {
it('has a name', function () {
var seminar = SeminarFactory.create({name: 'JavaScript'});
expect(seminar.getName()).toEqual('JavaScript');
});
it('has a price', function () {
var seminar = SeminarFactory.create({price: 10});
@gajus
gajus / gist:d75de7f3fdbfd6486d6a
Created September 22, 2014 08:28
"Example Factory" a factory method used to instantiate the SUT object with canonical values, overwriting only the properties relevant to the test case.
var SeminarFactory = {
create: function (overwrite) {
var defaultData,
objectData;
defaultData = {
name: 'JavaScript basics',
price: 100
};
$GLOBALS['translation'] = [
'authentication_error' => 'You must authorise Facebook application!',
'geofence_restricted' => 'Sorry, this game is currently not available in your country.',
'terms_and_conditions' => 'Terms & Conditions',
'terms_and_conditions_url' => 'http://www.sky.com/tv/show/the-blacklist/article/facebook-game',
'privacy_policy' => 'Privacy Policy',
'privacy_policy_url' => 'http://help.sky.com/security/privacy/privacy-and-cookies-notice',
<?php
/**
* @author Gajus Kuizinas <[email protected]>
* @version 1.7.2 (2013 07 28)
* @todo Consider adding layout attribute [label][input][name][/label][comment]
*/
function input ($name, $label = null, array $input_options = null, array $row_options = []) {
if (!isset($row_options['order'])) {
$row_options['order'] = 'label-input';
}
function distanceGeoPoints ($long1, $lat1, $long2, $lat2) {
$lat = deg2rad($lat2 - $lat1);
$long = deg2rad($long2 - $long1);
$a = sin($lat/2) * sin($lat/2) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * sin($long/2) * sin($long/2);
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
$d = 6371 * $c;
return $d;
}
Type: PDOException
Message: SQLSTATE[HY000]: General error: Extraneous additional parameters
File: [project]/ay/pdo.class.php
Line: 85
Time: Mar 12, 2013 23:07
public function fetchAll ($how = null, $class_name = null, $ctor_args = null) {
if ($how === PDO::FETCH_KEY_ASSOC) {
#$result = parent::fetchAll(PDO::FETCH_ASSOC);
@gajus
gajus / gist:5147789
Created March 12, 2013 22:44
PDO::FETCH_KEY_GROUP
PDO::FETCH_ASSOC
array(2) {
[0]=>
array(3) {
["id"]=>
int(1)
["name"]=>
string(7) "English"
["code"]=>