Skip to content

Instantly share code, notes, and snippets.

View FlyingDR's full-sized avatar

Alexander Grimalovsky FlyingDR

View GitHub Profile
@FlyingDR
FlyingDR / replace-wp-domain.sh
Created October 25, 2021 13:53
Shell script to replace domain in WordPress database with help of the WP CLI
#!/usr/bin/env bash
if [[ -z "$1" || -z "$2" ]]; then
echo 'Usage replace-wp-domain.sh <old domain> <new domain> [<new scheme>]'
exit 1
fi
runner=''
if [[ -f './wp' && ! -z $(./wp --version | grep -i 'wp-cli') ]]; then
@FlyingDR
FlyingDR / input.scss
Created February 17, 2021 10:52
Generated by SassMeister.com.
$habr: 100;
/* No modifier */
.outside-before {
content: $habr;
}
@media (max-width: 100px) {
$habr: 20;
.inside {
@FlyingDR
FlyingDR / input.scss
Created February 17, 2021 10:42
Generated by SassMeister.com.
$habr: 100;
.outside-before {
content: $habr;
}
@media (max-width: 100px) {
$habr: 20;
.inside {
content: $habr;
@FlyingDR
FlyingDR / README.md
Created May 28, 2020 18:12
Test for libsass issue with empty placeholder

Small test to demonstrate libsass issue with attempt to compile SCSS stylesheet with empty placeholder.

  1. Install dependencies: npm install
  2. Compile test stylesheet with dart-sass as reference: npm run ds, observe no error
  3. Compile test stylesheet with libsass: npm run ns, observe error:
{
  "status": 1,
 "file": "test.scss",
@FlyingDR
FlyingDR / a.twig
Created December 15, 2019 13:28
Simplified setup to reproduce parent() function issue in Twig.js 1.14.0
{% extends 'b.twig' %}
{% block content %}
{{ parent() }}
<h2>This one came from inherited template</h2>
{% endblock %}
@FlyingDR
FlyingDR / _direction.scss
Created March 1, 2019 10:53
Collection of simple SCSS mixins that are useful for adapting site for RTL languages
////
/// Collection of simple SCSS mixins that are useful for adapting site for RTL languages
///
/// @author Alexander Grimalovsky <alexander.grimalovsky@gmail.com>
////
/// Apply styles that are specific to LTR languages
@mixin ltr() {
html[dir="ltr"] & {
@content;
@FlyingDR
FlyingDR / RegularExpression.php
Created July 18, 2018 14:39
Adaptation of regular expressions for extracting hashtags / mentions from official Twitter text library
<?php
/**
* Regular expressions to match various kinds of information within texts
*
* Taken from twitter-text library
*
* @url https://github.com/twitter/twitter-text
* @author Twitter, Inc and other contributors
* @author Alexander Grimalovsky <alexander.grimalovsky@gmail.com>
@FlyingDR
FlyingDR / import-error-php7.php
Created June 15, 2016 08:57
Test script to demonstrate problem into \Timber\Core::import() on PHP 7
<?php
class A {
public $public = 'public A';
protected $protected = 'protected A';
private $private = 'private A';
public $existing = 'value from A';
public function import( $info, $force = false ) {
if ( is_object( $info ) ) {
@FlyingDR
FlyingDR / CommentVotePersistenceListener.php
Last active August 29, 2015 13:57
Example solution for creating unique votes for FOSCommentBundle
<?php
namespace Acme\Bundle\DemoBundle\EventListener;
use FOS\CommentBundle\Event\VotePersistEvent;
use FOS\CommentBundle\Events;
use FOS\CommentBundle\Model\SignedVoteInterface;
use FOS\CommentBundle\Model\VoteManagerInterface;
use Acme\Bundle\DemoBundle\Entity\User;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
<?php
function getWaterAmount($walls)
{
$water = 0;
$pool = 0;
$highest = null;
$last = null;
do {
$current = array_shift($walls);