This file contains hidden or 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, { Component } from "react"; | |
import { render } from "react-dom"; | |
const styles = { | |
fontFamily: "sans-serif", | |
textAlign: "center" | |
}; | |
class ChildComponent extends Component { | |
state = { |
This file contains hidden or 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 Ping { | |
private $host; | |
private $ttl; | |
private $timeout; | |
public $commandOut; | |
private $localhost = false; | |
public function __construct($host, $ttl = 255, $timeout = 10) { |
This file contains hidden or 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 | |
/* ----- Profiling.php ----- */ | |
class Profiling { | |
public $messages = []; | |
protected $profile; | |
protected $current_time; | |
public function __construct($profile) { |
This file contains hidden or 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 Event { | |
private static $events = []; | |
public static function listen($name, $callback) { | |
self::$events[$name][] = $callback; | |
} | |
public static function trigger($name, $argument = null) { | |
foreach (self::$events[$name] as $event => $callback) { |
This file contains hidden or 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
var obj = { | |
module: 'ceo', | |
children: [ | |
{ | |
module: 'VP of Happiness', | |
children: [{ module: 'Manager of P' },{ module: 'Manager of III' }] | |
}, | |
{ | |
module: 'VP of Finance', |
This file contains hidden or 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 startTime = new Date(); | |
// delete an object in a array/collection | |
const collection = [ | |
{id:3, name:"Item #1",age:32}, | |
{id:4, name:"Item #2",age:33}, | |
{id:5, name:"Item #3",age:34}, | |
{id:6, name:"Item #4",age:35}, | |
{id:7, name:"Item #5",age:36}, | |
{id:8, name:"Item #6",age:47}, | |
]; |
This file contains hidden or 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 startTime = new Date(); | |
// updating an object in a array/collection | |
let collection = [ | |
{id:3, name:"Item #1",age:32}, | |
{id:4, name:"Item #2",age:33}, | |
{id:5, name:"Item #3",age:34}, | |
{id:6, name:"Item #4",age:35}, | |
{id:7, name:"Item #5",age:36}, | |
{id:8, name:"Item #6",age:47}, | |
]; |
This file contains hidden or 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 isDefined(val) { | |
return typeof val !== 'undefined'; | |
} | |
function isUndefined(val) { | |
return typeof val === 'undefined'; | |
} | |
function isNull(val) { | |
return val === null && typeof val === 'object'; |
This file contains hidden or 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 formatToRegex(string $format): string { | |
$result = preg_quote($format, '/'); | |
$result = str_replace('%d', '\d+', $result); | |
$result = str_replace('%s', '[^\r\n]+', $result); | |
return "/^$result$/s"; | |
} | |
$output = "Mr. Jones"; |
This file contains hidden or 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 | |
// Array Diff | |
class DiffElem | |
{ | |
const TYPE_KEEP = 0; | |
const TYPE_REMOVE = 1; | |
const TYPE_ADD = 2; |