Skip to content

Instantly share code, notes, and snippets.

View richlloydmiles's full-sized avatar

Richard richlloydmiles

View GitHub Profile
// nand (not and): if both values are 1 return 0, otherwise return 1
const nand = (a, b) => (a === 1 && b === 1 ? 0 : 1)
// using only the nand function (or multiple nand functions), write a new composite "and" function
// "and" function returns 1 if both are both 1 return 1, otherwise return 0
const and = (a, b) => {
// write your function here
}
const names = ['George', 'Ringo', 'John', 'Paul']
const getEmailAddress = (name) => new Promise(resolve => setTimeout(resolve(name + '@beetle-mail.com'), 100));
// write a function that prints out all the names with email addresses as an array using the getEmailAddress function
// output should be: ['[email protected]', '[email protected]', '[email protected]', '[email protected]']
const people = {
adrian: {
age: 21,
department: 'design'
},
emma: {
age: 15,
department: 'development'
},
rachael: {
const nand = (a, b) => (a === 1 && b === 1 ? 0 : 1)
// NAND - A and B are both 1 return 0
// const A = 1
// const B = 0
// console.log(nand(A, B))
// NOT - return not A (OR B)
// const A = 1
const not = (x) => nand(x, x)
// console.log(not(A))
@richlloydmiles
richlloydmiles / links
Created June 26, 2019 16:53
useful-links
@richlloydmiles
richlloydmiles / city.schema
Last active June 1, 2019 19:57
example graphQL schema
type City {
id: ID!,
name: String!,
country: String!,
}
type Query {
fetchCity(id: ID!): City
}
@richlloydmiles
richlloydmiles / readme.md
Last active April 25, 2019 07:13
mysql udemy
<?php
class Person {
protected $name, $email, $id;
public function setName($name) {
$this->name = $name;
}
public function getName() {
<?php
use PHPUnit\Framework\TestCase;
require('./Person.php');
class PersonTest extends TestCase {
public function testPersonClassConstructorIsCalledAsExpected() {
$mock = $this->getMockBuilder('Person')->disableOriginalConstructor()->getMock();
$mock->expects($this->once())->method('setName')->with($this->equalTo('richard'));
<?php
class Person {
protected $name, $email, $id;
public function setName($name) {
$this->name = $name;
}
public function getName() {
return $this->name;