Skip to content

Instantly share code, notes, and snippets.

View veirus's full-sized avatar

Alex veirus

View GitHub Profile
@veirus
veirus / dror5.py
Last active May 14, 2018 06:43
DROR updated for Python 3.6
#!/usr/bin/env python3.6
# dror - datetime format edition
# Based on https://gist.github.com/dansku/9040240#file-dropboxorganize-py
# 2018-05-14: convert to Pathlib; remove .encode('utf-8'); add alt output template
__verstion__ = '0.5.2'
import os.path
import glob
from datetime import date
from pathlib import Path
@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 / visually-hidden.css
Created August 8, 2017 11:55
visually-hidden - hard version
.visually-hidden {
position: absolute !important;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
padding:0 !important;
border:0 !important;
height: 1px !important;
width: 1px !important;
overflow: hidden;
}
.credits
{
display: inline-block;
float: right;
color: var(--cl-credit);
}
.prostor
{
color: var(--cl-credit);