Skip to content

Instantly share code, notes, and snippets.

<script>
(function (d, f) {
var l = d.createElement('link');
l.rel = 'stylesheet';
l.media = 'only all';
l.href = 'http://fonts.googleapi.com/css?family=' + f;
var s = d.getElementsByTagName('script')[0];
s.parentNode.insertBefore(l, s);
})(document, 'Source+Sans+Pro:200,400,700|Source+Code+Pro:400,600|Alegreya:400,400italic');
</script>
@anilex
anilex / composer.json
Created November 12, 2019 03:24 — forked from jaytaph/composer.json
Using the Symfony security component as standalone
{
"name": "jaytaph/security-example",
"require": {
"symfony/security-core": "~2.8"
},
"authors": [
{
"name": "Joshua Thijssen",
"email": "jthijssen@noxlogic.nl"
}
@anilex
anilex / mailgun-webhook.php
Created December 15, 2017 19:09 — forked from umrysh/mailgun-webhook.php
Very simple PHP webhook for Mailgun that emails you on errors.
<?php
$key = "<API Key>";
$from = "info@example.com";
$to = "dave@example.com";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if(isset($_POST['timestamp']) && isset($_POST['token']) && isset($_POST['signature']) && hash_hmac('sha256', $_POST['timestamp'] . $_POST['token'], $key) === $_POST['signature'])
{
if($_POST['event'] == 'complained') {
if (typeof jQuery != 'undefined') {
var filetypes = /\.(zip|exe|dmg|pdf|doc.*|xls.*|ppt.*|mp3|txt|rar|wma|mov|avi|wmv|flv|wav)$/i;
var baseHref = '';
if (jQuery('base').attr('href') != undefined) baseHref = jQuery('base').attr('href');
var hrefRedirect = '';
jQuery('body').on('click', 'a', function(event) {
var el = jQuery(this);
var track = true;
@anilex
anilex / gist:d24d335e0c64276bdcaf600525cd5b99
Created April 25, 2018 15:18 — forked from arjenblokzijl/gist:9272411
Generate ProcessWire pages with random titles, body and image
<?php
for ($i = 1; $i <= 20; $i++)
{
$title = file_get_contents("http://loripsum.net/api/1/plaintext/long/prude/");
$body = file_get_contents("http://loripsum.net/api/3/decorate/link/ul/prude/long/");
$template = "INSERT_TEMPLATE_HERE"; // i.e. 'basic-page'
$parent = "INSERT_PARENT_HERE"; // i.e. /about-us/
$c = new Page();
<?php
$di = $app->getContainer();
// -----------------------------------------------------------------------------
// Service providers
// -----------------------------------------------------------------------------
// Twig
$di->set('view', function () use ($di) {
$settings = $di->get('settings');
@anilex
anilex / monolog.php
Created May 19, 2017 21:10 — forked from mamchenkov/monolog.php
Example use of Monolog logger
<?php
// Before: composer require monolog/monolog
// composer autoloader
require_once 'vendor/autoload.php';
// Shortcuts for simpler usage
use \Monolog\Logger;
use \Monolog\Formatter\LineFormatter;
use \Monolog\Handler\StreamHandler;
@anilex
anilex / Version20121011141021.php
Created May 17, 2017 15:50 — forked from ziadoz/Version20121011141021.php
Doctrine DBAL and Migrations Example
<?php
/*
* /path/to/migrations/directory/Version20121011141021.php
*/
namespace ExampleMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
class Version20121011141021 extends AbstractMigration
@anilex
anilex / soap-debug.php
Created May 2, 2017 10:59 — forked from Marko-M/soap-debug.php
Debug SOAP requests
<?php
/**
* Debug SOAP requests
*/
$client = new SoapClient(
'http://example.loc/index.php/api/v2_soap/?wsdl'
);
// Set yourself debug session cookie, for Xdebug and Phpstorm
@anilex
anilex / gist:3ba778dc7bb7b65db3cce18f31c3f995
Created February 17, 2017 19:34 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>