Skip to content

Instantly share code, notes, and snippets.

View piotrplenik's full-sized avatar

Piotr Plenik piotrplenik

View GitHub Profile
@piotrplenik
piotrplenik / docker
Created March 24, 2017 09:00
Turn on Docker Remote API on Ubuntu (on port 2375)
# File: etc/default/docker
# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS=""
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock"
@piotrplenik
piotrplenik / phpbrew-install.sh
Last active February 21, 2019 09:47
PHPBrew for Symfony 3 on Ubuntu and Debian
# Install Requrements
apt-get install curl libxslt1-dev libreadline6-dev libmcrypt-dev libicu-dev g++ \
libcurl4-openssl-dev libssl-dev clibcurl4-openssl-dev pkg-config libssl-dev libsslcommon2-dev \
pkg-config libcurl3 autoconf libmagickwand-dev libmagickcore-dev
# Install PHPBrew (https://github.com/phpbrew/phpbrew)
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew; chmod +x phpbrew
sudo mv phpbrew /usr/local/bin/phpbrew
########################
@piotrplenik
piotrplenik / SampleControllerTest.php
Last active July 28, 2016 14:46
Sample test with login
<?php
/*
* This file is part of the MyJobCompany platform.
*
* © MyJobCompany https://myjob.company
*/
namespace tests\AppBundle\Controller;
@piotrplenik
piotrplenik / convert-to-flat-pdf.sh
Created May 23, 2016 10:15
Covert PDF to flat PDF
#!/bin/bash
FILE=$1
OUTPUTFILE=$2
TEMPDIR=`mktemp -d`
gs -q -dSAFER -dBATCH -dNOPAUSE -sDEVICE=jpeg -dJPEGQ=95 -r600 -o $TEMPDIR/out-%05d.jpg $FILE
SIZES=(`identify -format "%W-%H\n" $FILE`)
function isJpeg($string) {
if(ord($string[0]) != 0xFF) {
return false;
}
if(ord($string[1]) != 0xD8) {
return false;
}
$count = strlen($string);
@piotrplenik
piotrplenik / flat-pdf.sh
Created November 25, 2013 15:25
Create flatten PDF file
#!/bin/bash
# Script to convert PDF - create flatten PDF file
#
# Format:
# ./convert input-file.pdf output-file.pdf
@piotrplenik
piotrplenik / sfWidgetFormSelectRadioSingleable.class.php
Last active December 16, 2015 13:39
sfWidgetFormSelectRadioSingleable Symfony widget lets you render just one option at a time. Extends sfWidgetFormSelectRadio. Inspiration from https://gist.github.com/ain/4165050
<?php
/**
* This file is part of the MnumiPrint package.
*
* (c) Mnumi Sp. z o.o. <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@piotrplenik
piotrplenik / ssh_key_validation.php
Created August 3, 2012 14:25
SSH-RSA/SSH-DSA validation
<?php
public function validateKey($value)
{
$key_parts = explode(' ', $value, 3);
if (count($key_parts) < 2) {
return false;
}
/*
* Formatter for Selenium 2 / WebDriver PHP client.
*/
var subScriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
subScriptLoader.loadSubScript('chrome://selenium-ide/content/formats/webdriver.js', this);
function useSeparateEqualsForArray() {
return true;
}
@piotrplenik
piotrplenik / New way to set the encoder.
Created December 31, 2011 19:04 — forked from damienalexandre/New way to set the encoder.
Playing with the Symfony2 serializer
<?php
// Inside your action
$this->serializer = new \Symfony\Component\Serializer\Serializer();
$this->serializer->addNormalizer(new \Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer());
$this->serializer->setEncoder('xml', new \Symfony\Component\Serializer\Encoder\XmlEncoder());
return $this->createResponse($this->serializer->encode($page, 'xml'), 200, array('Content-Type' => 'application/xml'));