Skip to content

Instantly share code, notes, and snippets.

@maryo
maryo / PSPad.ini
Created November 19, 2012 22:31
TypeScript syntax highlight definition for PSPad (experimental)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; CUSTOM COLORS (OPTIONAL) - APPEND IT TO YOUR PSPad.ini ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[TypeScript]
Filter=TypeScript (*.ts)|*.ts
HLTabWidth=4
IndentChar=
UnIndentChar=
Comment=009696961FFFFFFF000
Identifier=1FFFFFFF1FFFFFFF000
@maryo
maryo / nginx.conf
Created February 9, 2013 16:31
Nginx dart configuration
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
@maryo
maryo / FunctionMocker.php
Last active December 14, 2015 17:49
Simple function mocker for PHP 5.3
<?php
class FunctionMocker
{
/** @var FunctionMocker[] */
private static $instances = array();
/** @var string */
private $namespace;
/** @var string */
@maryo
maryo / SafeConditionWalker.php
Last active December 24, 2015 07:19
Doctrine2 Sandboxing Safe Condition DQL AST Walker
<?php
use Doctrine\ORM\Query\AST;
use Doctrine\ORM\Query\TreeWalkerAdapter;
class SafeConditionWalker extends TreeWalkerAdapter
{
/** @var bool */
private $inCondition = false;
/**
@maryo
maryo / Client.php
Last active August 29, 2015 14:03
Doctrine2 isolation of tests
<?php
namespace Company\SecretBundle\Test;
use Doctrine\DBAL\Connection;
use Symfony\Bundle\FrameworkBundle\Client as BaseClient;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\HttpKernel\TerminableInterface;
@maryo
maryo / IsolatedKernelTestCase.php
Last active November 2, 2015 16:28
Symfony2 / Doctrine2 Tests isolation without schema reloading / DB purging + fixtures support
<?php
namespace AcmeBundle\Test;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
use Doctrine\Common\DataFixtures\Loader;
use Doctrine\Common\DataFixtures\ReferenceRepository;
use Doctrine\DBAL\Connection;
use Doctrine\ORM\EntityManager;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
@maryo
maryo / convert_to_camelcase.php
Created May 17, 2018 02:41
Convert unicode string to camel case
<?php
function substring(string $string, int $start, int $length = null): string
{
return mb_substr($string, $start, $length, 'UTF-8');
}
function lower(string $string): string
{
return mb_strtolower($string, 'UTF-8');
@maryo
maryo / vlna.php
Created December 5, 2018 13:45
Vlna na webu
<?php
function vlna(string $text): string
{
return preg_replace('/([^a-zA-Z0-9])([ksvzaiou])\s([a-zA-Z0-9]{1,})/i', "\$1\$2\xc2\xa0\$3", $text);
}
@maryo
maryo / SnippetRenderer.php
Created December 16, 2018 15:52
Symfony snippet renderer
<?php
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\HttpKernel\KernelEvents;
@maryo
maryo / download.js
Created January 28, 2019 01:24
Typekit font downloader
const https = require('https');
const fs = require('fs');
// https://github.com/majodev/google-webfonts-helper/blob/master/server/logic/conf.js
const FORMAT_USER_AGENTS = {
// see http://www.dvdprojekt.de/category.php?name=Safari for a list of sample user handlers
// test generation through running grunt mochaTest:src
eot: 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)',
woff: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0',
// must serve complete woff2 file for one variant (no unicode range support yet!)