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 | |
$foo = isset($array['foo']) ? $array['foo'] : null; | |
$bar = isset($array['bar']) ? $array['bar'] : null; | |
# With php notices | |
$foo = $array['foo'] ? : null; | |
$bar = $array['bar'] ? : null; | |
# DefaultingArrayObject |
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 ($) { | |
Drupal.behaviors.moduleName = { | |
attach: function(context, settings) { | |
console.log(settings.module_name.foo); // bar | |
} | |
}; | |
})(jQuery); |
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 bar_form($form, &$state) { | |
$form['bar'] = array( | |
'#type' => 'textfield', | |
'#title' => t('Bar'), | |
'#autocomplete_path' => 'taxonomy/autocomplete/field_bar_term', // Field name here. | |
'#element_validate' => array('foo_taxonomy_autocomplete_validate'), | |
); | |
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
#!/bin/bash | |
echo "Select on option:" | |
echo "1) Set up new PoPToP server AND create one user" | |
echo "2) Create additional users" | |
read x | |
if test $x -eq 1; then | |
echo "Enter username that you want to create (eg. client1 or john):" | |
read u | |
echo "Specify password that you want the server to use:" | |
read p |
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($) { | |
Drupal.behaviors.Foo = { | |
attach:function (context, settings) { | |
// unbind() because click events firing multiple times. | |
$('#foo a.update', context).unbind().click(function (event) { | |
// Get parrent of item. | |
var item = $(this).closest(".item"); | |
// Get some data of item. |
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 | |
$html_dom = filter_dom_load($body); | |
$links = $html_dom->getElementsByTagName('a'); | |
foreach ($links as $link) { | |
$url = $link->getAttribute('href'); | |
// Do something. | |
$link->setAttribute('href', $url); | |
$link->setAttribute('rel', 'nofollow'); | |
} | |
return filter_dom_serialize($html_dom); |
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 | |
\Drupal::config('module_name.settings')->set('variable', 'hello'); | |
$variable = \Drupal::config('module_name.settings')->get('variable'); |
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 | |
/** | |
* Implements hook_search_api_solr_query_alter(). | |
*/ | |
function custom_api_search_api_solr_query_alter(array &$call_args, SearchApiQueryInterface &$query) { | |
$call_args['params']['fl'] = 'is_votes-sightsrank,' . $call_args['params']['fl'] ; | |
$call_args['params']['bf'] = "recip(rord(is_votes-sightsrank),1, 1000, 1000)"; | |
} |
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 | |
/** | |
* Implements hook_entity_property_info_alter(). | |
*/ | |
function example_search_api_property_entity_property_info_alter(&$info) { | |
$info['node']['properties']['created_week_day'] = array( | |
'type' => 'text', | |
'label' => t('Week day of node creation'), | |
'sanitized' => TRUE, | |
'getter callback' => 'example_search_api_property_weekday_getter_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
(1..100).select {|x| (1..x).select{|y|x%y==0}.size==2 } | |
=> [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] |