Skip to content

Instantly share code, notes, and snippets.

http {
map $http_user_agent $limit_bots {
default '';
~*(google|bing|yandex|msnbot) $binary_remote_addr;
}
limit_req_zone $limit_bots zone=bots:10m rate=1r/m;
server {
@shmaltorhbooks
shmaltorhbooks / config.yml
Last active August 29, 2015 13:59
create session shared with Symfony2
services:
session.metadata_bag:
class: Symfony\Component\HttpFoundation\Session\Storage\MetadataBag
arguments:
- '_sf2_meta'
- '0'
public: false
session.file_handler:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler
arguments:
@shmaltorhbooks
shmaltorhbooks / sf2.sh
Last active August 29, 2015 14:00
init sf2 application on deploy
#!/bin/sh
echo "cache..."
php app/console cache:clear --env=dev
php app/console cache:clear --env=prod
echo "doctrine..."
php app/console doctrine:cache:clear-metadata
<?php
$filter = 'foo';
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('u');
$qb->from($this->getClassName() , 'u');
$qb->add('where', $qb->expr()->orx(
$qb->expr()->like('u.email', $qb->expr()->literal('%'.$filter.'%')),
@shmaltorhbooks
shmaltorhbooks / layout.html.twig
Last active August 29, 2015 14:03
fos js routing
<script type="text/javascript" src="{{ asset('/bundles/fosjsrouting/js/router.js') }}"></script>
{% if _env == 'prod' %}
<script type="text/javascript" src="{{ asset('/js/fos_js_routes.js') }}"></script>
{% else %}
<script type="text/javascript" src="{{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }}"></script>
{% endif %}
@shmaltorhbooks
shmaltorhbooks / footer.php
Created July 2, 2014 13:39
XHProf header/footer
@shmaltorhbooks
shmaltorhbooks / mediawiki.com.conf
Created July 3, 2014 09:36
Nginx config for MediaWiki
server {
listen 80;
server_name mediawiki.com;
root /var/www/mediawiki.com;
client_max_body_size 5m;
client_body_timeout 60;
#!/bin/sh
sudo ln -s /usr/local/bin/node /usr/bin/node
sudo ln -s /usr/local/lib/node /usr/lib/node
sudo ln -s /usr/local/bin/npm /usr/bin/npm
sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf
@shmaltorhbooks
shmaltorhbooks / doctrine.yml
Last active August 29, 2015 14:14
define doctrine as service in symfony2 DI-container
parameters:
doctrine_cache.class: Doctrine\Common\Cache\ArrayCache
doctrine_metadata.class: Doctrine\Common\Annotations\Reader
doctrine_configuration.class: Doctrine\ORM\Configuration
doctrine_entity_manager.class: Doctrine\ORM\EntityManagerInterface
doctrine_entity_manager_factory.class: Doctrine\ORM\EntityManager
doctrine.proxy_dir.path: '/path/to/proxy'
doctrine.proxy.namespace: 'Project\Proxies'
@shmaltorhbooks
shmaltorhbooks / router.yml
Created February 2, 2015 16:32
define symfony routing as service in symfony DI-container
parameters:
routing.file: 'routing_%core.name%.yml'
routing.cache:
debug: %core.debug%
cache_dir: '%core.cache_path%/routing/'
generator_cache_class: '%core.name%UrlGenerator%core.env%'
matcher_cache_class: '%core.name%UrlMatcher%core.env%'
services:
routing.file_locator: