Skip to content

Instantly share code, notes, and snippets.

View ziadoz's full-sized avatar

Jamie York ziadoz

View GitHub Profile
@ziadoz
ziadoz / CapsuleServiceProvider.php
Last active May 1, 2020 02:46
Laravel Eloquent/Capsule Silex Service Provicer
<?php
use Silex\Application;
use Silex\ServiceProviderInterface;
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
use Illuminate\Cache\CacheManager;
class CapsuleServiceProvider implements ServiceProviderInterface
{
@ziadoz
ziadoz / footer.php
Created February 6, 2014 17:34
Perch Bug — When using the perch_content_create() function to create a region and then the perch_content() method to retrieve it, two regions get created — a shared one and one for the page.
@ziadoz
ziadoz / gmap.php
Created March 19, 2014 21:52
Generating a Static Google Map with PHP
<?php
$url = 'http://maps.googleapis.com/maps/api/staticmap?';
$bits = array(
'center' => 'Calgary Tower, Calgary, AB, Canada',
'zoom' => '16',
'size' => '800x600',
'maptype' => 'roadmap',
'markers' => 'color:0x576d4e|label:N|49.6967179,-112.8450119',
'sensor' => 'false',
);
@ziadoz
ziadoz / chromcast-bgs.js
Last active October 12, 2015 15:19
Download Google ChromeCast Backgrounds with CasperJS
/**
* Command: casperjs chomecast-bgs.js [DIR] [START] [END]
* Examples: casperjs chomecast-bgs.js ~/Downloads/Chromecast
* casperjs chomecast-bgs.js ~/Downloads/Chromecast 25
* casperjs chomecast-bgs.js ~/Downloads/Chromecast 25 35
*
* Note: [DIR] (Required) The directory to download. This must exist, it won't be created.
* [START] (Optional) Start is the image number to start from, incase the script fails and needs to be restarted.
* [END] (Optional) End is the image number to finish at, if you only want a specific range of images.
*/
@ziadoz
ziadoz / cleanup-plesk-logs.rb
Last active June 22, 2016 16:45
Plesk Log File Cleanup
#! /usr/bin/env ruby
# Cleanup Plesk 10.3 Log Files
# A handy little script to truncate Plesk log files.
# Useful for when you change the subscription log rotation settings.
# Make sure you backup your log files beforehand.
#
# Usage:
# ruby cleanup-plesk-logs.rb /var/www/vhosts
# ruby cleanup-plesk-logs.rb /var/www/vhosts -f
@ziadoz
ziadoz / audiobook_merge.rb
Last active September 21, 2017 13:38
Audiobook MP3 Merger
#!/usr/bin/env ruby
# Merge Audiobook MP3s
# This script will iterate through directories of audiobooks,
# combine the MP3 files and output the new file to a destination directory.
#
# Usage: ruby audiobook_merge.rb [SRC] [DEST]
# Example: ruby audiobook_merge.rb /audiobooks /audiobooks/combined
abort "Could not locate the 'cat' binary on your computer." if `which cat`.empty?
@ziadoz
ziadoz / console.php
Last active August 29, 2015 14:06
Add PHPMig Commands to Custom Symfony Console
<?php
require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Phpmig\Console\Command\CheckCommand;
use Phpmig\Console\Command\DownCommand;
@ziadoz
ziadoz / CreateForm.php
Created September 22, 2014 19:48
Symfony Form Modify Constraints
<?php
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
class CreateForm extends AbstractType
{
@ziadoz
ziadoz / AbstractForm.php
Created September 24, 2014 17:57
Aura Input / Filter Wrapper
<?php
/**
* A simple wrapper around Aura Input.
*/
use Aura\Input\Form;
use Aura\Input\Builder;
use Aura\Input\Filter;
use Aura\Html\HelperLocatorFactory;
use Aura\Filter\FilterFactory;
@ziadoz
ziadoz / cache.conf
Created November 5, 2014 20:06
PHP-FPM Nginx Website Configuration With FastCGI Caching
# Nginx FastCGI Cache: http://seravo.fi/2013/optimizing-web-server-performance-with-nginx-and-php
# More Caching: https://www.digitalocean.com/community/tutorials/how-to-setup-fastcgi-caching-with-nginx-on-your-vps
# Apache Bench Mac: http://kevify.com/2013/ab-on-mac/
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=MYAPP:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
server {
listen 80;