This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function urlGenerator(domain) { | |
return function(url){ | |
return `https://${url}.${domain}` | |
} | |
} | |
const comUrl = urlGenerator('com') | |
const ruUrl = urlGenerator('ru') | |
console.log(comUrl('google')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
#select * { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Select { | |
constructor(selector, options) { | |
this.$el = document.querySelector(selector) | |
this.options = options | |
this.selectedId = null | |
this.setup() | |
} | |
setup() { | |
this.clickHandler = this.clickHandler.bind(this) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const randomPerson = () => { | |
let randomNumber = Math.floor( Math.random() * people.length ) | |
return randomNumber | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>HTML RATING</title> | |
<style> | |
.rating { | |
display: inline-flex; | |
flex-direction: row-reverse; | |
} | |
/* Hiding elements in an accessible way */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function format_bytes( $bytes, $precision = 2 ) { | |
$units = array( 'B', 'KB', 'MB', 'GB', 'TB' ); | |
$bytes = max( $bytes, 0 ); | |
$pow = floor( ( $bytes ? log( $bytes ) : 0 ) / log( 1024 ) ); | |
$pow = min( $pow, count( $units ) - 1 ); | |
$bytes /= pow( 1024, $pow ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'init', function(){ | |
add_rewrite_rule( '^(users)/([^/]*)/?', 'index.php?page_name=$matches[1]&page_type=$matches[2]&user_id=$matches[3]', 'top' ); | |
} ); | |
function prefix_register_query_var( $vars ) { | |
$vars[] = 'page_type'; | |
$vars[] = 'user_id'; | |
$vars[] = 'page_name'; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Remove bookmakers from post type | |
add_filter( 'post_type_link', 'rgbc_remove_slug', 10, 2 ); | |
function rgbc_remove_slug( $post_link, $post ) { | |
global $post; | |
if ( 'brand' !== $post->post_type || 'publish' !== $post->post_status ) { | |
return $post_link; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_default_scripts', 'zl_remove_jquery_migrate' ); | |
function zl_remove_jquery_migrate( $scripts ) { | |
if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) { | |
$script = $scripts->registered['jquery']; | |
if ( $script->deps ) { | |
$script->deps = array_diff( $script->deps, array( 'jquery-migrate' ) ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function rgbc_slugify( $text ) { | |
// replace non letter or digits by - | |
$text = preg_replace('~[^\pL\d]+~u', '-', $text); | |
// transliterate | |
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); | |
// remove unwanted characters | |
$text = preg_replace('~[^-\w]+~', '', $text); |