Skip to content

Instantly share code, notes, and snippets.

View Mykola-Veryha's full-sized avatar
🏠
Working from home

Mykola Veryha Mykola-Veryha

🏠
Working from home
View GitHub Profile
sudo apt install android-tools-adb
sudo apt install android-tools-fastboot
fastboot flash recovery recovery.img
adb sideload vbmeta.img
adb sideload super_empty.img
adb sideload dtbo.img
adb sideload boot.img
adb sideload lineage-19.1-20231006-nightly-vayu-signed.zip

Keybase proof

I hereby claim:

  • I am mykola-veryha on github.
  • I am veryham (https://keybase.io/veryham) on keybase.
  • I have a public key ASB5olhAbNKDTEfhW4Ou4qE1k12B7LaIWBHqG9R4su4PPgo

To claim this, I am signing this object:

@Mykola-Veryha
Mykola-Veryha / copyFormValues.js
Last active August 29, 2022 22:47
Copy form values
const getFormValuesObject = (selector) => {
const form = document.querySelector(selector);
const formData = new FormData(form);
const formValues = {};
for (const [name, value] of formData.entries()) {
formValues[name] = value;
}
return formValues;
};
const BASE_URL = 'https://countriesnow.space/api/v0.1/countries'
let getCountries = async () => {
const response = await fetch(`${BASE_URL}`).then(response => response.json())
const { data } = response
data.forEach((country) => {
if (names.includes(country.country)) {
console.log(country) // {"country": "Afghanistan", "cities": [ "Herat", "Kabul", "Kandahar", "Molah", ...]}
}
@Mykola-Veryha
Mykola-Veryha / module_name.install.php
Last active February 19, 2022 01:05
Deploy vocabulary with default terms
<?php
/**
* @file
* Contains install, update and uninstall functions for the User module.
*/
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Site\Settings;
use Drupal\field\Entity\FieldConfig;
@Mykola-Veryha
Mykola-Veryha / states.php
Created February 18, 2022 11:35
New Zealand states, Australia states
<?php
$states = [
'australia_states' => [
'NSW' => 'New South Wales',
'QLD' => 'Queensland',
'SA' => 'South Australia',
'TAS' => 'Tasmania',
'VIC' => 'Victoria',
'WA' => 'Western Australia',
@Mykola-Veryha
Mykola-Veryha / CKEditor_filter.php
Created June 5, 2020 16:28
Drupal 8 CKEditor filter
<?php
namespace Drupal\MODULE_NAME\Plugin\Filter;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
/**
* Provides a filter to limit allowed HTML tags.
*
FROM surnet/alpine-wkhtmltopdf:3.9-0.12.5-full as wkhtmltopdf
FROM wodby/drupal-php:7.4-dev-4.15.3
USER root
# Install dependencies for wkhtmltopdf
RUN apk add --no-cache \
libstdc++ \
libx11 \
libxrender \
<?php
namespace Drupal\ln_follow_and_alert\Form;
use Drupal\Core\Batch\BatchBuilder;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@Mykola-Veryha
Mykola-Veryha / truncate_html.php
Last active April 11, 2020 18:15
Truncate html
<?php
function htmlTruncate(string $html, int $max_lenght) {
$dom= new \DOMDocument();
$dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
$xpath = new \DOMXPath($dom);
$body = $xpath->query('/html/body')->item(0);
$prev_lenght = 0;