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, { useState } from 'react'; | |
import useOnlineStatus from './useOnlineStatus'; | |
const Example = () => { | |
const [onlineStatus, setOnlineStatus] = useState(navigator.onLine); | |
useOnlineStatus((isOnline) => { | |
setOnlineStatus(isOnline); | |
}); |
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 Handlebars = require('handlebars'); | |
var source = `{{{{raw}}}} | |
{{#if ready}} | |
<p>Ready</p> | |
{{/if}} | |
<p>Something else!</p> | |
{{{{/raw}}}}`; | |
Handlebars.registerHelper('raw', function(content) { |
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
{ | |
"01d": { | |
"label": "Clear sky", | |
"icon": "wi-day-sunny" | |
}, | |
"01n": { | |
"label": "Clear sky", | |
"icon": "wi-night-clear" | |
}, | |
"02d": { |
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 hook_watchdog(array $log_entry) { | |
$severity_list = array( | |
WATCHDOG_EMERGENCY => t('Emergency'), | |
WATCHDOG_ALERT => t('Alert'), | |
WATCHDOG_CRITICAL => t('Critical'), | |
WATCHDOG_ERROR => t('Error'), | |
WATCHDOG_WARNING => t('Warning'), | |
WATCHDOG_NOTICE => t('Notice'), | |
WATCHDOG_INFO => t('Info'), |
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 | |
$entity_type = ''; | |
$old_bundle = ''; | |
$new_bundle = ''; | |
$fields = array( | |
'field_name', | |
); | |
foreach ($fields as $field) { |
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
include_once DRUPAL_ROOT . '/includes/utility.inc'; | |
$nodetype = ''; | |
$instances = field_info_instances('node', $nodetype); | |
$fields = array(); | |
foreach ($instances as $instance) { | |
unset($instances[$instance['field_name']]['id'], $instances[$instance['field_name']]['field_id']); |
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
@mixin breakpoint($point) { | |
@if $point == desktop { | |
// Larger than tablets. | |
@media (min-width: 1210px) { @content; } | |
} | |
@else if $point == tablet { | |
// Tablets, go from 4 to 2 and 2 to 1. | |
@media (max-width: 1209px) { @content; } | |
} | |
@else if $point == mobile { |
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
/** | |
* param string $module | |
* Name of the module. | |
* | |
* return int | |
* 1 or 0 | |
*/ | |
function is_module_enabled($module) { | |
$result = db_query('SELECT s.status FROM system s WHERE s.name = :name AND s.type = :type', array(':name' => $module, ':type' => 'module')); | |
$record = $result->fetchObject(); |
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
/** | |
* Implements hook_form_alter(). | |
*/ | |
function fortytwo_form_alter(&$form, &$form_state, $form_id) { | |
switch ($form_id) { | |
case 'block_admin_display_form': | |
$form['#attached']['js'] = array( | |
drupal_get_path('theme', 'fortytwo') . '/js/mousetrap.js' => array( | |
'scope' => 'footer', | |
), |
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
$field_name = ''; | |
$entity_name = ''; | |
$entity = entity_get_info($entity_name); | |
foreach ($entity['bundles'] as $key => $value) { | |
$field_instance = field_info_instances($entity_name, $key); | |
$instance = $field_instance[$field_name]; | |
field_delete_instance($instance); | |
} |
NewerOlder