Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Vic Cherubini viccherubini

🎯
Focusing
  • Rockwall, TX
View GitHub Profile
@viccherubini
viccherubini / ProductImporterTest.php
Created Dec 20, 2015
ProductImport Test Suite With Data Provider
View ProductImporterTest.php
<?php
use MyApp\Tests\TestCase;
class ProductImporterTest extends TestCase
{
/**
* @dataProvider providerProductFile
*/
@viccherubini
viccherubini / ProductImporterTest.php
Created Dec 20, 2015
ProductImport Test Suite With Mocks
View ProductImporterTest.php
<?php
use MyApp\Library\Feeds\ProductImporter;
class ProductImporterTest extends PHPUnit_Framework_TestCase
{
public function testImportingProducts()
{
// Imagine this was a sample array of data.
View validation.php
<?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([
View Histogram.php
<?php
class Histogram
{
/** @var array */
private $buckets = [];
/** @var integer */
private $count = 0;
@viccherubini
viccherubini / aws-sdk.php
Created Sep 24, 2014
AWS SDK base_url Questions
View aws-sdk.php
<?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 Jun 18, 2014
Phinx sample configuration
View phinx.yml.template
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 Aug 29, 2015
PHP cURL oddness
View curl.php
<?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 Mar 10, 2014
Testable JavaScript
View javascript.js
(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 Nov 4, 2013
Expert PHP Deployments Nginx virtual host configuration file.
View vhost-expert-php-applications.conf
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 Nov 4, 2013
Expert PHP Deployments nginx.conf configuration file.
View nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;