Skip to content

Instantly share code, notes, and snippets.

@yusufhm
yusufhm / data.json
Last active April 3, 2018 04:21
Sample JSON Data
{
"field1": "value1",
"field2": "value2"
}
@yusufhm
yusufhm / humhub-composer.json
Created December 27, 2017 12:57
HumHub composer.json
{
"name": "yusufhm/humhub",
"type": "project",
"authors": [
{
"name": "Yusuf Hasan Miyan",
"email": "yusuf.hasanmiyan@gmail.com"
}
],
"minimum-stability": "dev",
@yusufhm
yusufhm / views-local.settings.php
Last active December 11, 2017 01:45
Drupal 8 Views debug
<?php
// Skip cache so we don't need to do `drush cr` every time.
$config['views.settings']['skip_cache'] = TRUE;
// When views take a long time to execute, we might want to disable live preview.
$config['views.settings']['ui']['always_live_preview'] = FALSE;
// Show the SQL query.
$config['views.settings']['ui']['show']['sql_query']['enabled'] = TRUE;
@yusufhm
yusufhm / blt-additional-synced-folder-vm.md
Created November 6, 2017 07:42
BLT - additional synced folder for VM

Create a local config file in the project's box directory, called local.config.yml.

Copy the vagrant_synced_folders segment from box/config.yml and paste into box/local.config.yml:

vagrant_synced_folders:
  # Set the local_path for the first synced folder to `.`.
  - local_path: .
    destination: /var/www/my-project
    type: nfs
@yusufhm
yusufhm / d8_import_config.php
Created February 14, 2017 04:12
drupal 8 import config programmatically
<?php
// The following snippet updates the filter format configuration.
$config_path = drupal_get_path('module', 'my_custom_module') . '/config/install'; // or any path containing config files theoretically.
$source = new FileStorage($config_path);
$config_storage = \Drupal::service('config.storage');
$config_storage->write('filter.format.basic_html', $source->read('filter.format.basic_html'));
@yusufhm
yusufhm / replace-apt-mirror.md
Last active October 18, 2023 15:03
replace default apt with au mirror using Vim or sed
@yusufhm
yusufhm / get-domain-info.md
Created September 15, 2016 02:16
Find domain information.

nslookup -type=soa domain.name

dig +short NS domain.name

@yusufhm
yusufhm / file-by-type-size.sh
Created August 23, 2016 23:30
List file by type & size
#!/bin/bash
ftypes=$(find . -type f | grep -E ".*\.[a-zA-Z0-9]*$" | sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/' | sort | uniq)
for ft in $ftypes
do
echo -n "$ft "
find . -name "*${ft}" -exec ls -l {} \; | awk '{total += $5} END {print total}'
done
@yusufhm
yusufhm / regex.php
Last active December 29, 2017 17:38
php regex
<?php
// YouTube id from url.
// @see http://stackoverflow.com/a/6382259/351590
if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match)) {
$video_id = $match[2];
}
@yusufhm
yusufhm / d8-show-config.php
Created April 11, 2016 06:30
Drupal 8 various Field & Entity (display) config
<?php
$entity_type = 'node';
$bundle = 'page';
$field_name = 'field_description';
$fsc = FieldStorageConfig::loadByName($entity_type, $field_name);
$fc = FieldConfig::loadByName($entity_type, $bundle, $field_name);
$display = entity_get_display($entity_type, $bundle, 'default');
$form_display = entity_get_form_display($entity_type, $bundle, 'default');