Skip to content

Instantly share code, notes, and snippets.

View DimDev's full-sized avatar

Dzmitry Kazbiarovich DimDev

  • EPAM Systems
  • Wrocław, Poland
View GitHub Profile
@DimDev
DimDev / gist:4575276
Created January 19, 2013 21:23
TO make twitter bootstrap dropdowns working on touch devices
$('body').on('touchstart.dropdown', '.dropdown-menu', function (e) { e.stopPropagation(); });
@DimDev
DimDev / gist:6102632
Last active July 24, 2020 07:07
git aliases
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch
git config --global alias.hist 'log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short'
git config --global alias.type 'cat-file -t'
git config --global alias.dump 'cat-file -p'
git config --global alias.fixlast "commit --all --amend --no-edit"
git config --global color.ui auto
@DimDev
DimDev / gist:6316362
Created August 23, 2013 07:09
Javascript events. Just add to bookmarks
javascript:(function() {var url = '//www.sprymedia.co.uk/VisualEvent/VisualEvent_Loader.js';if( typeof VisualEvent!='undefined' ) {if ( VisualEvent.instance !== null ) {VisualEvent.close();}else {new VisualEvent();}}else {var n=document.createElement('script');n.setAttribute('language','JavaScript');n.setAttribute('src',url+'?rand='+new Date().getTime());document.body.appendChild(n);}})();
@DimDev
DimDev / CustomMongoCollection.php
Created September 2, 2013 08:59
Save documents into Mongodb collection with autoincrement field
<?php
/**
* @Author Dmitry Kazberovich
*/
class CustomMongoCollection extends MongoCollection
{
private $_autoincrementFieldName;
public function __construct($db, $collectionName, $autoincrementFieldName = '')
# git up
git config --global alias.up '!(git add . && git stash && git pull --rebase >&2) | grep -v "No local changes to save" && git stash pop'
# git in / git out — смотреть какие коммиты придут/уйдут перед выполнением pull/push
git config --global alias.in '!git remote update -p; git log ..@{u}'
git config --global alias.out 'log @{u}..'
# git addremove - добавить в индекс новые файлы/изменения и удалить всё что удалилось
git config --global alias.addremove \!"git add . && git ls-files --deleted | xargs --no-run-if-empty git rm"
@DimDev
DimDev / gist:63a4136cce5325a74cf4
Created January 28, 2015 09:16
Site to another docroot
RewriteCond %{HTTP_HOST} ^site.donain.com$ [NC]
RewriteCond %{REQUEST_URI} !folder/
RewriteRule ^(.*)$ folder/$1 [L]
@DimDev
DimDev / gist:ace0cb07037c07e1c2d7
Created March 18, 2015 09:13
Drupal, Apache solr, Group search results to make them unique
/**
* Implements hook_apachesolr_query_prepare().
*/
function my_search_apachesolr_query_prepare($query) {
$query->addParams(array(
'group' => true,
'group.field' => 'path',
'group.main' => true,
)
);
@DimDev
DimDev / Drupal 7 settings.local.php
Created May 8, 2015 08:58
Drupal 7 settings.local.php
<?php
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'database',
'username' => 'username',
'password' => 'password',
'host' => 'localhost',
@DimDev
DimDev / Drupal 8: file relative url
Created May 25, 2016 11:57
Drupal 8: file relative url
file_url_transform_relative(file_create_url($user_picture_entity->getFileUri()));
@DimDev
DimDev / fix-drupal8-permissions.sh
Created September 19, 2018 11:43 — forked from GreenSkunk/fix-drupal8-permissions.sh
Drupal - Bash shell script to fix Drupal 8 permissions where the PHP Handler is FastCGI.
#!/bin/bash
path=${1%/}
user=${2}
group=${2}
help="\nHelp: This script is used to fix permissions of a Drupal 8 installation in which the PHP Handler is FastCGI\nYou need to provide the following arguments:\n\t 1) Path to your drupal installation\n\t 2) Username of the user that you want to give files/directories ownership\n\nNote: This script assumes that the group is the same as the username if your PHP is compiled to run as FastCGI. If this is different you need to modify it manually by editing this script or checking out forks on GitHub.\nUsage: bash ${0##*/} drupal_path user_name\n"
echo "Refer to https://www.Drupal.org/node/244924"