Skip to content

Instantly share code, notes, and snippets.

View pavelthq's full-sized avatar

Pavel pavelthq

View GitHub Profile
@pavelthq
pavelthq / Liberal Regex Pattern for Web URLs
Created March 14, 2018 13:37 — forked from gruber/Liberal Regex Pattern for Web URLs
Liberal, Accurate Regex Pattern for Matching Web URLs
The regex patterns in this gist are intended only to match web URLs -- http,
https, and naked domains like "example.com". For a pattern that attempts to
match all URLs, regardless of protocol, see: https://gist.github.com/gruber/249502
# Single-line version:
(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|s
<?php
$icons = yaml_parse_file('icons.yml');
$data = [];
foreach($icons['icons'] as $icon) {
$iconData = [
'title' => $icon['name'] .
(isset($icon['filter']) ? '('.implode(', ',$icon['filter']).')': '') .
(isset($icon['aliases']) ? '('.implode(', ',$icon['aliases']).')': ''),
'id' => $icon['id'],
@pavelthq
pavelthq / vertical-text.css
Created April 8, 2016 09:13 — forked from obenjiro/vertical-text.css
CrossBrowser Vertical CSS Text
/**
* Works everywere ( IE7+, FF, Chrome, Safari, Opera )
* Example: http://jsbin.com/afAQAWA/2/
*/
.rotated-text {
display: inline-block;
overflow: hidden;
width: 1.5em;
}
.rotated-text__inner {
@pavelthq
pavelthq / custom_view.js
Last active March 27, 2024 14:51
Visual Composer: Custom markup element example
(function($) {
window.VcCustomElementView = vc.shortcode_view.extend( {
elementTemplate: false,
$wrapper: false,
changeShortcodeParams: function ( model ) {
var params;
window.VcCustomElementView.__super__.changeShortcodeParams.call( this, model );
params = _.extend( {}, model.get( 'params' ) );
if ( ! this.elementTemplate ) {
add_filter( 'vc_grid_item_shortcodes', 'my_module_add_grid_shortcodes' );
function my_module_add_grid_shortcodes( $shortcodes ) {
$shortcodes['vc_post_content'] = array(
'name' => __( 'Post content', 'fluidtopics' ),
'base' => 'vc_post_content',
'category' => __( 'Content', 'fluidtopics' ),
'description' => __( 'Show current post content', 'fluidtopics' ),
'post_type' => Vc_Grid_Item_Editor::postType(),
);
add_filter( 'vc_gitem_template_attribute_post_custom_meta', 'vc_gitem_template_attribute_post_custom_meta', 10, 2 );
function vc_gitem_template_attribute_post_custom_meta( $value, $data ) {
/**
* @var null|Wp_Post $post ;
* @var string $data ;
*/
extract( array_merge( array(
'post' => null,
'data' => '',
@pavelthq
pavelthq / octocats.sh
Created December 23, 2015 11:07 — forked from aguegu/octocats.sh
A bash script to download all Octocats logos from http://octodex.github.com/
#!/bin/zsh
curl -s "https://octodex.github.com/" | grep "<img.*data-src" | grep -o "/image[^\"]*" | while read line; do
wget 'https://octodex.github.com'$line
done