Skip to content

Instantly share code, notes, and snippets.

@dholmes
dholmes / gist:1154476
Created August 18, 2011 16:35
[zf] Quick and dirty validating field
<?php
$color = new Zend_Form_Element_Text('color');
$color->AddValidator('Regex',false,array('/^\#[a-f0-9]{6}$/i'));
$color->getValidator('Regex')->setMessages( array(
Zend_Validate_Regex::NOT_MATCH =>
'\'%value%\' is not valid. Use a value in the form of #112233'
));
@dholmes
dholmes / gist:1163356
Created August 22, 2011 19:56
[ZF] passing options to the pagination control
<?php
/* In your controller action */
class search extends Zend_Controller{
public function searchResultsAction()
{
$request = $this->getRequest();
$sort = $request->getParam('sort','date');
$this->view->sort = $sort;
$pageSize = (int) $request->getParam('pagesize',10);
@dholmes
dholmes / gist:1165580
Created August 23, 2011 15:56
[dojo] uncheck all the dijit checkBoxes contained within a single form, div, etc
dojo.query('#teamMemberInvitesList input[type=checkbox]').forEach(
function(node){
var checkbox = dijit.getEnclosingWidget(node);
if(checkbox){
checkbox.attr('checked',false);
}
}
);
@dholmes
dholmes / gist:1201528
Created September 7, 2011 19:46
Gone years without doing this....the flexible array of array / array of object filter
<!-- In some controller, etc somewhere -->
<?php
// Say you find yourself with a big array of data
$messageList = $email->getCompetitionMessages($competition);
// but you want to filter out anything from the admin
$messageList = array_filter($messageList,new Istart_Filter_ValueInObjectArrayFilter('fromEmail','admin@example.com'));
// Or, if < PHP 5.3
@dholmes
dholmes / gist:1278657
Created October 11, 2011 16:50
Dojo function for running through a bunch of dojo checkboxes, setting their disabled flag. Focus forces repaint.
function setFormState(disabled){
dijit.registry.forEach(function(w){
if(w.name.search(/application/i) >= 0){
w.disabled = disabled;
w.focus();
}
});
}
@dholmes
dholmes / gist:3102932
Created July 13, 2012 05:34
[wp-snippet] sidebar navigation
<?php
//if the post has a parent
$title = "";
global $post;
if($post->post_parent){
//collect ancestor pages
$relations = get_post_ancestors($post->ID);
//add current post to pages
array_push($relations, $post->ID);

Awesome PHP

A list of amazingly awesome PHP libraries, resources and shiny things.

Composer

@dholmes
dholmes / gist:00a4f9b45a7ad9a9301a
Created September 30, 2014 16:35
JS Inheritance the wrong way (apparently)
// Still trying to get the handle on JS OO - WAY too many years in C++ style languages I guess
// Anyway, for looking at later
function Collection() {
this.nextNewId = 1;
this.count = 0;
this.data = {};
}
Collection.prototype.getAll = function(){
@dholmes
dholmes / VagrantFile
Created July 28, 2015 20:56
Chunk of VagrantFile that I include the "hack" for -- seemed to address the issue.
config.vm.provision :puppet do |puppet|
puppet.facter = {
"hack=hack LANG=en_US.UTF-8 hack" => "hack",
'fqdn' => "#{config.vm.hostname}",
'ssh_username' => "#{ssh_username}",
'provisioner_type' => ENV['VAGRANT_DEFAULT_PROVIDER'],
}
puppet.manifests_path = "#{data['vm']['provision']['puppet']['manifests_path']}"
puppet.manifest_file = "#{data['vm']['provision']['puppet']['manifest_file']}"
puppet.module_path = "#{data['vm']['provision']['puppet']['module_path']}"
@dholmes
dholmes / kcphpug-homestead.md
Last active October 7, 2015 19:39
Notes for Homestead Talk - KC PHPUG / 2015-09-05

Dan's quick guide to adding a Homestead VM to your project

I'm always on the lookout for great ways to answer the question "How do I get started in PHP?" Sometimes, the hardest part is figuring out the server side of it, and everything you need to build something.

Homestead is a pre-configured, virtual server in a box. Easy to add to your project and has probably more services than you need but things you maybe haven't tried because you didn't know how to install them.

It is not a replacement for tools like Ansible|Chef|Puppet or even Docker--you can use those tools to script building not only your dev VM, but testing and production servers as well. But if you are looking for a quick way to add a dev VM to your project, or don't yet know the difference between Postfix and clearfix--those bigger tools can wait.

PreRequisites

Install

  • [VirtualBox]