Skip to content

Instantly share code, notes, and snippets.

View veirus's full-sized avatar

Alex veirus

View GitHub Profile
@veirus
veirus / findmedia8.py
Created March 12, 2018 09:39
Findmedia.py - generate a (play)list of specified filetypes
#!/usr/bin/env python3
'''Findmedia - generate a (play)list of specified filetypes'''
import os
__revision__ = '8'
vidia = ('3gp', 'AVI', 'VOB', 'WMV', 'wmv', 'avi', 'flv', 'mka', 'mkv',
'mov', 'mp4', 'mpeg', 'mpg', 'vob', 'ogm')
newformats = ('webm')
@veirus
veirus / com.bat
Created January 16, 2018 09:11
Moving pictures into corresponding dirs: batch file edition.
@echo off
if exist "*.jpg" (md ".\jpg\") && (move *.jpg ".\jpg\") && (move *.jpeg ".\jpg\") ELSE (echo no jpg)
if exist "*.tga" (md ".\tga\") && (move *.tga ".\tga\") ELSE (echo no tga)
if exist "*.bmp" (md ".\bmp\") && (move *.bmp ".\bmp\") ELSE (echo no bmp)
if exist "*.gif" (md ".\gif\") && (move *.gif ".\gif\") ELSE (echo no gif)
if exist "*.psd" (md ".\psd\") && (move *.psd ".\psd\") ELSE (echo no psd)
if exist "*.png" (md ".\png\") && (move *.png ".\png\") ELSE (echo no png)
@veirus
veirus / switchdict.py
Created December 25, 2017 09:26
dict instead of switch block
def a():
print("a")
def b():
print("b")
def default():
print("default")
@veirus
veirus / search.css
Created December 13, 2017 07:37
Search input custom element. Also works well with wp
/* header__search {{{3 */
/* use postcss-next */
&__search {
text-align: right;
cursor: pointer;
position: relative;
@nest & .screen-reader-text {
position: absolute;
left: -9999px;
top: -99999px;
<div class="header__contacts col-9 col-m-12">
<div class="col-8 col-m-12">
<?php $_phone = get_field('site_phone', 'options');
$_tel = preg_replace("/[^0-9]/", "", $_phone); ?>
<p><a href="tel:+<?php echo $_tel;?>" class="phone"><?php echo $_phone; ?></a></p>
<p><?php the_field('site_adress', 'options'); ?></p>
</div>
<div class="col-4 col-m-12 header__btns"><a class="btn js-mopen" href="#modal">Заказать консультацию</a></div>
</div>
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'menu_title' => 'Настройки контента',
'menu_slug' => 'theme-general-settings',
'capability' => 'edit_posts',
//'icon_url' => '/wp-content/themes/tt_landing/favicon.png',
'post_id' => 'options',
'position' => 2,
'redirect' => true
));
@veirus
veirus / wp_debug_show_template_name.php
Last active October 31, 2017 08:37
Show template file name to figure out what fucking part is now loaded into view
<?php if (1): ?>
<h1 class="title title-debug" style="position: fixed; bottom:20px; right: 0; margin: 16px 0; padding: 10px; border-radius: 8px 0 0 8px; font-size: 16px; background-color: #d4e0c1; opacity: .42; z-index: 9999; user-select: none; text-shadow: 1px 1px 0px green, 1px 2px 3px rgba(0,255,0,.3), 3px 3px 3px hsla(173, 67%,47%,.75), -1px -1px 0px red, -3px -3px 3px rgba(255,0,0,.3);">
<!-- debug -->
<?php global $template; echo basename($template); ?>
</h1>
<?php endif; ?>
@veirus
veirus / wp_disable_autoformat.php
Last active October 17, 2017 09:19
Disable autoformatting in the Wordpress post editor
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_content', 'wptexturize' );
remove_filter( 'the_excerpt', 'wpautop' );
remove_filter( 'comment_text', 'wpautop' );
@veirus
veirus / show_tax_id.php
Created October 13, 2017 10:01
Show taxonomy ID in wordpress admin panel
// show tax id's in admin panel:
// https://wordpress.stackexchange.com/a/77536
foreach ( get_taxonomies() as $taxonomy ) {
add_action( "manage_edit-${taxonomy}_columns", 't5_add_col' );
add_filter( "manage_edit-${taxonomy}_sortable_columns", 't5_add_col' );
add_filter( "manage_${taxonomy}_custom_column", 't5_show_id', 10, 3 );
}
add_action( 'admin_print_styles-edit-tags.php', 't5_tax_id_style' );
function t5_add_col( $columns )
@veirus
veirus / cvimrc
Last active September 14, 2017 06:17
config for cvim chrome extension
" cvim config v.0.0.1
map gr gT
map gb :buffer<Space>
"==================================================
" russian langmap for hotkeys to work in both kb layouts
" credit: https://gist.github.com/rynffoll/7bb30a47b3b8d39687f588ecc2be5425
" also: https://gist.github.com/MaxLevs/f519d361d3946d6d877085f909e13043
let langmap = "Ё|АFБ<ВDГUДLЕTЖ:ЗPИBЙQКRЛKМVНYОJПGРHСCТNУEФAХ{ЦWЧXШIЩOЪ}ЫSЬMЭ\"Ю>ЯZаfб\\,вdгuдlеtж\\;зpиbйqкrлkмvнyоjпgрhсcтnуeфaх[цwчxшiщoъ]ыsьmэ'ю.яzё\\№#"
"==================================================
let blacklists = ["http://www.typing.com/*","http://www.heuxasoftware.com/*","http://www.keybr.com/*","http://www.reddit.com/*","https://sirxemic.github.io/*","http://vim-adventures.com/*","https://mail.google.com/*","https://timeinvariant.github.io/*","http://www.platinumgames.co.jp/*","http://codecombat.com/*","http://johanw123.nu/*","http://hughsk.io/*","https://np.reddit.com/*","chrome-extension://hgimloonaobbeeagepickockgdcghfnn/*","https://blastar-1984.appspot.com/*","http://redditp.com/*",