Skip to content

Instantly share code, notes, and snippets.

View radist2s's full-sized avatar

Alex Batalov radist2s

  • Georgia, Tbilisi
View GitHub Profile
@radist2s
radist2s / canvasMatte.html
Last active April 23, 2024 16:31
Simple Canvas cliping with anti aliasing by alpha channel of mask image or canvas shape.
<canvas id="show" width="300" height="300"></canvas>
@radist2s
radist2s / docusaurus.config.js
Last active March 17, 2024 19:14
Adds `npx` and `npm exec --call` support to `@docusaurus/remark-plugin-npm2yarn` plugin.
{
// ...
docs: {
remarkPlugins: [
[
require('@docusaurus/remark-plugin-npm2yarn'),
{
sync: true,
converters: [
[
@radist2s
radist2s / bem-and-sass.md
Created March 25, 2019 15:07
BEM & SASS best practices

BEM & SASS best practices

Every block should be in separated file named as block.

Filename: rating-star.scss

.rating-star {
    $font-size: 0.5em;
    
    display: inline-block; // `display` style may be set freely
@radist2s
radist2s / git-clean-tree.md
Created October 10, 2023 12:01
Рекомендации по использованию Git для поддержания чистоты дерева изменений

Amend Commit

git commit --amend -m "New commit message"

Эта команда позволяет изменить сообщение последнего коммита на "New commit message".

🧹 Перезапись хеша: Поскольку содержание коммита изменяется (хотя бы сообщение), хеш коммита тоже изменится. Это, в свою очередь, приведёт к изменению хешей всех последующих коммитов, если таковые имеются.

@radist2s
radist2s / MessagesProvider.tsx
Created August 18, 2023 01:14
Next.js Dynamic I18nProvider with chunked LinguiJS messages
import { Messages, setupI18n } from '@lingui/core';
import { I18nProvider } from '@lingui/react';
import { ReactNode, useState } from 'react';
export const generateMessagesProvider = async (
locale: string,
{ messages }: { messages: Messages }
) => {
return function LocaleMessagesProvider({ children }: { children: ReactNode }) {
return (
@radist2s
radist2s / functions.php
Last active July 9, 2023 10:07 — forked from jaredatch/gist:11239971
Create ACF options page under custom post type menu
<?php
/**
* Create ACF options page under custom post type menu
*
* @since 1.0.0
*/
if ( function_exists( 'acf_add_options_sub_page' ) ){
acf_add_options_sub_page(array(
'title' => 'Event Settings',
'parent' => 'edit.php?post_type=events',
@radist2s
radist2s / Docker Machine Virtual Network creating issue fix.md
Created April 2, 2022 01:36
Docker Machine Virtual Network creating issue fix

Docker Machine Virtual Network creating issue fix

Error: VBoxManage: error: Code E_ACCESSDENIED (0x80070005) - Access denied (extended info not available)

  • Create file path /etc/vbox/networks.conf
  • Put the entry * 0.0.0.0/0 ::/0 (including leading star)
  • Profit!

Answer source

@radist2s
radist2s / Remove-zsh-history-entry.md
Created April 1, 2022 18:22
Remove zsh history entry

Remove zsh history entry

*BSD/Darwin (macOS):

LC_ALL=C sed -i '' '/porn/d' $HISTFILE

Linux (GNU sed):

@radist2s
radist2s / cf7-hooks.php
Created March 15, 2018 16:09
WordPress Contact Form 7 custom chars validation hooks
<?php
<?
// Hooks only for version 5 only, may be for previous version also works
if (!defined('WPCF7_VERSION') OR intval(WPCF7_VERSION) !== 5)
{
return;
}
add_filter( 'wpcf7_validate_text', 'wpcf7_text_allowed_chars_validation_filter', 11, 2 );
add_filter( 'wpcf7_validate_text*', 'wpcf7_text_allowed_chars_validation_filter', 11, 2 );
@radist2s
radist2s / ffmpeg.php
Last active February 22, 2021 15:59
Jaksta youtube WEBM video encoding fix (Bash and PHP versions of script)
#!/usr/bin/php
<?
// Rename this file to ffmpeg (without extention)
$dir = __DIR__;
$ffmpeg_bin = 'ffmpeg-bin';
setlocale(LC_CTYPE, 'ru_RU.UTF-8');
/*
Array
(