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
function convertJsonToObjAttributes($json){ | |
$keys = array_keys((array)$json); | |
$jsonSize = count($json); | |
for( $i=0; $i<$jsonSize; $i++ ) | |
$this->{$keys[$i]} = $json[$keys[$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
let scroller=(callback, interval)=>{ | |
//Inits the var | |
let scrollStop; | |
//Adds the event listener | |
window.addEventListener('scroll', function () { | |
clearTimeout(scrollStop); | |
scrollStop = setTimeout(function () { | |
//Execute the callback passed as reference |
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
const states = this.state.proposalOptions; | |
let gathered = {}; | |
Object.keys(states).map((key)=>{ | |
gathered[key] = this.state.proposalOptions[key]; | |
} | |
); |
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
function getBase64Image(img) { | |
var canvas = document.createElement("canvas"); | |
canvas.width = img.width; | |
canvas.height = img.height; | |
var ctx = canvas.getContext("2d"); | |
ctx.drawImage(img, 0, 0); | |
var dataURL = canvas.toDataURL("image/png"); | |
return dataURL.replace(/^data:image\/(png|jpg);base64,/, ""); | |
} |
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
import React from "react"; | |
class RadioGroup extends React.Component{ | |
constructor(props){ | |
super(props); | |
this.handleCheckboxChange = this.handleCheckboxChange.bind(this); | |
this.state = { selectedOption : this.props.checked } | |
} |
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); |
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
-- 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
-- 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
-- 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 |
OlderNewer