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
componentDidCatch (error, errorInfo) { | |
// Log only errors in component tree, which can break the rendering. | |
// @see https://reactjs.org/docs/error-boundaries.html | |
if (this.props.logError) { | |
this.props.logError(error, errorInfo) | |
} | |
} | |
componentDidMount () { | |
// Development mode - catches any error. |
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
constructor(private router: Router, | |
private actRoute: ActivatedRoute) { } | |
... | |
this.router.events.filter(event => event instanceof NavigationEnd).subscribe((event) => { | |
const getActiveRoutePath = (routeSnapshot: ActivatedRouteSnapshot) => { | |
if (routeSnapshot.routeConfig) { | |
// Check top level route. | |
return routeSnapshot.routeConfig.path; | |
} else { |
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 {Component, Directive, ElementRef, QueryList, ViewChildren} from "@angular/core"; | |
// DON'T FORGET TO DECLARE A DIRECTIVE IN YOUR MODULE. | |
// Selector by class | |
@Directive({selector: '.live-screen__user-microphone'}) | |
export class microphoneIconSelector { | |
// Define a property to make it available in object, returned by directive. | |
nativeElement: any; | |
constructor(private element: ElementRef) { | |
this.nativeElement = element.nativeElement; |
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 | |
/** | |
* Drupal 7. | |
*/ | |
$user_obj = user_load(1); | |
$form_state = array(); | |
$form_state['uid'] = $user_obj->uid; | |
user_login_submit(array(), $form_state); |
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
/** | |
* Check if current request is AJAX. | |
*/ | |
function MODULE_NAME_is_ajax() { | |
$http_request = isset($_SERVER['HTTP_X_REQUESTED_WITH']) | |
&& strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; | |
// Check ajax in IE. | |
$request_uri = isset($_SERVER['REQUEST_URI']) | |
&& strtolower($_SERVER['REQUEST_URI']) == '/system/ajax'; |
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
/** | |
* Check url for external property. | |
*/ | |
function module_url_is_external($path) { | |
global $base_url; | |
$url_host = parse_url($path); | |
if (empty($url_host['host']) && empty($url_host['scheme'])) { | |
return FALSE; | |
} else { | |
if ($url_host['scheme'] . '://' . $url_host['host'] === substr($base_url, 0, strlen($url_host['scheme'] . '://' . $url_host['host']))) { |