This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Promise<XMLHttpRequest>((resolve, reject) => { | |
xhr.onreadystatechange = ()=> resolve(xhr); | |
}) | |
.then(result => { | |
(result.status == 200) ? statusMessage(messageSuccess) : statusMessage(messageError); | |
}) | |
.catch(error => console.log('ERROR:', error.message)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(() => { | |
$(".onlyNumbers").keypress(function (e) { | |
if (e.which !== 8 && e.which !== 0 && (e.which < 48 || e.which > 57)) { | |
return false; | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
must return TRUE: | |
('arc', 'car') | |
('listen', 'silent') | |
('malarm', 'malmar') | |
('peer', 'eper') | |
must return FALSE: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AstronautController{ | |
private string $name; | |
private float $pounds; | |
function __construct(string $name, float $pounds){ | |
$this->setName($name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"repositories": [ | |
{ | |
"type": "git", | |
"url": "https://github.com/pressbooks/new-private-project" | |
} | |
], | |
"require": { | |
"pressbooks/new-private-project": "dev-bugfixes" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- COUNT APPLICATIONS BY USER | |
SELECT ca.id_user, u.name, | |
COUNT(ca.id_user) as num_applications | |
FROM course_application ca, user u | |
WHERE ca.id_user = u.id | |
GROUP BY ca.id_user, u.name; | |
-- COUNT COURSES BY USER OF ID 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- INSERT DATA | |
INSERT INTO `course` (`id`, `title`) | |
VALUES | |
(1,'Cooking for Fun'), | |
(2,'Arduin and Automation'), | |
(3,'Education for Life'), | |
(4,'Modern PHP Definitive Guide'); | |
INSERT INTO `course_application` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- CREATE STRUCTURE | |
DROP TABLE IF EXISTS `course`; | |
CREATE TABLE `course` ( | |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | |
`title` varchar(255) NOT NULL DEFAULT '', | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function sortWords(String $string){ | |
$words = explode(' ', $string); | |
$numWords = count($words); | |
$englishWords = []; | |
$chineseWords = []; | |
for($i=0; $i<$numWords; $i++){ | |
if(ctype_alnum($words[$i])){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class SiteImages{ | |
public string $path = ''; | |
public string $template = ''; | |
public function __construct(string $path, string $template){ | |
$this->setPath($path); | |
$this->setTemplate($template); |