Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bologer's full-sized avatar
🎯
Focusing

Alexander Teshabaev bologer

🎯
Focusing
View GitHub Profile
@bologer
bologer / random_useraname.js
Last active July 10, 2021 16:52
Generate random username based on real name and last name from given array.
// call generateRandomUsername()
// example output: edward_cannon137
// example output: thomas1295_deitz
// example output: tim2225_caswell31
function generateRandomUsername() {
let firstnames = [ "Adam", "Alex", "Aaron", "Ben", "Carl", "Dan", "David", "Edward", "Fred", "Frank", "George", "Hal", "Hank", "Ike", "John", "Jack", "Joe", "Larry", "Monte", "Matthew", "Mark", "Nathan", "Otto", "Paul", "Peter", "Roger", "Roger", "Steve", "Thomas", "Tim", "Ty", "Victor", "Walter"];
let lastnames = ["Anderson", "Ashwoon", "Aikin", "Bateman", "Bongard", "Bowers", "Boyd", "Cannon", "Cast", "Deitz", "Dewalt", "Ebner", "Frick", "Hancock", "Haworth", "Hesch", "Hoffman", "Kassing", "Knutson", "Lawless", "Lawicki", "Mccord", "McCormack", "Miller", "Myers", "Nugent", "Ortiz", "Orwig", "Ory", "Paiser", "Pak", "Pettigrew", "Quinn", "Quizoz", "Ramachandran", "Resnick", "Sagar", "Schickowski", "Schiebel", "Sellon", "Severson", "Shaffer", "Solberg", "Soloman", "Sonderling", "Soukup", "Soulis", "Stahl", "Sweeney", "Tandy",
@bologer
bologer / hypercomments-spam.js
Last active April 17, 2020 06:39
Hypercomments Spam
var dictionary = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean augue magna, aliquet vitae finibus vel, semper a arcu. Sed pretium dignissim consectetur. Ut diam diam, volutpat ut orci non, laoreet elementum justo. Nulla imperdiet odio ante, vulputate cursus ipsum mollis et. Donec dictum, dolor varius tempus dapibus, ante ligula bibendum leo, nec semper libero enim a leo. Nulla aliquet massa ac sem finibus fringilla. Vestibulum ut euismod dui. Morbi sit amet mollis velit. Maecenas id sapien ut risus efficitur fermentum vestibulum vitae purus. Sed ultrices magna vitae elit ultricies, vitae placerat tellus aliquet. Vivamus sit amet luctus augue. Nunc sit amet eleifend mauris, eu elementum est. Proin tempor enim odio, in sagittis est porta vestibulum. Duis lobortis in nisi a placerat. Cras eu volutpat lacus, vitae malesuada sapien. Cras vestibulum urna tellus, in sagittis massa facilisis vitae. Proin maximus sodales eros, id elementum arcu aliquam a. Quisque eget enim et velit maximus scelerisq
@bologer
bologer / anycomment-woo-reset-default.php
Created March 30, 2020 19:39
Remove AnyComment's comments template from WooCommerce single page
<?php
/**
* Overrides anycomment template on WooCommerce single product page.
*
* @param $theme_template
*
* @return string
*/
function anycomment_woocommerce_override( $theme_template ) {
if ( class_exists( 'WooCommerce' ) && is_product() ) {
@bologer
bologer / anycomment-popup.js
Last active December 4, 2019 09:54
anycommnet-popup.js
/**
* Ждем пока в DOM появится элемент с указанным селектором
* и вызовем колбек в момент появления.
*
* @param selector
* @param callback
*/
function waitForEl( selector, callback ) {
var poller = setInterval(
function() {
@bologer
bologer / ac_get_post_rating.php
Last active June 12, 2019 17:39
AnyComment получить рейтинг записи
<?php
// Функцию ниже нужно добавить в functions.php вашей темы
// Пример вывода в single.php: echo ac_get_post_rating(get_the_ID());
/**
* Возвращает рейтинг записи по ID записи.
*
* @see \AnyComment\Models\AnyCommentRating::get_average_by_post() для подробной информации.
* @return float
*/
@bologer
bologer / functions.php
Created February 12, 2019 12:33
Remove WooCommerce tab from AnyComment
<?php
add_filter( 'woocommerce_product_tabs', 'sb_woo_remove_reviews_tab', 1000);
function sb_woo_remove_reviews_tab($tabs) {
unset($tabs['reviews']);
return $tabs;
}
@bologer
bologer / exclude_anycomment.php
Last active January 12, 2019 22:04
Exclude anycomment core js asset in j news
<?php
// Только без "<?php" выше
add_filter( 'minit-exclude-js', function($excludes) {
$excludes[] = 'anycomment-js-bundle';
return $excludes;
});
@bologer
bologer / gist:70e5513f35c9020a9961a768c1c56c14
Created January 7, 2019 09:16 — forked from saippuakauppias/gist:4714695
javascript vkontakte api wall post: постинг на стену к текущему пользователю на JS vk API. С помощью этого кода так же можно отправлять записи на стены групп, пользователей и публичных страниц (пабликов). Используется в iframe приложениях вконтакте.
/*
* message - сообщение, которое будет опубликовано
* image - картинка для постинга
* user_id - id текущего пользователя (к нему будет осуществлён постинг)
*/
function wallPost(message, image, user_id) {
VK.api('photos.getWallUploadServer', {
uid: user_id
}, function (data) {
if (data.response) {
@bologer
bologer / functions.php
Created November 3, 2018 17:20
Hide admin bar from users who cannot manage options
<?php
/**
* Disable admin bar for users who cannot manage options.
*/
function anycomment_disable_admin_bar() {
if ( is_plugin_active( 'anycomment/anycomment.php' ) ) {
if ( ! current_user_can( 'manage_options' ) ) {
show_admin_bar( false );
}
@bologer
bologer / functions.php
Last active November 3, 2018 09:44
Add custom classes to #comments for AnyComment
<?php
function anycomment_custom_js() {
?>
jQuery(document).on('ready', function($) {
$('#comments').addClass('gridlove-comments gridlove-box box-inner-p-bigger');
});
<?php
}
add_action('wp_footer', 'anycomment_custom_js');