Skip to content

Instantly share code, notes, and snippets.

View viccherubini's full-sized avatar
🚀
Zooming

Vic Cherubini viccherubini

🚀
Zooming
View GitHub Profile
@viccherubini
viccherubini / ProductImporterTest.php
Created December 20, 2015 06:11
ProductImport Test Suite With Data Provider
<?php
use MyApp\Tests\TestCase;
class ProductImporterTest extends TestCase
{
/**
* @dataProvider providerProductFile
*/
@viccherubini
viccherubini / ProductImporterTest.php
Created December 20, 2015 06:07
ProductImport Test Suite With Mocks
<?php
use MyApp\Library\Feeds\ProductImporter;
class ProductImporterTest extends PHPUnit_Framework_TestCase
{
public function testImportingProducts()
{
// Imagine this was a sample array of data.
@viccherubini
viccherubini / validation.php
Created September 29, 2015 16:48
Symfony Validation
<?php
$constraints = [
// Here is the issue, I want to assert the vendor_num key
// of the $vendor array below is both not blank AND has
// a length <= 24 (and who knows, more constraints down the road).
// The issue is that Collection() expects vendor_num to
// be an array. How to do I chain these without calling
// addPropertyConstraint() a bunch because I don't have access to it.
'vendor_num' => new Assert\Collection([
@viccherubini
viccherubini / Histogram.php
Last active August 29, 2015 14:21
Histogram.php
<?php
class Histogram
{
/** @var array */
private $buckets = [];
/** @var integer */
private $count = 0;
@viccherubini
viccherubini / aws-sdk.php
Created September 24, 2014 15:06
AWS SDK base_url Questions
<?php
// Configuration, using AWS SDK 2.6.16
return [
'includes' => ['_aws'],
'services' => [
'default_settings' => [
'params' => [
'key' => 'xxx',
'secret' => 'yyyy',
@viccherubini
viccherubini / phinx.yml.template
Created June 18, 2014 18:27
Phinx sample configuration
paths:
migrations: %%PHINX_CONFIG_DIR%%/../migrations
environments:
default_migration_table: _migrations
default_database: test
prod:
adapter: pgsql
host: "@@DB_SETTINGS_HOST@@"
name: "@@DB_SETTINGS_DATABASE@@"
@viccherubini
viccherubini / curl.php
Last active August 29, 2015 13:57
PHP cURL oddness
<?php
// This fails, but only on staging (DigitalOcean) server.
// Works fine on production (Linode) server.
// Please ignore bad security practices.
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://server.com:2143');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_POSTFIELDS, '<CommandQuery/>');
@viccherubini
viccherubini / javascript.js
Created March 10, 2014 21:39
Testable JavaScript
(function($app, $jQuery) {
"use strict";
var CampaignGroupCollection = function(options) {
this.init(options);
};
CampaignGroupCollection.prototype.init = function(options) {
this.collection = options.collection;
this.campaignGroups = [];
@viccherubini
viccherubini / vhost-expert-php-applications.conf
Created November 4, 2013 03:24
Expert PHP Deployments Nginx virtual host configuration file.
server {
listen 80;
server_name expertphpdeployments.com www.expertphpdeployments.com;
return 301 https://expertphpdeployments.com$request_uri;
}
server {
listen 443;
server_name expertphpdeployments.com;
@viccherubini
viccherubini / nginx.conf
Created November 4, 2013 03:19
Expert PHP Deployments nginx.conf configuration file.
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;