Skip to content

Instantly share code, notes, and snippets.

@sylvainfilteau
sylvainfilteau / mapreduce.php
Created March 9, 2012 22:09
PHP map reduce (I hate myself)
<?php
$partition = function ($mapper, array $data, $nb_batches = 2) {
$length = count($data);
$nb_chunk = ceil($length / $nb_batches);
$chunks = array_chunk($data, $nb_chunk);
$batches = array();
foreach ($chunks as $chunk) {
@sylvainfilteau
sylvainfilteau / php.rb
Created May 6, 2012 17:34
Homebrew formula for PHP 5.4.0
require 'formula'
def mysql_installed?
`which mysql_config`.length > 0
end
def postgres_installed?
`which pg_config`.length > 0
end
@sylvainfilteau
sylvainfilteau / app-model-Bug.js
Created August 21, 2012 15:01
Warning when loading stores with Ext.application
Ext.define('App.model.Bug', {
extend: 'Ext.data.Model',
fields: ['id', 'title', 'description']
});
@sylvainfilteau
sylvainfilteau / gist:3906935
Created October 17, 2012 17:38
Find number of occurence of the word "class" in php file in the "tests" directory
find tests -iname "*.php" | xargs grep "class" | sort | cut -f 1 -d : | uniq -c | sort -n -r
@sylvainfilteau
sylvainfilteau / gist:3952812
Created October 25, 2012 14:21
Deny access to everything but a file type
<Directory /vagrant>
AllowOverride None
Order allow,deny
deny from all
</Directory>
<FilesMatch .jasper$>
Order allow,deny
allow from all
</FilesMatch>
@sylvainfilteau
sylvainfilteau / gist:4001608
Created November 2, 2012 14:16
Fonts available on CentOS 5.8
Bitstream Vera Sans
Bitstream Vera Sans Mono
Bitstream Vera Serif
DejaVu LGC Sans
DejaVu LGC Sans Condensed
DejaVu LGC Sans Light
DejaVu LGC Sans Mono
DejaVu LGC Serif
DejaVu LGC Serif Condensed
Dialog
@sylvainfilteau
sylvainfilteau / gist:4279342
Created December 13, 2012 20:03
Randomize players
<?php
$players = array('cedric', 'mathieu', 'sylvain', 'christian');
shuffle($players);
var_dump($players);
@sylvainfilteau
sylvainfilteau / RemoveFilteredTableEventSubscriber.php
Created March 16, 2013 20:26
Replace the orm:schema-tool:update command from Doctrine 2 with UpdateCommand.php. It will allow you to ignore table starting with B_ (see bootstrap file)
<?php
namespace Comet\Event\Subscriber;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Tools\ToolEvents;
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
class RemoveFilteredTableEventSubscriber implements EventSubscriber {
@sylvainfilteau
sylvainfilteau / get_ip_from_apt_source_list.sh
Last active December 28, 2015 01:19
Getting all IP addresses related to APT source host
grep -shri "^deb" /etc/apt | cut -d " " -f 2 | sort -u | sed -e 's;https\?://;;' | sed -e 's;/.*$;;' | xargs dig +short | sort -u
@sylvainfilteau
sylvainfilteau / link_dump.md
Last active December 29, 2015 11:38
Link dump of my browsers tabs I keep open to read sometime (looks more like never)