Skip to content

Instantly share code, notes, and snippets.

View mducharme's full-sized avatar

Mathieu Ducharme mducharme

View GitHub Profile
<?php
use \Psr\Http\Message\ServerRequestInterface;
use \Psr\Http\Message\ResponseInterface;
use \Charcoal\Action\ActionFactory;
// ...
$app->get('api/v1/{action:.*}', function(ServerRequestInterface $request, ResponseInterface $response, array $args=null) {
$action_ident = 'alert/action/api/v1/'.$args['action'];
App
->setup()
->setupConfig()
->setupLogger()
->routeManager()->setupRoutes()
[
->setupTemplates()
->setupActions()
->setupScripts()
->setupRoutables()
<?php
$view = new Presenter([
'id',
'foo' => [
1,
':id',
':foo'
],
'bar' => 'This is an hardcoded string',

mysql-backup-s3.sh

A tool to create mysql server backups and optionally compress them and save them on a remote S3 server.

It is built on top of mysqldump, gzip and aws-shell.

Run with -h for for help / usage information:

sh mysql-backup-s3.sh -h
@mducharme
mducharme / ROADMAP.md
Created July 14, 2017 20:34
Charcoal ROADMAP

Charcoal Roadmap

Ideas and todos for future development

charcoal-app

  • \Charcoal\App\Service\SitemapGenerator
  • Static generator et static middleware
  • Penser à loader directement par .htaccess
@mducharme
mducharme / optimize_images.sh
Created September 13, 2017 21:01
Image scripts
#!/bin/bash
print_help() {
echo "# optimize-images.sh";
echo "# Optimize all images in a given directory (recursively) with jpegoptim and optipng.";
echo "#";
echo "# USAGE";
echo "# optimize-images.sh --width=MAX_WIDTH --height=MAX_HEIGHT --dir=DIR";
echo "#";
echo "# PARAMETERS";
  • ExpressionInterface
    • JsonSerializable (jsonSerialize())
    • active()
    • raw()
    • data()
    • GroupInterface
      • Iterator / Traversable
      • type()
      • items()
      • conjunction()
@mducharme
mducharme / .htaccess
Last active November 24, 2017 04:22
Default .htaccess, avec static cache
# Enable static cache on index (home) page
DirectoryIndex static/index.html index.php
RewriteEngine On
<IfModule mod_vhost_alias.c>
RewriteBase /
</IfModule>
# Redirect Trailing Slashes If Not A Folder...
<?php
namespace Charcoal\Admin\Script\Tools;
use Exception;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Pimple\Container;
@mducharme
mducharme / DateTimeParser.php
Created April 9, 2018 01:18
DateTimeParser.php
@@ -0,0 +1,45 @@
<?php
namespace Charcoal\Model\Service;
use DateTime;
use DateTimeInterface;
use Exception;
use InvalidArgumentException;