Skip to content

Instantly share code, notes, and snippets.

View renoirb's full-sized avatar

Renoir Boulanger renoirb

View GitHub Profile
@renoirb
renoirb / init.yml
Created November 1, 2013 22:17
Salt stack, context and Jinja template
#
# Some state file...
#
{% for site, args in pillar.get('sites', {}).items() %}
/etc/nginx/sites-available/{{ site }}:
file.managed:
- source: salt://nginx/files/site.conf.jinja
- template: jinja
- context:
site: {{ site }}
@renoirb
renoirb / ps-aux-grep-runjob.txt
Last active December 27, 2015 07:48
WebPlatform system problems. MediaWiki's runJobs.php script not lowering quantity of jobs.
#
# Same for [app1,app2,app3,app4]
#
$ salt 'app*' cmd.run 'ps aux|grep runJob'
...
app5.webplatform.org:
www-data 28200 0.0 0.0 4108 576 ? Ss Nov02 0:00 /bin/sh -c /usr/bin/php /srv/webplatform/wiki/current/maintenance/runJobs.php #1st run
www-data 28201 8.0 0.7 241648 59180 ? S Nov02 120:39 /usr/bin/php /srv/webplatform/wiki/current/maintenance/runJobs.php
www-data 28529 0.0 0.0 4108 576 ? Ss Nov02 0:00 /bin/sh -c /usr/bin/php /srv/webplatform/wiki/current/maintenance/runJobs.php #1st run
@renoirb
renoirb / etc-salt-master-d-pillars.conf
Created November 27, 2013 18:36
Separating a secret pillar repository, and spreading SSL certificates among hosts.
## in /etc/salt/master.d/pillars.conf
pillar_roots:
base:
- /srv/pillar
- /srv/private/pillar
@renoirb
renoirb / files-ssl.cnf
Last active January 11, 2020 22:54
Creating on a server MySQL configuration. Using those three
[client]
ssl
ssl-ca=/etc/mysql/ca-cert.pem
ssl-cert=/etc/mysql/client-cert.pem
ssl-key=/etc/mysql/client-key.pem
[mysqld]
ssl
ssl-cipher=DHE-RSA-AES256-SHA
ssl-ca=/etc/mysql/ca-cert.pem
@renoirb
renoirb / dabblet.css
Created December 18, 2013 19:51
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@renoirb
renoirb / mdn-compat-original.json
Last active August 29, 2015 13:55
MDN Compatibility tables import snapshots. See worked out version via https://github.com/webplatform/mdn-compat-importer, in this gist: https://gist.github.com/renoirb/8809405
/**
* FULL import
**/
{
"https://developer.mozilla.org/en-US/docs/Gamepad": {
"desktop": {
"General support": {
"Chrome": {
"prefix": "21.0"
},
@renoirb
renoirb / compat-mdn.json
Last active August 29, 2015 13:56
MDN Compatibility tables import snapshots. See original data: https://gist.github.com/renoirb/8746058
This file has been truncated, but you can view the full file.
[
{
"breadcrumb": [
"Web",
"CSS",
":indeterminate"
],
"category": "css",
"contents": {
"desktop": {
@renoirb
renoirb / performance.conf
Created February 27, 2014 02:01
Making systematic variable configuration based on server provisioning.
{%- set ram_int = salt['grains.get']('mem_total', '1024') // 1024 -%}
{%- set max_clients = ram_int * 150 -%}
{%- if ram_int == 1 -%}
{%- set max_per_child = 1000 -%}
{%- elif ram_int == 2 -%}
{%- set max_per_child = 10000 -%}
{%- else -%}
{%- set max_per_child = 0 -%}
{%- endif -%}
# Edited by Salt Stack, generated with calculations
@renoirb
renoirb / TimeHelper.php
Created March 17, 2014 00:25
PHP Time Helper
<?php
namespace Renoir\Util;
// Specific
use \DateTime;
use \DateInterval;
/**
* Time helper utility
@renoirb
renoirb / ApiConverterHandler.md
Last active August 29, 2015 13:57
Read for `Content-Type` in request, hijacks response to format.

Convert into an API a Symfony2 response

You want to create an alternate way to serve your data from your controllers on a Symfony2 project.

How about adding one event listener to convert to JSON anything that is sent from a controller. To do this, your project has to have your controllers to return arrays of Doctrine2 Entities and also to leverage @Template and @Route.

If you already do, only insert this EventListener and ensure you have a dependency or two met (below). Note that except the Serializer, the other ones are not required, you would need to manually create the services in your project (not covered here).

Use