Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / drupal-module-xmlsitemap-custom.php
Last active January 30, 2018 09:56
Add links programmatically to xmlsitemap
<?php
/**
* Implements hook_cron().
*/
function MYMODULE_cron() {
MYMODULE_xmlsitemap_links();
}
/**
@yusufhm
yusufhm / data.json
Last active April 3, 2018 04:21
Sample JSON Data
{
"field1": "value1",
"field2": "value2"
}
@yusufhm
yusufhm / visually-hidden.css
Created April 12, 2018 05:30
CSS Visually Hidden
#logo a {
position: absolute !important;
height: 1px;
width: 1px;
overflow: hidden;
clip: rect(1px, 1px, 1px, 1px);
}
@yusufhm
yusufhm / lambda-last-commit.py
Created August 30, 2018 02:03
Get the last commit of a Lambda function in Python
#!/usr/bin/env python
import sys
import boto3
import os
def get_lambda_last_commit(arn):
"""Get the commit hash of the last lambda push.
Keyword arguments:
@yusufhm
yusufhm / wordpress-url-update.sql
Created January 17, 2019 03:11
wordpress update site for localhost
UPDATE ixs_options
SET option_value = 'http://localhost:8080'
WHERE option_name = 'home';
UPDATE ixs_options
SET option_value = 'http://localhost:8080'
WHERE option_name = 'siteurl';
UPDATE ixs_posts
SET post_content = REPLACE(post_content,'http://old.url','http://localhost:8080');
@yusufhm
yusufhm / git.sh
Last active February 18, 2019 00:58
git commands
# ignore local changes to the .gitconfig file
git update-index --skip-worktree .gitconfig
# list skipped files
git ls-files -v | grep ^S
# revert the above
git update-index --no-skip-worktree .gitconfig