Skip to content

Instantly share code, notes, and snippets.

View dmitry-korolev's full-sized avatar

Dima Korolev dmitry-korolev

View GitHub Profile
const transparent = 'display: none!important;'
class ColorLite extends HTMLElement {
connectedCallback() {
this.card = document.createElement('ha-card');
const container = document.createElement('div');
this.card.appendChild(container);
this.card.style.background = 'none';
#!/bin/bash
LIST=(
"stapp"
"stapp-formbase"
"stapp-loaders"
"stapp-persist"
"stapp-react"
"stapp-rxjs"
"stapp-select"
@dmitry-korolev
dmitry-korolev / example.jsx
Last active July 16, 2018 13:58 — forked from artalar/example.jsx
[RFC] global stream with declarative suscriptions
/* Example #1 */
// Store.js
// `Atom()` - create new stream
const a = Atom(0);
const b = Atom(0);
function reverseString(string) {
var arr = new Array(string.length),
middle = Math.ceil(string.length / 2);
for (var x = 0, y = string.length - 1; x <= middle; x++, y--) {
arr[x] = string[y];
arr[y] = string[x];
}
return arr.join('');
@dmitry-korolev
dmitry-korolev / breakpoint.md
Last active December 30, 2015 01:18
LESS alternative (doesn't cover all functions although) to breakpoint-sass (http://breakpoint-sass.com/)
@dmitry-korolev
dmitry-korolev / cookies.js
Last active October 10, 2015 17:17
Simple functions to work with cookies. Plain JS.
/**
* @link https://learn.javascript.ru/cookie
*/
function setCookie(name, value, options) {
options = options || {};
var expires = options.expires;
if (typeof expires == "number" && expires) {
@dmitry-korolev
dmitry-korolev / md_rioe.php
Created September 22, 2015 17:34
Return instead of echoing.
<?php
/**
* This function can be used to return (instead of echoing) results
* of build-in functions, that cannot return, just echo.
* @return mixed Results of called function.
*/
function md_rioe() {
if (func_num_args() === 0) {
trigger_error('Nothing to call', E_USER_WARNING);
@dmitry-korolev
dmitry-korolev / post_thumbnail_urls.php
Created September 22, 2015 17:25
Returns urls of all sizes of the post thumbnail (featured image).
<?php
/**
* Returns urls of all sizes of the post thumbnail (featured image).
* @param integer $post_id Post ID
* @return array Key-value array of sizes and urls.
*/
function md_post_thumbnail_urls($post_id) {
$thumbnail_id = get_post_thumbnail_id( $post_id );
@dmitry-korolev
dmitry-korolev / remove_jquery.php
Created September 22, 2015 17:21
Remove jQuery from the front.
<?php
/**
* Completely removes jQuery from the front.
*/
function remove_jquery() {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_deregister_script('jquery-migrate');
wp_register_script('jquery', '', false, '1.11.3', true);
wp_enqueue_script('jquery');
@dmitry-korolev
dmitry-korolev / get_excerpt_by_id.php
Created September 22, 2015 17:19
Get excerpt by id in Wordpress.
<?php
if (!function_exists(get_excerpt_by_id)) {
/**
* Returns excerpt by ID. WP_Post->post_excerpt if it presents, wp_trim_words on other case.
* @param mixed $post WP_Post object or post ID. Accepts WP_Post object or post ID (integer or string);
* @return string Excerpt
*/
function get_excerpt_by_id($post) {
$return_excerpt = function($post) {
if ($post->post_excerpt == '')