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 / 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:
@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 / 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 / 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 / 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 / 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 / 0.json
Last active November 27, 2023 18:07
NFT AI LOGO
{
"tokenId": 0,
"name": "AlefInvest logo NFT",
"description": "This is logo of AlefInvest trademark as NFT created with a simple smart contract.",
"image": "https://raw.githubusercontent.com/alexmazaltov/bitcoin-test-net-history/master/g60.png"
}
@alexmazaltov
alexmazaltov / CODE_OF_CONDUCT.md
Last active April 15, 2024 22:44
Contributing Guidelines ADOPTED from Amazon Open Source Code of Conduct.
@alexmazaltov
alexmazaltov / backup.sh
Created April 27, 2024 22:58
In case anyone needs a script to get a backup from directus instance using postgres database here it is.
#backup.sh
#!/bin/bash
# Define variables
LABEL="DBASH"
REMOTE_USER="root"
REMOTE_HOST="15.15.15.1"
POSTGRES_CONTAINER_NAME="postgresql-s0g8css"
POSTGRES_USER="LKDoajsdhjkj123" # Replace with your PostgreSQL username
POSTGRES_DB="directus" # Replace with your PostgreSQL database name
{
"url": "https://alefinvest.xyz",
"name": "AI NFT Marketplace",
"iconUrl": "https://i.ibb.co/1nnc4g4/2024-05-30-15-10-58.jpg",
"termsOfUseUrl": "https://ton-connect.github.io/demo-dapp-with-react-ui/terms-of-use.txt",
"privacyPolicyUrl": "https://ton-connect.github.io/demo-dapp-with-react-ui/privacy-policy.txt"
}