Skip to content

Instantly share code, notes, and snippets.

View karser's full-sized avatar

Dmitrii Poddubnyi karser

View GitHub Profile
@karser
karser / LoginSubcriber.php
Created July 23, 2020 10:09 — forked from nuryagdym/LoginSubcriber.php
Symfony 4.4 google captcha integration to login form using KarserRecaptcha3Bundle
<?php
namespace App\EventSubscriber;
use App\Form\LoginType;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
@karser
karser / TCB_Landing_Page_Transfer.php
Last active October 21, 2020 19:22
Here is a fix for Thrive Architect which allows to import themes from thelandingfactory when attachments are stored on S3. https://docs.thelandingfactory.com/article/51-how-do-i-install-the-template-on-my-website
<?php
//wp-content/plugins/thrive-visual-editor/landing-page/inc/TCB_Landing_Page_Transfer.php
class TCB_Landing_Page_Cloud_Templates_Api {
public function import( $file, $page_id ) {
$template_name = $this->importValidateFile( $file );
$file = $this->getLocalPath($file); // <----------------- line added
$zip = new ZipArchive();
INFO: 2019/12/28 19:39:58.499689 weave 2.6.0
INFO: 2019/12/28 19:39:58.503768 Docker API on unix:///var/run/docker.sock: &[GoVersion=go1.10.8 Os=linux KernelVersion=4.4.127-mainline-rev1 BuildTime=2019-02-28T05:59:55.000000000+00:00 ApiVersion=1.39 Components=[{"Details":{"ApiVersion":"1.39","Arch":"amd64","BuildTime":"2019-02-28T05:59:55.000000000+00:00","Experimental":"true","GitCommit":"774a1f4","GoVersion":"go1.10.8","KernelVersion":"4.4.127-mainline-rev1","MinAPIVersion":"1.12","Os":"linux"},"Name":"Engine","Version":"18.09.3"}] Version=18.09.3 MinAPIVersion=1.12 GitCommit=774a1f4 Arch=amd64 Experimental=true Platform={"Name":"Docker Engine - Community"}]
INFO: 2019/12/28 19:39:58.566162 proxy listening on unix:///var/run/weave/weave.sock
INFO: 2019/12/28 19:39:59.188760 Bridge type is bridged_fastdp
INFO: 2019/12/28 19:39:59.188797 Communication between peers via untrusted networks is encrypted.
INFO: 2019/12/28 19:39:59.238500 Our name is 22:bb:2e:ae:0b:62(A2)
INFO: 2019/12/28 19:39:59.238603 Launch d
@karser
karser / DeserializeNestedArrayOfObjectsTest.php
Last active October 11, 2018 23:23
[Serializer] Deserialization ignores argument type hint from phpdoc for array in constructor argument https://github.com/symfony/symfony/issues/28825
<?php
namespace Symfony\Component\Serializer\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
@karser
karser / mount-nbd.sh
Last active January 20, 2023 16:07
Automatic mounting of additional NBD volumes using systemd on Ubuntu
#!/bin/bash
if [ "$#" -ne 2 ] ; then
echo 'Usage: mount-nbd.sh <device> <mount_point>'
exit 1
fi
device=$1
fs_type=$(blkid -o value -s TYPE $device)
if [[ -z $fs_type ]] ; then
@karser
karser / FormMassAction
Last active December 4, 2019 16:26
APYDataGridBundle: Custom mass action with parameters
use APY\DataGridBundle\Grid\Action\MassAction;
use Symfony\Component\Form\FormInterface;
class FormMassAction extends MassAction
{
/** @var FormInterface */
protected $form;
public function getFormView()
{
#Servers
set :application, "internetsms"
set :domain, "internetsms.org"
set :deploy_to, "/home/karser/internetsms"
set :app_path, "app"
role :web, domain # Your HTTP server, Apache/etc
role :app, domain # This may be the same as your `Web` server
role :db, domain, :primary => true # This is where Symfony2 migrations will run
set :keep_releases, 3
logger.level = Logger::INFO
<?php
set_time_limit(0);
// set input args
$master_host = $argv[1];
$master_user = $argv[2];
$master_pass = $argv[3];
$slave_host = $argv[4];
$slave_user = $argv[5];