Skip to content

Instantly share code, notes, and snippets.

View veirus's full-sized avatar

Alex veirus

View GitHub Profile
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
));
<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>
@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;
@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 / 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 / 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 / foldmarker_map.vim
Created May 13, 2018 22:30
Simple mapping to quickly insert default fold marker
nnoremap <expr> <leader><Tab> getline('.') =~ "\"" ? "m1A {{{1<Esc>`1" : "m1A \" {{{1<Esc>`1"
nnoremap <expr> <leader>1<Tab> getline('.') =~ "\"" ? "m2A }}}1<Esc>`2" : "m1A \" }}}1<Esc>`2"
inoremap <expr> <localleader><Tab> getline('.') =~ "\"" ? "<Esc>m1A {{{1<C-o>`1" : "<Esc>m1A\" {{{1<C-o>`1"
inoremap <expr> <localleader>1<Tab> getline('.') =~ "\"" ? "<Esc>m2A }}}1<C-o>`2" : "<Esc>m2A\" }}}1<C-o>`2"
@veirus
veirus / switchvim.bat
Created May 14, 2018 06:36
Switch between two different .vim dirs on the fly - Windows version
@echo off
if exist "%USERPROFILE%\vimfiles" ( if not exist "%USERPROFILE%\vimfiles_" (move "%USERPROFILE%\vimfiles" "%USERPROFILE%\vimfiles_") else (echo "0 -> _ failed, _ exists"))
if exist "%USERPROFILE%\vimfiles1" ( if not exist "%USERPROFILE%\vimfiles" (move "%USERPROFILE%\vimfiles1" "%USERPROFILE%\vimfiles") else (echo "1 -> 0 failed, 0 exists"))
if exist "%USERPROFILE%\vimfiles_" ( if not exist "%USERPROFILE%\vimfiles1" (move "%USERPROFILE%\vimfiles_" "%USERPROFILE%\vimfiles1") else (echo "_ -> 1 failed, 1 exists"))
@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 / packit.py
Last active May 20, 2018 08:42
Pack current project folder into zip excluding node_modules
#!/usr/bin/env python3
import os
import zipfile
def printProgressBar (iteration, total, prefix = '', suffix = '', decimals = 0,
length = 100, fill = '█', span = ' '):
"""
Call in a loop to create terminal progress bar
@params:
iteration - Required : current iteration (Int)
total - Required : total iterations (Int)