Skip to content

Instantly share code, notes, and snippets.

@karrikas
karrikas / SymfonyCrawlerAddOptionToSelect.php
Last active February 24, 2021 10:45
Symfony Crawler how to add <option> to <select> element
<?php
use Symfony\Component\DomCrawler\Crawler;
$crawler = new Crawler('<html><body><select id="my_select"></select></body></html>');
$crawler->filter('select#my_select')->each(function (Crawler $crawler) {
$node = $crawler->getNode(0);
$option = new \DOMElement('option', 'Option Name');
$node->appendChild($option);
@karrikas
karrikas / cp-parent.sh
Last active February 15, 2021 14:34
Copy modified files between git commits
cp -pv --parents $(git diff --name-only sha1 sha2) ../path/to/copy
@karrikas
karrikas / bitbucket-pipelines.yml
Created January 28, 2021 12:42
Phpunit test in Symfony proyect with bitbucket
image: docker/compose
options:
docker: true
pipelines:
default:
- step:
size: 2x # double memory (8GB) for this step
script:
@karrikas
karrikas / database.sql
Last active April 4, 2019 13:16
Create new database and new user in mysql
CREATE DATABASE database;
CREATE USER user@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON database.* TO user@localhost;
FLUSH PRIVILEGES;
@karrikas
karrikas / Dockerfile
Last active October 31, 2018 16:10
Docker, Install wordpres cli in wordpress docker wp-cli
FROM wordpress:latest
WORKDIR /var/www/html
RUN apt-get update
RUN apt-get install -y curl \
gnupg
RUN curl -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
RUN chmod +x /usr/local/bin/wp
RUN wp --info
@karrikas
karrikas / my.sql
Created August 1, 2018 13:03
Mysql - Create database and its user;
CREATE DATABASE 'my_db';
CREATE USER 'my_user'@'localhost' IDENTIFIED BY 'my_pass';
GRANT ALL PRIVILEGES ON my_db.* TO 'my_user'@'localhost';
FLUSH PRIVILEGES;
# create a new branch
git checkout -b feature/example
# do some changes
# udpate master
git checkout master
git pull origin master
# rebase with master
@karrikas
karrikas / gulpfile.js
Last active August 29, 2017 11:27
Gulp deploy web by rsync
var gulp = require('gulp');
var shell = require('gulp-shell');
var prompt = require('gulp-prompt');
var init = {
ssh: {
user: "",
host: "",
port: "22",
path: ""
@karrikas
karrikas / send-push.php
Last active July 2, 2018 10:57
Firebase push notification by PHP example, cordova FCM_PLUGIN
<?php
// API access key from Google API's Console
define('API_ACCESS_KEY', 'your-key');
function pushMessage($title, $body, $sound = true)
{
$msg = array (
'body' => substr($body,0,40), // limit body
'title' => $title,
'click_action' => 'FCM_PLUGIN_ACTIVITY',
@karrikas
karrikas / functions.php
Created February 24, 2017 09:41
Add bootstrap responsive embed to wordpress automatic media embed and iframes
<?php
// your custom code...
add_filter('embed_oembed_html', 'my_embed_oembed_html', 10, 4);
function my_embed_oembed_html($html, $url, $attr, $post_ID) {
$iframe = str_replace('<iframe', '<iframe class="embed-responsive-item"', $html);
$newHtml = '<div class="embed-responsive embed-responsive-16by9">%s</iframe></div>';
$html = sprintf($newHtml, $iframe);
return $html;