Skip to content

Instantly share code, notes, and snippets.

View Banochkin's full-sized avatar
🤙
banochkin.com

Ruslan Banochkin Banochkin

🤙
banochkin.com
View GitHub Profile
@tomdaley92
tomdaley92 / README.md
Last active June 27, 2024 12:23
Proxmox - SPICE Client setup for MacOS

Proxmox - SPICE client setup for MacOS

  1. Install a working (and compiled) version of virt-viewer. You may view the homebrew package's upstream source on GitHub.

    brew tap jeffreywildman/homebrew-virt-manager
    brew install virt-viewer
  2. Once that's installed should be able make a call remote-viewer with a pve-spice.vv file downloaded from proxmox web interface

@premek
premek / mv.sh
Last active March 5, 2024 17:43
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
@lord-alfred
lord-alfred / keitaro_api_example.php
Last active November 5, 2020 21:55
Запрос к API Keitaro TDS v6 с запасным URL, в случае если TDS недоступна (позволяет не терять трафик)
<?php
// пример работы с Keitaro TDS v6 по API (написан на PHP 7 (!) из-за Throwable)
// запрет кэширования этой страницы в CloudFlare/браузере
header("Cache-Control: private");
// сюда можно воткнуть какой-то свой антибот, чтоб он отрабатывал до запуска общения с API
// примерно как-то так:
// require_once(__DIR__ . '/antibot.php');
@mtx-z
mtx-z / wp-bootstrap4.4-pagination.php
Last active April 4, 2023 12:55
Wordpress 5.4 Bootstrap 4.4 pagination (with custom WP_Query() and global $wp_query support) (UPDATED for Bootstrap 5: https://gist.github.com/mtx-z/af85d3abd4c19a84a9713e69956e1507)
<?php
/**
* @param WP_Query|null $wp_query
* @param bool $echo
* @param array $params
*
* @return string|null
*
* UPDATE for Bootstrap 5.0: https://gist.github.com/mtx-z/af85d3abd4c19a84a9713e69956e1507
*
@campusboy87
campusboy87 / setup_404_for_url_with_space.php
Last active October 17, 2017 10:26
Для страниц, которые имею пробел в ссылке, устанавливает ответ сервера 404.
<?php
add_action( 'pre_handle_404', function ( $false, $wp_query ) {
// если ярлык страницы содержит пробел...
$url = empty( $wp_query->query['pagename'] ) ? '' : $wp_query->query['pagename'];
if ( $url && strpos( $url, '%20' ) !== false ) {
$wp_query->set_404();
status_header( 404 );
nocache_headers();
@campusboy87
campusboy87 / insert_parse_post.php
Created October 8, 2017 14:32
Публикует спаршенную запись c проверкой, есть ли подобная запись в БД по уникальному ключу
<?php
/**
* Проверяет наличие метаполя поста с заданным занчением
*
* @param string $url уникальное значение для поста, к примеру путь будет url спаршенной статьи
*
* @return bool
*/
function is_unique_meta_parse_post( $url ) {
@campusboy87
campusboy87 / change_rrs_posts_date.php
Last active May 4, 2018 06:24
Изменяет порядок вывода постов в ленте RSS (feed) через равные указанные промежутки времени
<?php
/**
* Изменяет порядок вывода постов в ленте через равные промежутки времени
*
* @param WP_Query $query
*/
function change_rrs_posts_date( $query ) {
// Период обновления постов в ленте - 1 день
$period = 24 * HOUR_IN_SECONDS;
@crittermike
crittermike / wget.sh
Last active March 26, 2024 22:49
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
@thesadoo
thesadoo / getTelegramAvatar.php
Created July 21, 2017 19:34
Get user's Telegram avatar with a simple function using their Telegram usernames
<?php
function getTelegramAvatar($username='')
{
$username = $username;
$username = str_replace('@', '', $username);
$baseURL = 'https://telegram.me/';
$pageURL = $baseURL . $username;
@felixexter
felixexter / readme.md
Last active January 14, 2023 21:32
Undress your Trello links

Undress your Trello links

Before

Before custom script

https://trello.com/c/MMIAzcT1/461-candidates-new-%D1%82%D0%B5%D1%81%D1%82%D0%BE%D0%B2%D0%BE%D0%B5-%D0%B7%D0%B0%D0%B4%D0%B0%D0%BD%D0%B8%D0%B5-%D0%B4%D0%BB%D1%8F-%D0%BC%D0%B8%D0%B4%D0%BB-%D1%81%D0%B8%D0%BD%D1%8C%D0%BE%D1%80