Skip to content

Instantly share code, notes, and snippets.

//
// UITests.swift
// UITests
//
// Created by Peter Lafferty on 19/08/2015.
// Copyright © 2015 Web Reservations International. All rights reserved.
//
import XCTest
//
// UISearchTests.swift
// Hostelworld
//
// Created by Peter Lafferty on 21/08/2015.
// Copyright © 2015 Web Reservations International. All rights reserved.
//
import Foundation
<?php
function test($number, $text)
{
if (!is_int($number) || is_null($number)) {
throw new Exception('invalid argument type $number');
}
if (!is_string($text) || is_null($text)) {
throw new Exception('invalid argumenti type $string');
}
<?php
function test($number, $text)
{
if (!is_int($number) || is_null($number)) {
throw new Exception('invalid argument type $number');
}
if (!is_string($text) || is_null($text)) {
throw new Exception('invalid argumenti type $string');
}
<?php
function test(int $number, string $text) : string
{
$number = test2($number);
return str_repeat($text, $number);
}
function test2(int $number) : int
{
return $number * 2;
<?php
function test($number, $text)
{
//do something
return str_repeat($text, $number);
}
@peterlafferty
peterlafferty / places.sql
Created April 20, 2017 20:34
simple schema to demonstrate a stored procedure in mysql
CREATE DATABASE IF NOT EXISTS `places` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `places`;
-- MySQL dump 10.13 Distrib 5.7.17, for macos10.12 (x86_64)
--
-- Host: localhost Database: places
-- ------------------------------------------------------
-- Server version 5.7.18
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@peterlafferty
peterlafferty / absence-schema.sql
Last active April 27, 2017 12:59
a simple schema to demonstrate stored procedures in mysql
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
ALTER SCHEMA `calendar` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci ;
CREATE TABLE IF NOT EXISTS `calendar`.`Absence` (
`idAbsence` INT(11) NOT NULL,
`date` DATE NOT NULL,
`idReason` TINYINT(4) NOT NULL,
@peterlafferty
peterlafferty / advancedsproc.sql
Created May 4, 2017 21:56
schema to demonstrate advanced stored procedures with MySQL
CREATE DATABASE IF NOT EXISTS `hotel` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `hotel`;
-- MySQL dump 10.13 Distrib 5.7.17, for macos10.12 (x86_64)
--
-- Host: localhost Database: hotel
-- ------------------------------------------------------
-- Server version 5.7.18
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
<?php
namespace pl\basicproject;
class Car {
public
function beep()
{
return true;
}