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 / build
Created September 19, 2025 17:28
Build script for Symfony project
#!/bin/bash
DBDUMP=${1:-$1}
DBHOST="localhost"
DBUSER="database_user"
DBNAME="database_name"
DBADMIN="$USER"
function main {
@viccherubini
viccherubini / dump-db
Created September 17, 2025 21:32
PostgreSQL database dump script
#!/usr/bin/env php
<?php
// Data from the following tables
// will not be included in the dump
$excludeTableDataTables = [
'event',
'sessions',
];
@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 = [];