Skip to content

Instantly share code, notes, and snippets.

View alexmazaltov's full-sized avatar
🎯
Blockchain development

Oleksii Bondarenko alexmazaltov

🎯
Blockchain development
View GitHub Profile
@alexmazaltov
alexmazaltov / git_empty_branch
Created October 18, 2020 18:26 — forked from j8/git_empty_branch
Create new branch with empty folder structure
You can create a new empty branch like this:
$ git checkout --orphan NEWBRANCH
--orphan creates a new branch, but it starts without any commit. After running the above command you are on a new branch "NEWBRANCH", and the first commit you create from this state will start a new history without any ancestry.
The --orphan command keeps the index and the working tree files intact in order to make it convenient for creating a new history whose trees resemble the ones from the original branch.
Since you want to create a new empty branch that has nothing to do with the original branch, you can delete all files in the new working directory:
@alexmazaltov
alexmazaltov / Makefile
Created October 15, 2020 13:13 — forked from andypost/Makefile
drupal 8 core contributor docker kickstarter
.PHONY: up upx log down exec exec0 h t
CUID := $(shell id -u)
CGID := $(shell id -g)
IMAGEPHP := skilldlabs/php:73
all: | exec
up:
docker run --rm --name core8 \
@alexmazaltov
alexmazaltov / mv_recursive.sh
Last active October 7, 2020 13:59
snippet to move folder and create non existing folders in the provided path
mv ./web/sites/report/ `mkdir -p ./web/sites/phpunit/ && echo $_`
#It will move whole folder located at path ./web/sites/report/ to the new location
#At the result folder report would be located on the new path inside parent folder phpunit
# command mkdir -p creates non existinf folders in provided path ./web/sites/phpunit/
@alexmazaltov
alexmazaltov / loop.html.twig
Created October 2, 2020 13:36
Using loop.last in twig template with loop
{% for type in types %}
<span itemprop="employmentType" content="{{ type.key }}">{{ type.text }}</span>
{% if not loop.last %}<br />{% endif %}
{% endfor %}
@alexmazaltov
alexmazaltov / email_validation_simple.php
Created September 28, 2020 06:35 — forked from anxp/email_validation_simple.php
Simple email address validation - check syntax and MX record existing.
<?php
function _nxte_redeem_is_email_valid($email) {
if (empty ($email)) {return false;}
list($user_name, $mail_domain) = explode('@', $email);
if (empty($user_name) || empty($mail_domain)) {return false;}
$is_syntax_ok = (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
$is_MX_exists = checkdnsrr($mail_domain, 'MX');
@alexmazaltov
alexmazaltov / using_limit_validation_errors.php
Created September 28, 2020 06:31 — forked from anxp/using_limit_validation_errors.php
How to correctly use #limit_validation_errors element of Form API in Drupal 7
<?php
//Sometimes we need to submit only part of the form. Sure, if form has #required fields, all they will be highlighted with red,
//and form will not be submitted if these elements have no value.
//To workaround this, we can use '#limit_validation_errors' option AND custom submit function for every 'Partial Submit' button.
//Interesting note: when we use '#limit_validation_errors', we will see ALL form fields in _validate function,
//but in _submit function will be visible ONLY elements, included in '#limit_validation_errors' array!!!
//Case 1. The most simple.
//We want to make a 'reset' button, or 'previous step' button, so it must work even if some REQUIRED form elements are empty: