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 MyName | |
{ | |
public function __toString() | |
{ | |
return 'I Am A Genius'; | |
} | |
} |
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 characterOnce(str){ | |
let frequency = {}; | |
let newWord =''; | |
for(let i=0; i<str.length; i++){ | |
let character = str.charAt(i) | |
if(frequency[character]){ | |
frequency[character]++ | |
} else { | |
frequency[character] = 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
const MyComponent = props => { | |
const innerFunction = useCallback(() => { | |
// do something! | |
}); | |
useEffect(() => { | |
innerFunction(); | |
// The effect calls innerFunction, hence it should declare it as a dependency | |
// Otherwise, if something about innerFunction changes (e.g. the data it uses), the effect would run the outdated version of innerFunction | |
}, [innerFunction]); |
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 MyComponent = props => { | |
const innerFunction = () => { | |
// do something! | |
}; | |
useEffect(() => { | |
innerFunction(); | |
// The effect calls innerFunction, hence it should declare it as a dependency | |
// Otherwise, if something about innerFunction changes (e.g. the data it uses), the effect would run the outdated version of innerFunction | |
}, [innerFunction]); |
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 MyComponent = props => { | |
const innerFunction = () => { | |
// a function in a function! | |
// this function object (stored in the 'innerFunction' constant) is constantly re-built | |
// to be precise: It's re-built when MyComponent is re-built | |
// MyComponent is re-built whenever its 'props' or 'state' changes | |
}; | |
}; |
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 User { | |
/** | |
* @var \Logger | |
*/ | |
public $logger; | |
public function __construct(Logger $logger) | |
{ |
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 User { | |
public function create(array $data){ | |
try { | |
//Save User To Database | |
} catch (Exception $exception){ | |
$this->logError($exception->getMessage()); | |
} | |
} |
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 UserRepository | |
{ | |
private $db; | |
private $config; | |
private $users; | |
public function __construct(Database $db, Config $config, User $users) | |
{ |
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
.Backdrop { | |
width: 100%; | |
height: 100%; | |
position: fixed; | |
z-index: 100; | |
left: 0; | |
top: 0; | |
background-color: rgba(0,0,0,0.5); | |
} |
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
.Modal { | |
position: fixed; | |
z-index: 500; | |
background-color: white; | |
width: 70%; | |
border: 1px solid #ccc; | |
box-shadow: 1px 1px 1px black; | |
padding: 16px; | |
left: 15%; | |
top: 30%; |